Right-click popup menu.  None of the options that come from the
cascades can be selected with the mouse.  If you select a submenu with
the mouse and then use the arrow keys and enter key to select an
option, it works, but the menu remains on the canvas.  If you click
the option with the mouse, the menu disappears but the function
doesn't get called.
Can someone tell me why?

-Chuckk

-- 
http://www.badmuthahubbard.com
#!/usr/bin/python2.4

import Tkinter as tk

class App:
    def __init__(self, parent):
        self.myparent = parent
        self.myparent.rowconfigure(0, weight=1)
        self.myparent.columnconfigure(0, weight=1)

        self.canvas = tk.Canvas(self.myparent)
        self.canvas.grid(row=0, column=0, sticky='nesw')
        self.canvas.bind("<Button-3>",self.popup)

        self.menupopup1 = tk.Menu(self.myparent, tearoff=0)
        self.menupopup1.add_command(label="Test1", command=self.selected)
        self.menupopup1.add_command(label="Test2", command=self.selected)
        self.menupopup1.add_command(label="Test3", command=self.selected)
        self.menupopup2 = tk.Menu(self.myparent, tearoff=0)
        self.menupopup2.add_command(label="Test1", command=self.selected)
        self.menupopup2.add_command(label="Test2", command=self.selected)
        self.menupopup2.add_command(label="Test3", command=self.selected)

        self.menupopup = tk.Menu(self.myparent, tearoff=0)
        self.menupopup.add_cascade(label="Test1", menu=self.menupopup1)
        self.menupopup.add_cascade(label="Test2", menu=self.menupopup2)

    def selected(self):
        print "Selected"

    def popup(self,event):
        self.menupopup.post(event.x_root,event.y_root)

root = tk.Tk()
app = App(root)

root.mainloop()

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to