Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

What does the ‘tearoff’ attribute do in a Tkinter Menu?

  • Last Updated : 11 Dec, 2020


Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with tkinter is the fastest and easiest way to create the GUI applications. Creating a GUI using tkinter is an easy task.

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

Important Terminologies

  • Menu is used to create various types of menus such as top level, pull down etc.. in Tkinter. The Top Level Menu, which is displayed under the title bar of main window.


To create menu

menubar = Menu(root)

To add text in Menu

file = Menu(menubar) 
menubar.add_cascade(label ='Your Text', menu = file)
  • A Tearoff permits you to detach menus for the most window making floating menus. If you produce a menu you may see dotted lines at the top after you click a top menu item. To fix this tearoff needs to set to 0 at the time of menu declaration.
file = Menu(menubar,tearoff=0)
edit = Menu(menubar,tearoff=0)
help_ = Menu(menubar,tearoff=0)
  • Cascade is used to create Sub-menus below the Main-menu.
  • A submenu is a menu plugged into another menu object. By adding the menu to the fileMenu and not to the menubar, we create a submenu.


Object_Name.add_command(label ='Write Text')


  • Import module
  • Create normal Tkinter window
  • Add Menus
  • Add SubMenus



# import Module
from tkinter import *
# creating tkinter window
root = Tk()
# set geometry
# Add title
root.title('Menu Demonstration')
# Creating Menubar
menubar = Menu(root)
# Adding File Menu and SubMenus
file = Menu(menubar, tearoff=0)
menubar.add_cascade(label='File', menu=file)
file.add_command(label='New File')
# Adding Edit Menu and SubMenus
edit = Menu(menubar, tearoff=0)
menubar.add_cascade(label='Edit', menu=edit)
edit.add_command(label='Select All')
# Adding Help Menu and SubMenus
help_ = Menu(menubar, tearoff=0)
menubar.add_cascade(label='Help', menu=help_)
help_.add_command(label='Tk Help')
# display Menu
# Execute Tkinter


Without Using tearoff method



 With tearoff method

My Personal Notes arrow_drop_up
Recommended Articles
Page :