แถบเมนูประกอบด้วยรายการเมนูที่เรียงซ้อนกันในแนวตั้ง เราสามารถสร้างแถบเมนูโดยเริ่มต้นวัตถุของ เมนู(ราก) . เมื่อใดก็ตามที่เราเริ่มต้นแถบเมนูในแอปพลิเคชัน จะแสดงตัวคั่นบรรทัดที่ด้านบนของแถบเมนู
ในการลบตัวคั่นหรือเส้นประออกจากเมนู เราสามารถใช้ การฉีกขาด คุณสมบัติ. สามารถสร้างได้โดยการกำหนด 'tearoff =off ' คุณสมบัติ
ตัวอย่าง
#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() ผลลัพธ์
การเรียกใช้โค้ดด้านบนจะแสดงหน้าต่างที่มีแถบเมนูที่ด้านบนของหน้าต่าง

ตอนนี้ ตั้งค่า 'tearoff =on ' และเรียกใช้โค้ดอีกครั้งเพื่อดูผลกระทบบนแถบเมนู
