【发布时间】:2016-06-09 21:37:33
【问题描述】:
我正在尝试更改 Tkinter 中下拉菜单的呈现方式。我在 TutorialsPoint 上找到了这段代码:
from Tkinter import *
def donothing():
filewin = Toplevel(root)
button = Button(filewin, text="Do nothing button")
button.pack()
root = Tk()
menubar = Menu(root)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="New", command=donothing)
filemenu.add_command(label="Open", command=donothing)
filemenu.add_command(label="Save", command=donothing)
filemenu.add_command(label="Save as...", command=donothing)
filemenu.add_command(label="Close", command=donothing)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=root.quit)
menubar.add_cascade(label="File", menu=filemenu)
editmenu = Menu(menubar, tearoff=0)
editmenu.add_command(label="Undo", command=donothing)
editmenu.add_separator()
editmenu.add_command(label="Cut", command=donothing)
editmenu.add_command(label="Copy", command=donothing)
editmenu.add_command(label="Paste", command=donothing)
editmenu.add_command(label="Delete", command=donothing)
editmenu.add_command(label="Select All", command=donothing)
menubar.add_cascade(label="Edit", menu=editmenu)
helpmenu = Menu(menubar, tearoff=0)
helpmenu.add_command(label="Help Index", command=donothing)
helpmenu.add_command(label="About...", command=donothing)
menubar.add_cascade(label="Help", menu=helpmenu)
root.config(menu=menubar)
root.mainloop()
根据站点,呈现的菜单应如下所示:Dropdown Menu Image Web
但是,当我在计算机上运行该程序时,我看到的是:Dropdown Menu Image Local
我有什么方法可以强制网络版本中显示的行为,其中每个下拉菜单从菜单按钮的左角向右延伸,而不是从菜单按钮的右上角向左延伸?
【问题讨论】:
标签: python python-3.x user-interface tkinter