my_menu=Menu(root) # for creating the menu bar
m1=Menu(my_menu,tearoff=0) # tear0ff=0 will remove the tearoff option ,its default
value is 1 means True which adds a tearoff line
m1.add_command(label="Save",command=saveCommand)
m1.add_command(label="Save As",command=saveAsCommand)
m1.add_command(label="Print",command=printCommand)
m1.add_separator() # this adds a separator line --this is used keep similar options
together
m1.add_command(label="Refresh",command=refreshCommand)
m1.add_command(label="Open",command=openCommand)
my_menu.add_cascade(label="File",menu=m1)
m2 = Menu(my_menu)
m2.add_command(label="Copy all",command=copyAllCommand)
m2.add_command(label="Clear all",command=clearAllCommand)
m2.add_command(label="Undo",command=undoCommand)
m2.add_command(label="Redo",command=redoCommand)
m2.add_command(label="Delete",command=deleteCommand)
my_menu.add_cascade(label="Edit",menu=m2)
#all the values in command attribute are functions
my_menu.add_command(label="Exit", command=quit)
root.config(menu=my_menu)