我在Pycharm (macOS)上写了这段代码,但是菜单栏没有显示出来。有人能告诉我为什么吗?
from tkinter import *
root = Tk()
def hello():
print("hello!")
# create a toplevel menu
menubar = Menu(root)
menubar.add_command(label="Hello!", command=hello)
menubar.add_command(label="Quit!", command=root.destroy)
# display the menu
root.config(menu=menubar)
root.mainloop()发布于 2020-12-07 23:15:48
在OSX中,你不能把命令放在菜单栏的最上面。此外,菜单不会出现在窗口的顶部,它出现在屏幕的顶部,就像原生OSX应用程序一样。
除了你的菜单栏没有下拉菜单这一事实之外,它是按照设计的那样工作的。添加一个下拉菜单,该菜单将出现在菜单栏上。
https://stackoverflow.com/questions/65183903
复制相似问题