Long Tkinter Menu

Dustan DustanGroups at gmail.com
Wed Oct 4 20:33:54 EDT 2006


I don't know if this is because of Tkinter (ie Tk) itself or the
Windows default way of handling things, but when I create a very long
menu (my test is shown below), the way it displays is rather sucky; the
menu stretches from the top of the moniter's window to the bottom (no
matter the size of the actual application).

Is there any alternative format for how a long menu gets displayed? It
would be nice if say, I could make the menu only go to the borders of
the application itself (in this case, not that long).

As for why I'm creating such a long menu, think browser bookmarks
(That's not actually what I'm doing, but similar).

================================
# menu-example-5.py

from Tkinter import *

root = Tk()

menubar = Menu(root)

menu = Menu(menubar, tearoff=0)
for i in xrange(100):
    menu.add_command(label=str(i), command=root.quit)
menu.add_command(label="Exit", command=root.quit)

menubar.add_cascade(label="Test", menu=menu)

root.config(menu=menubar)

mainloop()
================================




More information about the Python-list mailing list