473,555 Members | 2,307 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Apr 6 '06 #1
2 2828
On Thu, 2006-04-06 at 12:27 -0700, ishtar2020 wrote:
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


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.

Apr 6 '06 #2
In article <11************ **********@g10g 2000cwb.googleg roups.com>,
ishtar2020 <is********@hot mail.com> wrote:
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.


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

http://aspn.activestate.com/ASPN/Coo.../Recipe/442500

(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 (je*@jes-2.demon.nl)

Apr 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5960
by: Josh | last post by:
Caution, newbie approaching... I'm trying to come up with a very simple Tkinter test application that consists of a window with a drop-down menu bar at the top and a grid of colored rectangles filling the remainder of the window. Mind you, this is a contrived test application to help me understand Tkinter and Python, not an actual...
1
11599
by: Patrick L. Nolan | last post by:
We have a Tkinter application which has a menubar with cascade submenus. I would like to start the program with one of the submenu items state=DISABLED, then change it to state=NORMAL at a later time. I hope I just missed something obvious, because I can't figure out how to change its state. The problem comes about because the menu bar is...
0
1778
by: Humpty Dumpty | last post by:
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...
1
5355
by: eltronic | last post by:
here is some code to add right click context menus. in the few apps I've edited sofar, it just works, once you run rCbinder with the root of the gui or bind B3 all present and future widgets will have right click. there will be a line something like root=Tk.mainloop() #or Tkinter.mainloop() in epydoc it was necessary to look into the gui...
3
5062
by: John Pote | last post by:
I have a menu bar in a top level window as follows menuBar = Menu(rootWin) menuBar.add_command( label='Quit', command=rootWin.quit) configMenu = Menu(menuBar, tearoff=0) configMenu.add_command(label='Left Device Raw', command=setLeftRaw) configMenu.add_command(label='Right Device Raw', command=setRightRaw) etc
5
5046
by: Phil Schmidt | last post by:
I am making a little Tkinter GUI app that needs to be in several languages (english, french, etc.), adjustable at runtime via a menu pick to select the language. The only way I can see to change text in the menus entries is to destroy them and recreate them usiing different labels. This seems very clunky though, and there must be a better way....
5
2546
by: Kevin Walzer | last post by:
I'm having difficulty structuring a Tkinter menu entry. Here is the command in question: self.finkmenu.add_command(label='Update List of Packages', command=self.authorizeCommand(self.scanPackages)) When I start my program, it crashes because it's trying to run the command self.authorizeCommand. The reason I'm structuring it in this...
3
3325
by: MartinRinehart | last post by:
Tkinter definitely deserves more respect! I'm making rapid progress and it looks good. But am stuck on this: I want the File/Save state to change from disabled to enabled, depending on whether or not there is something to save (Text modified). Google returns results in every language except Python. Sub problems: how to change state of...
8
3270
by: karthikbalaguru | last post by:
Hi, One of my python program needs tkinter to be installed to run successfully. I am using Redhat 9.0 and hence tried installing by copying the tkinter-2.2.2-36.i386.rpm alone from the CD 3 to my pc. But, it is not getting installed and is failing by throwing the below errors. Should i need to configure / install any specific files for...
0
7622
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7547
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7825
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8060
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7588
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5171
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3596
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
865
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.