
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Remove Dashed Line from 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.
Example
#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()
Output
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.
Advertisements