Re: Tkinter fonts setting

2008-02-06 Thread jim-on-linux
On Tuesday 05 February 2008 15:22, Unnamed 
One wrote:
 First question - is it possible to set
 font to default OS font for window text?
 It would be preferable, while on my
 Windows XP system Tkinter sets small
 Helvetica-style font by default.

 Secondly, can I set font globally (or
 specify default font for widgets)? In
 fact, all I want is to get default OS font
 unless (rarely) I need to specify another.

 Thanks


Go to:
http://www.pythonware.com/library/tkinter/introduction/

Read chapter 6,  Widget Styling, there is a 
section on Fonts which has a sub-section on  
System Fonts.

jim-on-linux
http://www.inqvista.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter fonts setting

2008-02-06 Thread Unnamed One
jim-on-linux wrote:
 On Tuesday 05 February 2008 15:22, Unnamed 
 One wrote:
   
 First question - is it possible to set
 font to default OS font for window text?
 It would be preferable, while on my
 Windows XP system Tkinter sets small
 Helvetica-style font by default.

 Secondly, can I set font globally (or
 specify default font for widgets)? In
 fact, all I want is to get default OS font
 unless (rarely) I need to specify another.

 Thanks
 


 Go to:
 http://www.pythonware.com/library/tkinter/introduction/

 Read chapter 6,  Widget Styling, there is a 
 section on Fonts which has a sub-section on  
 System Fonts.

 jim-on-linux
 http://www.inqvista.com
   
These are fonts supported by individual systems, but not fonts set there 
as default.

Regarding my questions, I guess both are impossible in Tkinter (as I 
didn't found anything about that in any Tkinter documentation), but 
there still must be a way to get the default OS font name and size 
(maybe outside of Tkinter), because it's always advised to use them in 
applications.

Otherwise text, for example, will always be too large or too small on 
some screens.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter fonts setting

2008-02-06 Thread Gabriel Genellina
En Wed, 06 Feb 2008 14:02:35 -0200, Unnamed One [EMAIL PROTECTED]  
escribi�:

 jim-on-linux wrote:
 On Tuesday 05 February 2008 15:22, Unnamed
 One wrote:

 First question - is it possible to set
 font to default OS font for window text?
 It would be preferable, while on my
 Windows XP system Tkinter sets small
 Helvetica-style font by default.

 Secondly, can I set font globally (or
 specify default font for widgets)? In
 fact, all I want is to get default OS font
 unless (rarely) I need to specify another.

 Go to:
 http://www.pythonware.com/library/tkinter/introduction/

 Read chapter 6,  Widget Styling, there is a
 section on Fonts which has a sub-section on
 System Fonts.

None of them is suitable as a default text font. Prior to Tk 8.5, there is  
no way to get the right fonts used by the OS/desktop/theme. Tk 8.5 may  
provide that, but I haven't got it yet (see  
http://www.tcl.tk/cgi-bin/tct/tip/145.html)

 Regarding my questions, I guess both are impossible in Tkinter (as I
 didn't found anything about that in any Tkinter documentation), but
 there still must be a way to get the default OS font name and size
 (maybe outside of Tkinter), because it's always advised to use them in
 applications.

Yes. Your second question is easy; google for tkinter default font.
To obtain the desired font description, on Windows, you can use the  
pywin32 package or ctypes to call the following functions, and then  
configure Tkinter to use the desired font by default.
Use SystemParametersInfo(SPI_GETNONCLIENTMETRICS,...) to obtain a  
NONCLIENTMETRICS structure.
 From it, obtain the lfMessageFont field (this is the default font for  
message boxes; you may be interested on others too, like lfMenuFont). It  
has all the info you need: lfFaceName is the font name, the various flags  
determine the font style, note that bold == lfWeight=500.
Maybe lfHeight it's a bit complicated; it's the height in pixels, to  
convert to points (1/72):

hdc = GetDC(0)
dpi = GetDeviceCaps(hdc, LOGPIXELSY)
font_size = int(round(abs(lfHeight) * 72 / dpi))
ReleaseDC(0, hdc)


-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

Tkinter fonts setting

2008-02-05 Thread Unnamed One
First question - is it possible to set font to default OS font for 
window text? It would be preferable, while on my Windows XP system 
Tkinter sets small Helvetica-style font by default.

Secondly, can I set font globally (or specify default font for 
widgets)? In fact, all I want is to get default OS font unless (rarely) 
I need to specify another.

Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list