tkinter font selector?
Bob van der Poel
bvdpoel at uniserve.com
Mon Jun 26 13:33:04 EDT 2000
Thanks. I looked at the tk stuff which gets the list of families. What
I'm wondering is if there is a way for tk to get the possible
sizes/weights which are available for a family? I guess one could just
parse the output from xlsfonts and play with that...
Richard Chamberlain wrote:
>
> Hi Bob,
>
> In tkFont there is a method called families which returns a list
> of installed fonts. I've created a little script below which
> pops them in a combobox and changes the font of a label
> according to the item selected. It would be fairly easy to to
> add size and style (but I'll let you do that ;) ).
>
> from Tkinter import *
> from tkFont import families
> import Pmw
> root = Tk()
> Pmw.initialise()
>
> choice = None
> comboentries = families(root)
> lblTest = Label(root, text='Test Font',padx=20, pady=10)
> lblTest.pack(expand=1, fill=BOTH, padx=8, pady=8)
>
> def selectFont(entry):
> lblTest.configure(font=(entry,10))
> combobox = Pmw.ComboBox(root, label_text='Font:', labelpos='wn',
> listbox_width=24, dropdown=1,
> scrolledlist_items=comboentries,
> selectioncommand=selectFont)
> combobox.pack(fill=BOTH, expand=1, padx=8, pady=8)
>
> combobox.selectitem(comboentries[0])
>
> root.mainloop()
>
--
__
/ ) / Bob van der Poel
/--< ____/__ bvdpoel at uniserve.com
/___/_(_) /_) http://users.uniserve.com/~bvdpoel
More information about the Python-list
mailing list