How to create a tear off menu in TKinter. Help Needed

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

    #1

    How to create a tear off menu in TKinter. Help Needed

    Hi everybody

    I'd appreciate some help on creating a tear off menu with TkInter. I've
    been reading some documentation but still no luck.

    Please don't get confused: when I mean "tear off" menu I don't mean a
    drop-down or a pop-up menu, but those options which yield to another
    batch of sub-options when scrolled over, (as for example, the File->New
    option from internet explorer).

    I'm sure TkInter supports those widgets because the IDLE editor is
    built on it and it's got some tear off options like File->Recent Files.

    Thank you all in advance

  • John McMonagle

    #2
    Re: How to create a tear off menu in TKinter. Help Needed

    On Thu, 2006-04-06 at 12:27 -0700, ishtar2020 wrote:[color=blue]
    > Hi everybody
    >
    > I'd appreciate some help on creating a tear off menu with TkInter. I've
    > been reading some documentation but still no luck.
    >
    > Please don't get confused: when I mean "tear off" menu I don't mean a
    > drop-down or a pop-up menu, but those options which yield to another
    > batch of sub-options when scrolled over, (as for example, the File->New
    > option from internet explorer).
    >
    > I'm sure TkInter supports those widgets because the IDLE editor is
    > built on it and it's got some tear off options like File->Recent Files.
    >
    > Thank you all in advance
    >[/color]

    Are you sure you don't mean a cascading menu ? A tearoff menu gives the user the ability to tear off the menu into a new top level window.

    The following example illustrates the difference:

    from Tkinter import *
    r = Tk()
    m = Menu(r)

    # Create a cascading Edit menu
    editmenu = Menu(m, tearoff=0)
    editmenu.add_co mmand(label='co py')
    editmenu.add_co mmand(label='cu t')
    editmenu.add_co mmand(label='pa ste')

    # Create a sub menu of the edit menu and use tearoff option
    testmenu = Menu(editmenu, tearoff=1)
    testmenu.add_co mmand(label='op tion1')
    testmenu.add_co mmand(label='op tion2')

    # add the sub menu to the editmenu
    editmenu.add_ca scade(label='te st', menu=testmenu)

    # Add the edit menu to the menu bar
    m.add_cascade(l abel='Edit', menu=editmenu)


    # Display the menu
    r.config(menu=m )

    r.mainloop()


    John McMonagle



    --
    This message has been scanned for viruses and
    dangerous content by MailScanner, and is
    believed to be clean.

    Comment

    • Jim Segrave

      #3
      Re: How to create a tear off menu in TKinter. Help Needed

      In article <1144351644.629 167.115470@g10g 2000cwb.googleg roups.com>,
      ishtar2020 <ishtar2020@hot mail.com> wrote:[color=blue]
      >Hi everybody
      >
      >I'd appreciate some help on creating a tear off menu with TkInter. I've
      >been reading some documentation but still no luck.
      >
      >Please don't get confused: when I mean "tear off" menu I don't mean a
      >drop-down or a pop-up menu, but those options which yield to another
      >batch of sub-options when scrolled over, (as for example, the File->New
      >option from internet explorer).
      >
      >I'm sure TkInter supports those widgets because the IDLE editor is
      >built on it and it's got some tear off options like File->Recent Files.[/color]

      I created an extension for Tkinter which allows for popup menus (onesl
      which appear when a parent menu item is under the cursor and close if
      you then move away). It was an early experiment for me with Tkinter,
      so I'm sure it can be heavily improved. It's available on



      (see the notes, the demonstration program doesn't work correctly on
      Windows, because I forgot the directory separator is a '\'. But the
      code itself works to create cascading auto-pop-up menus, or any other
      widget you want to pop-up as part of a menu.



      --
      Jim Segrave (jes@jes-2.demon.nl)

      Comment

      Working...