Tkinter Menu tearoff Parameter
Menu() method of the parameter options tearof f parameter, its default value is 1, as for other details can refer to the description of the section, because this is the default value, so if you open the menu can see the "tearof f = 1" parameter generated by the dashed separator line.
If you click on the dotted line, you can make this drop-down menu detach, and the result is shown in the figure above.
Example#1
After setting "tearof f=False" when creating the menu and observing the execution results, you can see that the dotted line has been cancelled, which also makes it impossible to detach this drop-down menu from the apidemos.com window.
from tkinter import *
from tkinter import messagebox
def newFile():
messagebox.showinfo("New File-apidemos","New File-apidemos")
root = Tk()
root.title("apidemos.com")
root.geometry("300x180")
menubar = Menu(root) # Create top-level menu
# Create a menu category object, and name this menu category as File
filemenu = Menu(menubar,tearoff=False)
menubar.add_cascade(label="File File-apidemos",menu=filemenu)
# Create a menu list within the File menu
filemenu.add_command(label="New File New File-apidemos",command=newFile)
filemenu.add_command(label="Exit Exit-apidemos!",command=root.destroy)
root.config(menu=menubar) # Show menu objects
root.mainloop()
Output: