Tcl vs Tkinter

Paul Magwene paul.magwene at yale.edu
Tue Apr 11 10:38:06 EDT 2000


T Zimmerman wrote:
> 
>     I again am looking for help on the use of 'alt-*' to access the menus in
> any application written with Tkinter. I have tried the tcl examples that
> were included with the download of Python and they work as expected. So, I
> am confused as to why it does not work for Tkinter widgets.  The following
> script should work and should open the 'File' menu when 'alt-f' is pressed.
> On NT this does nothing.
> 
> ==================================================================
> import Tkinter
> 
> root = Tkinter.Tk()
> 
> button = Tkinter.Menubutton(text = 'File', underline = 0)
> button.pack()
> menu = Tkinter.Menu(button)
> button.configure(menu = menu)
> menu.add_command(label = 'Hello World', underline = 0)
> 
> root.mainloop()
> ==================================================================

Odd, your code works as expected using Python 1.5.2 on FreeBSD (3.x
stable), but doesn't work right on NT.

However, the following, which uses only Menu objects and cascades, DOES
work on both FreeBSD and NT:

#==================================================================
import Tkinter

root = Tkinter.Tk()

MnMenu = Tkinter.Menu()

menu = Tkinter.Menu(MnMenu)
menu.add_command(label = 'Hello World', underline = 0)

MnMenu.add_cascade(label='File',underline=0,menu=menu)

root.config(menu=MnMenu)

root.mainloop()
#==================================================================


Go figure.  Maybe the effbot has some insight?

--Paul



More information about the Python-list mailing list