|
List Info
Thread: System Font Size
|
|
| System Font Size |

|
2006-07-11 12:07:20 |
Hello all,
I'm creating a windows application, with a Tkinter GUI.
I currently happily set the font sizes using tuples
``font=("name",
"size", "weight")``. (or something
like that.)
I use a couple of different sizes for titles, subtitles,
body text and
buttons.
I would like to detect the system font size, so that I can
respond to
this. (In case the user has specified larger fonts). Does
anyone know
how I can do this ?
Oh, and while I'm on the subject, does anyone know of a
pure Python
combobox other than the Pmw one ? The Pmw one is fine, it
just means
distributing the Pmw extension with my application, and if I
could
replace this with a single file I would.
All the best,
Fuzzyman
http:/
/www.voidspace.org.uk/python/index.shtml
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
a>
|
|
| System Font Size |

|
2006-07-11 14:54:20 |
If you want to find the default font used for a particular
item, create
one and interrogate it:
>>> b = Tkinter.Button(app)
>>> b.cget("font")
'-monotype-arial-medium-r-normal-*-12-*-*-*-p-*-iso8859-15
'
(in this case, it's a Linux system with the fonts coming
from the X
resource database in XLFD format)
You can find out details of the font using the tkFont
module:
>>> import tkFont
>>> f = tkFont.Font(b,
b.cget("font"))
>>> fo.metrics()
{'fixed': 0, 'ascent': 11, 'descent': 3,
'linespace': 14}
>>> fo.configure()
{'family': 'arial', 'weight': 'normal',
'overstrike': '0', 'size': '9',
'slant': 'roman', 'underline': '0'}
>>> fo.measure("Hello World")
64
You can construct a new font similar to an existing one:
>>> fc = fo.configure()
>>> fc.weight = 'bold'
>>> nf = tkFont.Font(b, **fc)
>>> b.configure(font=nf, text="Bold
Button")
>>> b.pack()
You can also find the available "font families":
>>> tkFont.families(b)
('nimbus roman no9 l', 'arial black', 'clearlyu
devangari extra', ...
I'm not sure what use this is:
>>> tkFont.names(b)
('font136858972', 'font136997436')
Jeff
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
a>
|
|
| System Font Size |

|
2006-07-11 15:03:52 |
Jeff Epler wrote:
>If you want to find the default font used for a
particular item, create
>one and interrogate it:
> >>> b = Tkinter.Button(app)
> >>> b.cget("font")
>
'-monotype-arial-medium-r-normal-*-12-*-*-*-p-*-iso8859-15
'
>
>
Wow, on windows I get :
'{MS Sans Serif} 8'
That's pretty different.
If I then change my system font size to "extra
large" and repeat the
exercise, the default font size is unchanged. The text on
the title bar
is made bigger, but buttons created have the same smaller
size text.
Looks like I'll have to find a win32 way to check the
system settings. :-(
Thanks anyway Jeff.
All the best,
Fuzzyman
http:/
/www.voidspace.org.uk/python/index.shtml
>(in this case, it's a Linux system with the fonts
coming from the X
>resource database in XLFD format)
>
>You can find out details of the font using the tkFont
module:
> >>> import tkFont
> >>> f = tkFont.Font(b,
b.cget("font"))
> >>> fo.metrics()
> {'fixed': 0, 'ascent': 11, 'descent': 3,
'linespace': 14}
> >>> fo.configure()
> {'family': 'arial', 'weight': 'normal',
'overstrike': '0', 'size': '9',
> 'slant': 'roman', 'underline': '0'}
> >>> fo.measure("Hello World")
> 64
>
>You can construct a new font similar to an existing one:
> >>> fc = fo.configure()
> >>> fc.weight = 'bold'
> >>> nf = tkFont.Font(b, **fc)
> >>> b.configure(font=nf, text="Bold
Button")
> >>> b.pack()
>
>You can also find the available "font
families":
> >>> tkFont.families(b)
> ('nimbus roman no9 l', 'arial black', 'clearlyu
devangari extra', ...
>I'm not sure what use this is:
> >>> tkFont.names(b)
> ('font136858972', 'font136997436')
>
>Jeff
>
>
>
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
a>
|
|
| System Font Size |

|
2006-07-11 16:24:02 |
Tk font sizes are independent of Windows so looking for a
win32com means
of querying the system font sizes may be required. As to
your combobox
question, I don't use pmw but the combobox should be fairly
simple to
create. To refresh my mem on it I looked up examples of the
two types,
simple & dropdown. The simple version would be pretty
easy to do with a
label and listbox. The dropdown version would be harder,
but if you
don't care about the arrow icon and don't need to select
multiple items
in the combobox dropdown, then an OptionMenu would be the
way to go.
Another thing to consider is tying a ListBox to a Button or
MenuButton.
I've never tried this but I believe I've seen others on
the web say it
can be done.
Bobby
-----Original Message-----
From: tkinter-discuss-bounces python.org
[mailto:tkinter-discuss-bounces python.org]On Behalf Of
Fuzzyman
Sent: Tuesday, July 11, 2006 8:04 AM
To: Jeff Epler
Cc: tkinter-discuss python.org
Subject: Re: [Tkinter-discuss] System Font Size
Jeff Epler wrote:
>If you want to find the default font used for a
particular item, create
>one and interrogate it:
> >>> b = Tkinter.Button(app)
> >>> b.cget("font")
>
'-monotype-arial-medium-r-normal-*-12-*-*-*-p-*-iso8859-15
'
>
>
Wow, on windows I get :
'{MS Sans Serif} 8'
That's pretty different.
If I then change my system font size to "extra
large" and repeat the
exercise, the default font size is unchanged. The text on
the title bar
is made bigger, but buttons created have the same smaller
size text.
Looks like I'll have to find a win32 way to check the
system settings.
:-(
Thanks anyway Jeff.
All the best,
Fuzzyman
http:/
/www.voidspace.org.uk/python/index.shtml
>(in this case, it's a Linux system with the fonts
coming from the X
>resource database in XLFD format)
>
>You can find out details of the font using the tkFont
module:
> >>> import tkFont
> >>> f = tkFont.Font(b,
b.cget("font"))
> >>> fo.metrics()
> {'fixed': 0, 'ascent': 11, 'descent': 3,
'linespace': 14}
> >>> fo.configure()
> {'family': 'arial', 'weight': 'normal',
'overstrike': '0', 'size':
'9',
> 'slant': 'roman', 'underline': '0'}
> >>> fo.measure("Hello World")
> 64
>
>You can construct a new font similar to an existing one:
> >>> fc = fo.configure()
> >>> fc.weight = 'bold'
> >>> nf = tkFont.Font(b, **fc)
> >>> b.configure(font=nf, text="Bold
Button")
> >>> b.pack()
>
>You can also find the available "font
families":
> >>> tkFont.families(b)
> ('nimbus roman no9 l', 'arial black', 'clearlyu
devangari extra',
...
>I'm not sure what use this is:
> >>> tkFont.names(b)
> ('font136858972', 'font136997436')
>
>Jeff
>
>
>
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
a>
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
a>
|
|
| System Font Size |

|
2006-07-12 21:36:26 |
Fuzzyman wrote:
> Oh, and while I'm on the subject, does anyone know of
a pure Python
> combobox other than the Pmw one ? The Pmw one is fine,
it just means
> distributing the Pmw extension with my application, and
if I could
> replace this with a single file I would.
here's an old module that might be useful:
http://svn.effbot.python-hosting.com
/stuff/sandbox/tkinter/tkComboChooser.py
</F>
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
a>
|
|
[1-5]
|
|