Message66492
#Python 3.0a5 (py3k:62932M, May 9 2008, 16:23:11) [MSC v.1500 32 bit
#(Intel)] on win32
#
# If you run this tiny program on Linux and press Alt+F (Alt-f in Tk
# terminology) the File menu pops up as expected. But run it on
# Windows Home XP and nothing happens when you press Alt+F.
# The problem may be with the code below since IDLE works fine on
# Windows, in which case sorry!
# However, Grayson's AppB/menu.py example (with suitably fixed print
# statements since it was writtend for Py2) is exactly the same:
# works fine on Linux but Alt+key does not invoke the menus on Windows.
from Tkinter import *
class MainWindow:
def __init__(self, parent):
self.parent = parent
menuBar = Frame(self.parent, relief=RAISED, borderwidth=2)
menuBar.pack(anchor=N, fill=X)
fileMenu = Menubutton(menuBar, text="File", underline=0)
fileMenu.pack(side=LEFT)
fileMenu.menu = Menu(fileMenu, tearoff=False)
for label, command in (
("New...", self.fileNew),
("Open...", self.fileOpen),
("Quit", self.fileQuit)):
fileMenu.menu.add_command(label=label, command=command)
fileMenu["menu"] = fileMenu.menu
menuBar.tk_menuBar(fileMenu)
def fileNew(self, *args):
print("fileNew", args)
def fileOpen(self, *args):
print("fileOpen", args)
def fileQuit(self, *args):
self.parent.destroy()
root = Tk()
window = MainWindow(root)
root.protocol("WM_DELETE_WINDOW", window.parent.destroy)
root.mainloop() |
|
Date |
User |
Action |
Args |
2008-05-09 21:51:56 | mark | set | spambayes_score: 0.0066122 -> 0.006612198 recipients:
+ mark |
2008-05-09 21:51:56 | mark | set | spambayes_score: 0.0066122 -> 0.0066122 messageid: <1210369916.39.0.944355148013.issue2806@psf.upfronthosting.co.za> |
2008-05-09 21:51:55 | mark | link | issue2806 messages |
2008-05-09 21:51:53 | mark | create | |
|