- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to remove the dashed line from the Tkinter menu UI?
A Menu Bar contains vertically stacked menu items. We can create a Menu bar by initializing the object of Menu(root). Whenever we initialize a Menu bar in an application, it displays a line separator at the top of the Menu Bar.
To remove the separator or the dashed line from the Menu, we can use the tearoff property. It can be created by defining the 'tearoff = off' property.
#Import the required Libraries from tkinter import * from tkinter import ttk #Create an instance of Tkinter frame win = Tk() #Set the geometry of Tkinter frame win.geometry("750x250") win.title("Editor") # Adding Menubar menu_bar = Menu(win) #Create a New Menu in the MenuBar file_menu = Menu(menu_bar, tearoff="off") #All file menu-items will be added here next menu_bar.add_cascade(label='File', menu=file_menu) #Add Menu Items in the file Menu file_menu.add_command(label="New", compound='left', underline=0) file_menu.add_command(label="Open", compound='left', underline=0) file_menu.add_command(label="Save", compound='left', underline=0) file_menu.add_command(label="Exit", compound='left', underline=0) win.config(menu=menu_bar) win.mainloop()
Running the above code will display a window with a Menubar at the top of the window.
Now, set 'tearoff = on' and run the code again to observe its effect on the Menubar.
- Related Articles
- How to remove dashed line from my tkinter menu UI?
- How to remove Ttk Notebook Tab Dashed Line? (tkinter)
- How to draw a dashed line on a Tkinter canvas?
- How to remove the icon from the title bar in Tkinter?
- How to change the TKinter canvas line from dash to solid?
- How to make dotted/dashed line in iOS?
- How to remove focus from a Tkinter widget?
- How to create a Popup Menu in Tkinter?
- C program to remove a line from the file
- How can I create a dropdown menu from a List in Tkinter?
- How to change the menu background color of Tkinter's OptionMenu widget?
- How to get alternating colours in a dashed line using Matplotlib?
- How to add a separator in Menu item in Tkinter?
- How to remove the outline of an oval in Tkinter?
- How to remove line numbers from data.table object in R?