[Tkinter-discuss] Muti-column menu (cont)

Vasilis Vlachoudis Vasilis.Vlachoudis at cern.ch
Thu Nov 3 12:11:54 CET 2011


Is it possible to have a separator line extending both columns (something like columnspan=2).
If I add two separators, the first one appears ok while the second appears like a dot. 

from Tkinter import *

def showMenu(event=None):
	menu = Menu(tk,tearoff=0)

	menu.add_command(label="PLA")
	menu.add_command(label="XZP")
	menu.add_separator()
	menu.add_command(label="RPP")
	menu.add_command(label="WED")
	menu.add_separator()
	menu.add_command(label="SPH")
	menu.add_separator()
	menu.add_command(label="RCC")
	menu.add_command(label="XCC")
	menu.add_command(label="YCC")
	menu.add_command(label="ZCC")
	menu.add_command(label="TRC")
	menu.add_separator()
	menu.add_command(label="ARB")
	menu.add_command(label="TRX")
	menu.add_command(label="TRZ")

	menu.add_command(label="XYP")
	menu.add_command(label="YZP")
	menu.add_separator()
	menu.add_command(label="BOX")
	menu.add_command(label="RAW")
	menu.add_separator()
	menu.add_command(label="ELL")
	menu.add_separator()
	menu.add_command(label="REC")
	menu.add_command(label="XEC")
	menu.add_command(label="YEC")
	menu.add_command(label="ZEC")
	menu.add_separator()
	menu.add_separator()
	menu.add_command(label="QUA")
	menu.add_command(label="TRY")

	menu.entryconfigure(17,columnbreak=1)

	menu.tk_popup(tk.winfo_pointerx(), tk.winfo_pointery())

tk = Tk()
tk.bind("<3>",showMenu)
tk.mainloop()



Vasilis 

________________________________________
From: Vasilis Vlachoudis
Sent: 03 November 2011 11:48
To: Michael Lange; tkinter-discuss at python.org
Subject: RE: [Tkinter-discuss] Muti-column menu

Thank you very much.
Exactly what I was looking for.
Vasilis

________________________________________
From: tkinter-discuss-bounces+vasilis.vlachoudis=cern.ch at python.org [tkinter-discuss-bounces+vasilis.vlachoudis=cern.ch at python.org] on behalf of Michael Lange [klappnase at web.de]
Sent: 03 November 2011 11:36
To: tkinter-discuss at python.org
Subject: Re: [Tkinter-discuss] Muti-column menu

Hi Vasilis,

Thus spoketh Vasilis Vlachoudis <Vasilis.Vlachoudis at cern.ch>
unto us on Wed, 2 Nov 2011 20:51:43 +0000:

> Hi All,
>
> in my application I have a submenu (appearing both on the menu bar and
> with right-click) that contains many entries ~30. But it has to be in
> one submenu since they are various types of geometrical bodies to
> insert. Is there a way to create a multi-column sub-menu in Tkinter?
>

Yes, all you need to do is

    menu.entryconfigure(i, columnbreak=1)

where i is the index number of the menu item that will appear at the top
of a new column.

Best regards

Michael


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

No one can guarantee the actions of another.
                -- Spock, "Day of the Dove", stardate unknown
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss at python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


More information about the Tkinter-discuss mailing list