Hi all,
I'm a beginner in Tkinter development and I have a problem w/ the menus
under Mac OS.
I would like to build a GUI w/ menus but when I run the program on MAC OS
Lion everything is ok but no menus are displayed in my window. I tried to
run the same program w/ the same Python version on a Ubuntu 12.04 and this
time the menus are correctly displayed.
I also noticed that IDLE doesn't display the menus either.
I'm not stuck as I can continue to code on my Linux but at the end this
program will have to run mainly on Mac OS and at this time I can't provide
it as it is.
I had a look at the known issue on the Python website but nothing seems
related to this problem. It is also possible I do something wrong but I
can't find what. Please can you help me to troubleshoot this issue ?
My configuration is the following:
Mac Book Pro 2.4GHz Core i5 / 4GB RAM
Mac OS X 10.7.5
Python 2.7.3 (the one provided w/ Mac OS)
I believe TK is ver. 8.5 but I don't know how to verify it.
I attached to this email the test case I used to confirm the issue.
Best regards,
Francois.
#!/usr/bin/python
import Tkinter as tk
import sys
class ExampleApp(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
self._create_menubar()
self.text = tk.Text()
self.text.pack(side='bottom', fill='none', expand=False)
def _create_menubar(self):
# create a menu for the menubar and associate it
# with the window
self.menubar = tk.Menu()
self.configure(menu=self.menubar)
# self.menubar.pack()
# create a File menu and add it to the menubar
file_menu = tk.Menu(self.menubar, tearoff=False)
self.menubar.add_cascade(label="File", menu=file_menu)
file_menu.add_command(label="Quit", command=self.on_quit)
# create a Edit menu and add it to the menubar
edit_menu = tk.Menu(self.menubar, tearoff=False)
self.menubar.add_cascade(label="Edit", menu=edit_menu)
edit_menu.add_command(label="Cut", underline=2, command=self.on_cut)
edit_menu.add_command(label="Copy", underline=0, command=self.on_copy)
edit_menu.add_command(label="Paste", underline=0, command=self.on_paste)
# create a View menu and add it to the menubar
view_menu = tk.Menu(self.menubar, tearoff=False)
self.menubar.add_cascade(label="View", menu=view_menu)
view_menu.add_cascade(label="Whatever", command=self.on_whatever)
def log(self, s):
self.text.insert("end", s + "\n")
self.text.see("end")
# not good programming style, but I'm trying to keep
# the example short
def on_cut(self): self.log("cut...")
def on_copy(self): self.log("copy...")
def on_paste(self): self.log("paste...")
def on_quit(self): sys.exit(0)
def on_whatever(self): self.log("whatever...")
if __name__ == "__main__":
app = ExampleApp()
app.mainloop()
_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss