473,656 Members | 2,997 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 2837
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
5968
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 application yet. I've trivially subclassed Tkinter.Canvas into ColorCanvas, added a bunch of ColorCanvases...
1
11637
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 built by several add_cascade() calls. Each of the cascades, in turn, has several add_command()...
0
1793
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 I dynamically add the children menu items to the parent. However, a print statement in the...
1
5359
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 class and find one of the attributes has the root.
3
5071
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
5076
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. Can anyone offer any pointers or a short example for how to do this? Thanks, Phil
5
2554
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 fashion is that this command takes another command as an argument--in this case, self.ScanPackages.
3
3328
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 menu item? how to detect changes in Text widget?
8
3280
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 resolving this issue ?
0
8380
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8296
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8497
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8598
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4150
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2721
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1598
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.