tkinter font selector?
Richard Chamberlain
richard_chamberlainNOriSPAM at ntlworld.com.invalid
Mon Jun 26 06:24:27 EDT 2000
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()
Richard
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com
More information about the Python-list
mailing list