problem: Tkinter.Menu() on NT

Sven Drescher Sven.Drescher at dlr.de
Mon Mar 6 07:49:39 EST 2000


Hallo!

I have a little problem with the following program. I want to have the index
of the pressed submenu entry. On UNIX this works fine. But under Win NT the
method returns 'none'. What's wrong with my code? Or is there a possibility
to get the index on an other way? I need the index or the name of the menu
entry, becaus it's built on the fly with file entries.

Thanks for hints and help!
Sven

#!/usr/local/bin/python
import Tkinter

def test_routine():
    global submenu
    print submenu.index('active')

test=Tkinter.Tk()

frame=Tkinter.Frame(test)
frame.pack()

menu_button=Tkinter.Menubutton(frame, text='menu')
menu_button.pack()

menu=Tkinter.Menu(menu_button)
submenu=Tkinter.Menu(menu, tearoff=0)

for i in range(6):
    submenu.add_command(label=i, command=test_routine)

menu.add_cascade(label='test', menu=submenu)
menu_button['menu']=menu
test.mainloop()






More information about the Python-list mailing list