Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

tkinter menus

# importing only those functions
# which are needed
from tkinter import *
from tkinter.ttk import *
from time import strftime

# creating tkinter window
root = Tk()
root.title('App')

# Creating Menubar
menubar = Menu(root)

# Adding File Menu and commands
file = Menu(menubar, tearoff = 0)
menubar.add_cascade(label ='File', menu = print("File clicked"))
file.add_command(label ='New File', command = print("New clicked"))
file.add_command(label ='Open...', command = print("Open clicked"))
file.add_command(label ='Save', command = print("Save clicked"))
file.add_separator()
file.add_command(label ='Exit', command = root.destroy)

# Adding Help Menu
help_ = Menu(menubar, tearoff = 0)
menubar.add_cascade(label ='Help', menu = help_)
help_.add_command(label ='Tk Help', command = None)
help_.add_command(label ='Demo', command = None)
help_.add_separator()
help_.add_command(label ='About Tk', command = None)

# display Menu
root.config(menu = menubar)
mainloop()
Comment

Python Tkinter Menu Widget

from tkinter import *
m = Tk()
menu = Menu(m)
m.config(menu=menu)
filemenu = Menu(menu)
menu.add_cascade(label='File', menu=filemenu)
filemenu.add_command(label='New Text File')
filemenu.add_command(label='New File...')
filemenu.add_command(label='New Window')
filemenu.add_separator()
filemenu.add_command(label='Open File...')
filemenu.add_command(label='Open Folder...')
filemenu.add_command(label='Open Recent')
filemenu.add_separator()
filemenu.add_command(label='Save')
filemenu.add_command(label='Save As...')
filemenu.add_command(label='Save All')
filemenu.add_separator()
filemenu.add_command(label='Exit', command=m.quit)
helpmenu = Menu(menu)
menu.add_cascade(label='Help', menu=helpmenu)
helpmenu.add_command(label='About')
mainloop()
Comment

Python Tkinter Menu Widget Syntax

w = Menu(master, option=value)
Comment

PREVIOUS NEXT
Code Example
Python :: checking if a string is in alphabetical order in python 
Python :: # Take user input in python 
Python :: python simple input popup 
Python :: python selenium get text of div 
Python :: pyqt5 image 
Python :: discord.py run 
Python :: convert pandas dataframe/ table to python dictionary 
Python :: numpy array_equal 
Python :: flask return error response 
Python :: read page source from text file python 
Python :: df reset index 
Python :: only size-1 arrays can be converted to Python scalars 
Python :: pytesseract.image_to_string save text file 
Python :: python bool to string 
Python :: generate new secret key django 
Python :: replace all nan values in dataframe 
Python :: random picker in python 
Python :: selenium webdriver manager python 
Python :: find common values in different dataframes pandas 
Python :: how to reset index after dropping rows pandas 
Python :: how to save a pickle file 
Python :: convert numpy array to tensor 
Python :: django group by 
Python :: difference between generator and iterator in python 
Python :: find where df series is null and print 
Python :: datetime to int in pandas 
Python ::  in python 
Python :: how to delete a file in python 
Python :: pyspark show all values 
Python :: python pyqt5 sleep 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =