Re: Tkinter popup menu

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Carl

    Re: Tkinter popup menu

    "Chuckk Hubbard" <badmuthahubbar d@gmail.comwrit es:
    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
    Try creating the "main" popup menu before the sub-menus, and when
    instantiating the sub-menus, pass the main menu as the "master"
    instead of "self.myparent" :

    ....snip code -----------------------------------------
    self.canvas.bin d("<Button-3>",self.popup )

    self.menupopup = tk.Menu(self.my parent, tearoff=0)

    self.menupopup1 = tk.Menu(self.me nupopup, tearoff=0)
    self.menupopup1 .add_command(la bel="Test1", command=self.se lected)
    self.menupopup1 .add_command(la bel="Test2", command=self.se lected)
    self.menupopup1 .add_command(la bel="Test3", command=self.se lected)
    self.menupopup2 = tk.Menu(self.me nupopup, tearoff=0)
    self.menupopup2 .add_command(la bel="Test1", command=self.se lected)
    self.menupopup2 .add_command(la bel="Test2", command=self.se lected)
    self.menupopup2 .add_command(la bel="Test3", command=self.se lected)

    # self.menupopup = tk.Menu(self.my parent, tearoff=0)
    self.menupopup. add_cascade(lab el="Test1", menu=self.menup opup1)
    self.menupopup. add_cascade(lab el="Test2", menu=self.menup opup2)
    ....end code changes ----------------------------------

    Hope that helps.
    Carl.
  • Chuckk Hubbard

    #2
    Re: Tkinter popup menu

    On Thu, Aug 28, 2008 at 3:50 AM, Carl <c.groner@gmail .comwrote:
    "Chuckk Hubbard" <badmuthahubbar d@gmail.comwrit es:
    >
    >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
    >
    Try creating the "main" popup menu before the sub-menus, and when
    instantiating the sub-menus, pass the main menu as the "master"
    instead of "self.myparent" :
    Thanks Carl, that indeed did it.
    -Chuckk


    --

    Comment

    Working...