473,395 Members | 2,783 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 2821
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_command(label='copy')
editmenu.add_command(label='cut')
editmenu.add_command(label='paste')

# Create a sub menu of the edit menu and use tearoff option
testmenu = Menu(editmenu, tearoff=1)
testmenu.add_command(label='option1')
testmenu.add_command(label='option2')

# add the sub menu to the editmenu
editmenu.add_cascade(label='test', menu=testmenu)

# Add the edit menu to the menu bar
m.add_cascade(label='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**********************@g10g2000cwb.googlegroups .com>,
ishtar2020 <is********@hotmail.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
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...
1
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...
0
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...
1
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...
3
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)...
5
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...
5
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',...
3
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...
8
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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...

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.