tkinter puzzler

Russell E. Owen rowen at cesmail.net
Mon May 16 18:31:17 EDT 2005


In article <7xhdh5ilz7.fsf at ruckus.brouhaha.com>,
 Paul Rubin <http://phr.cx@NOSPAM.invalid> wrote:

>Martin Franklin <mfranklin1 at gatwick.westerngeco.slb.com> writes:
>> I suspect you need to look at the columnconfigure / rowconfigure methods
>> of the container (toplevel or frame)
>
>Thanks, columnconfigure turned out to be the answer and Peter Otten's
>post showing how to use it was very informative.  For some reason
>columnconfigure is not documented in the otherwise excellent tkinter
>reference manual from New Mexico Tech.
>
>I'm having sort of a different prob now, which is I want to make a
>pulldown menu as commonly seen on web pages.  The NMT reference
>suggests using the MenuButton widget, which sort of works, though the
>entrycget and entryconfigure methods that are supposedly on the menu
>items aren't really there.  The toolkit itself says that MenuButton is
>now considered obsolete and Frederik Lundh's manual seems to say
>to use Menu somehow instead, but I haven't quite figured out how.

MenuButton is (as far as I know) the recommended way to do this
(and I've been puzzled by F. Lendh's assertion that they are
obsolete). The basics are:

  mbut = Tkinter.Menubutton.(master, text="MyMenu", inicatoron=True)
  mnu = Tkinter.Menu(mbut, tearoff=False)
  mbut["menu"] = mnu

where indicatoron=True gives you the "this is a pop-up menu" indicator 
icon. The circular reference is icky but appears to be necessary (i.e. 
having the menubutton be a parent to the menu and the menu attribute of 
the menubutton point to the menu).

I suggest you buy Grayson's "Python and Tkinter Programming"
(it has a very useful reference section in the back, though 
unfortunately it is somewhat incomplete). For more serious work you'll 
also want Welch's "Practical Programming in Tcl and Tk" (lots of good 
details about Tk).

-- Russell



More information about the Python-list mailing list