Tkinter Menu tearoff

Jason McDermott mcdermoj at ohsu.edu
Tue Sep 12 17:23:17 EDT 2000


In article <75F7304BB41CD411B06600A0C98414FCB368E8 at ORSMSX54>, "Daley, Mark
W" <mark.w.daley at intel.com> wrote:


> I am having difficulty removing the tearoff from my menus.  I am using Tk
> 8.0.5.  Here is the code and message.
>
> def makefilemenu():
>  filebtn = Menubutton(mbar, text = 'File', tearoff = 0)
>  filebtn.pack(side=LEFT)
>  filebtn.menu = Menu(filebtn)
>  
>  filebtn.menu.add_command(label = 'Quit', command = die)
>  
>  filebtn['menu'] = filebtn.menu
>  return filebtn

The problem is that the tearoff option works at the level of the menu and
not the menu button (presumably since it is the menu which is 'torn off'). A
minor modification in your code should fix this, try:

def makefilemenu():
    filebtn = Menubutton(mbar, text='File')
    filebtn.pack(side=LEFT)
    filebtn.menu = Menu(filebtn, tearoff=0)

    ... (etc.)

Fredrick Lundh's, 'An Introduction to TkInter' has all the documentation you
need for making menu's and anything else Tk-wise- check it out at
http://www.pythonware.com/library/tkinter/introduction

Jason

**********************************************************************
****** Jason McDermott ---------------- http://www.jasonya.com *******
***********   *********       |||      ***********   ****************
         ===============================================



More information about the Python-list mailing list