Use
tearoff=0. From the NM Tech Tkinter
reference:
tearoff
通常,菜单可以被删除:菜单中的第一个位置(位置0)
选择列表被撕裂元素和附加
从位置1开始添加选项。如果设置“tearoff=0”,菜单
将不具有撕下功能,并且将从开始添加选项
位置0。
You can see the difference in this example:
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()



