Lazy cascading menu in Tkinter with postcommand

Discussion in 'Python' started by Humpty Dumpty, Jan 16, 2004.

  1. Hi folks, here's a challenge: I have a dynamically created cascading menu in
    Tkinter that can be quite large because it is created from a file. I tried
    using lazy creation so only the menu item that is actually selected by the
    user gets children menu items created under it, but that fails.

    I did this by use of postcommand callback, in which I dynamically add the
    children menu items to the parent. However, a print statement in the
    postcommand callback shows that:
    1) *ALL* cascading menu items in a hierarchy get the postcommand event,
    every time the user selects the top menu item
    2) all children that have just been added to a cascading menu item in the
    postcommand callback will hear that postcommand event

    So in the end, the first time the user clicks on the top menu item, the
    whole menu hierarchy gets created (though only the top level is displayed of
    course).

    Anyone know how to get around this? I'm considering bypassing the built-in
    cascading menu and creating my own via popup menus and filtering for "on
    entry" of the buttons, but there should be a simpler method.

    Thanks in advance for any help,
    Oliver
    Humpty Dumpty, Jan 16, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ken Pu
    Replies:
    3
    Views:
    661
    Steven D'Aprano
    Jan 16, 2009
  2. Boris Borcic
    Replies:
    0
    Views:
    538
    Boris Borcic
    Jan 16, 2009
  3. Boris Borcic
    Replies:
    0
    Views:
    536
    Boris Borcic
    Jan 16, 2009
  4. gregory stevenson

    Cascading Menu scripts

    gregory stevenson, Jan 24, 2004, in forum: Javascript
    Replies:
    2
    Views:
    101
    gregory stevenson
    Jan 24, 2004
  5. Cascading Menu Recommendation

    , May 9, 2005, in forum: Javascript
    Replies:
    1
    Views:
    79
    Richard Cornford
    May 10, 2005
Loading...

Share This Page