这行是什么以及如何删除创建菜单时自动出现的行:
最佳答案
使用tearoff=0
。来自NM Tech Tkinter reference :
tearoff
Normally, a menu can be torn off: the first position (position 0) in the list of choices is occupied by the tear-off element, and the additional choices are added starting at position 1. If you set
tearoff=0
, the menu will not have a tear-off feature, and choices will be added starting at position 0.
您可以在此示例中看到差异:
from tkinter import *
root = Tk()
menubar = Menu(root)
tearoff = Menu(menubar, tearoff=1)
tearoff.add_command(label="Tearoff")
menubar.add_cascade(label="Tearoff", menu=tearoff)
notearoff = Menu(menubar, tearoff=0)
notearoff.add_command(label="No Tearoff")
menubar.add_cascade(label="No Tearoff", menu=notearoff)
root.config(menu=menubar)
root.mainloop()
关于python - 创建菜单时如何删除 tkinter - - - - 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55088055/