[英]How to control location of drop down menu in Tkinter?
我正在嘗試更改 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()
根據該站點,呈現的菜單應如下所示:下拉菜單圖像 Web
但是,當我在計算機上運行該程序時,我看到的是: Dropdown Menu Image Local
有什么辦法可以讓我強制執行網絡版本中顯示的行為,其中每個下拉菜單都從菜單按鈕的左角向右延伸,而不是從菜單按鈕的右角向左延伸?
我在桌面 Windows 8.1 系統上遇到了這個問題。
我修好了
有關更多信息,請參閱此鏈接: https : //www.askvg.com/how-to-change-menu-position-from-left-to-right-in-windows-vista/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.