Reputation: 2487
What is this line and How to remove the lines that appear automatically when creating a menu:
Upvotes: 1
Views: 2037
Reputation: 10532
Use tearoff=0
. From the 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.
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()
Upvotes: 6