Accessing Tk-inter Popup menu entry

Aki Niimura akineko at pacbell.net
Sun Sep 8 13:01:14 EDT 2002


Hi,

I have created a popup menu. (see the attached example code)
Now I would like to change the state of a popup menu entry dynamically.
I tried to use 
    popup.entryconfig(2, state=DISABLED)
But it didn't work although it worked fine with a regular menu bar.
My questions are:
(1) Is there any convenient way to configure popup menu entry widget?
(2) If not, how can I can retrieve widget of menu entry (child widget)
 - I used NameToWidget() in Motif programming.

Thank you for your attention.

Aki-

// a sample popup menu from http://effbot.org/zone/tkinter-popup-menu.htm
from Tkinter import *

root = Tk()

w = Label(root, text="Right-click to display menu", width=40, height=20)
w.pack()
    
# create a menu
popup = Menu(root, tearoff=0)
popup.add_command(label="Next") # , command=next) etc...
popup.add_command(label="Previous")
popup.add_separator()
popup.add_command(label="Home")

def do_popup(event):
    # display the popup menu
    popup.tk_popup(event.x_root, event.y_root, 0)

w.bind("<Button-3>", do_popup)

b = Button(root, text="Quit", command=root.destroy)
b.pack()

mainloop()

~/tmp/tkinter-popup-menu.txt
I'm trying to access



More information about the Python-list mailing list