Tkinter: OptionMenu question

Randall Hopper aa8vb at yahoo.com
Thu Mar 9 09:02:29 EST 2000


Peter Funk:
 |> Hi.  Thanks for the reply.  Actually I was using Tkinter.  Tkinter does
 |> have an OptionMenu class written in Python code that is instantiable (see
 |> Tkinter.py::OptionMenu).
 |
 |Yes.  Indeed.  I should have better checked before posting.  :-(
 |
 |However this "poor mans" OptionMenu class only provides a very raw
 |wrapper around the MenuButton class.  As far as I can see from the source
 |in Tkinter.py the only way to set the font is to access the menu
 |component afterwards and use
 |	menu['menu'].configure(font=....) 
 |to change the font.

Thanks.  I was hoping not to have to plug at internals.  I'll file an
enhancement request to add this.

Creating a frame around the option menu, assigning it a unique Tk class
name, and then stuffing a *Class*Font specs in the Tk option database also
works.  But, since the only text displayed in an option menu are the
options, IMO the user shouldn't have to go through all this just to just
set the font.

 |You should consider getting your hands on the Pmw.

I've used Pmw before.  It's a little more difficult to use than Tkinter
widgets, but very handy for those widgets Tkinter doesn't include!

I thought I'd initially avoid Pmw megawidgets in this particular case
though because I'm dynamically creating panels from pre-built definition
files, each of which may contain hundreds of widget instances (shooting for
max speed and minimum overhead).  I'll review this again later.

Thanks,

Randall

-- 
Randall Hopper
aa8vb at yahoo.com




More information about the Python-list mailing list