I'm writing a very simple and small Ptyhon/Tkinter application and I'm
having trouble getting the menus to appear correctly. Rather than a name
appearing on the menu bar, I see "()" instead. Clicking on these "()" does
nothing (other than changing the appearance of them to indicated they've
been pressed).
I'm using Python 2.2.3 on Win2K, using a release downloaded from one
of the Cygwin mirrors.
This is most likely a simple mistake on my part, but I can't find it. I'm new
to Python and Tkinter both.
Any help appreciated!
Jim
#! /usr/bin/env python
# $Id$
#
# File: timecard.py
import string
from Tkinter import *
class App:
def callback(self):
print "called the callback!"
def __init__(self, master):
frame=Frame(master)
master.title("Timecard, Implemented in Cygwin supplied Python!")
master.maxsize(1000, 400)
frame.pack()
self.b = Button(frame, text="Clock In", width=8, command=self.callback)
self.b.pack(side=LEFT, padx=2, pady=2)
self.b = Button(frame, text="Clock Out", width=8, command=self.callback)
self.b.pack(side=LEFT, padx=2, pady=2)
self.b = Button(frame, text="Report", width=8, command=self.callback)
self.b.pack(side=LEFT, padx=2, pady=2)
self.menubar = Menu(master)
self.filemenu=Menu(self.menubar)
self.filemenu.add_command(master, label="Exit", command=self.callback)
self.menubar.add_cascade(master, label="File", menu=self.filemenu)
master.config(menu=self.menubar)
root = Tk()
app = App(root)
root.mainloop() 2 2084
James Ash wrote: I'm writing a very simple and small Ptyhon/Tkinter application and I'm having trouble getting the menus to appear correctly. Rather than a name appearing on the menu bar, I see "()" instead. Clicking on these "()" does nothing (other than changing the appearance of them to indicated they've been pressed).
I'm using Python 2.2.3 on Win2K, using a release downloaded from one of the Cygwin mirrors.
This is most likely a simple mistake on my part, but I can't find it. I'm new to Python and Tkinter both.
Any help appreciated! Jim
#! /usr/bin/env python
# $Id$ # # File: timecard.py
import string
from Tkinter import * class App:
def callback(self): print "called the callback!"
def __init__(self, master): frame=Frame(master) master.title("Timecard, Implemented in Cygwin supplied Python!") master.maxsize(1000, 400) frame.pack()
self.b = Button(frame, text="Clock In", width=8, command=self.callback) self.b.pack(side=LEFT, padx=2, pady=2)
self.b = Button(frame, text="Clock Out", width=8, command=self.callback) self.b.pack(side=LEFT, padx=2, pady=2)
self.b = Button(frame, text="Report", width=8, command=self.callback) self.b.pack(side=LEFT, padx=2, pady=2)
self.menubar = Menu(master)
self.filemenu=Menu(self.menubar) self.filemenu.add_command(master, label="Exit", command=self.callback) self.menubar.add_cascade(master, label="File", menu=self.filemenu)
No need for master in the two previous calls: doing just
self.filemenu.add_command(label="Exit", command=self.callback)
self.menubar.add_cascade(label="File", menu=self.filemenu)
solves the problem.
Please refer to http://www.pythonware.com/library/tk...tion/index.htm
for further details. master.config(menu=self.menubar)
root = Tk()
app = App(root) root.mainloop()
HTH
--
- Eric Brunel <eric dot brunel at pragmadev dot com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
by: Stewart Midwinter |
last post by:
I would like to link the contents of three OptionMenu lists. When I select an
item from the first list (call it continents), the contents of the 2nd list
(call it countries) would update. And in...
|
by: Dan Greenblatt |
last post by:
I know this can be done for context menus with the 'post' command....
What I'm trying to do, though, is programmatically post non-contextual
menus (i.e. menus that exist on a horizontal menu bar...
|
by: Bob Greschke |
last post by:
Root.option_add("*?????*font", "Helvetica 12 bold")
Want to get rid of the "font =":
Widget.add_cascade(label = "File", menu = Fi, font = "Helvetica 12 bold")
Does anyone know what ?????...
|
by: Stewart Midwinter |
last post by:
I have a Tkinter app running on cygwin. It includes a Test menu item
that does nothing more than fetch a directory listing and display it
in a Toplevel window (I'd use a tkMessageBox showinfo...
|
by: ishtar2020 |
last post by:
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...
|
by: Andrew Trevorrow |
last post by:
Our app uses embedded Python to allow users to run arbitrary scripts.
Scripts that import Tkinter run fine on Windows, but on Mac OS X there
is a serious problem. After a script does "root = Tk()"...
|
by: Gigs_ |
last post by:
class MenuDemo(Frame):
def __init__(self, parent=None):
Frame.__init__(self, parent)
self.pack(expand=YES, fill=BOTH)
self.createWidgets()
def createWidgets(self):
self.makeMenuBar()...
|
by: bg_ie |
last post by:
Hi,
I'm in the process of writing some code and noticed a strange problem
while doing so. I'm working with PythonWin 210 built for Python 2.5. I
noticed the problem for the last py file...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
| |