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 :: Python Tkinter Scrollbar Widget Syntax 
Python :: PySimpleGUI and tkinter with camera on Android 
Python :: nim game in python 
Python :: login() takes 1 positional argument but 2 were given 
Python :: difference() Function of sets in python 
Python :: flask env variable 
Python :: box plot seaborn advance python 
Python :: how to use print function in python stack overflow 
Python :: Create Admin Interface For Objects 
Python :: os scan dir python 2 
Python :: It appears you are missing some prerequisite to build the package from source 
Python :: check true false in python 
Python :: comparison operators in python 
Python :: python rest api interview questions 
Python :: python keyerror 0 
Python :: enumerate count 
Python :: how to find most occurring items in sequence python 
Python :: how to detect if a key was press down 
Python :: Check if a Key is Already Present in a Dictionary 
Python :: pyqt5 different resolutions 
Python :: clustermap subplots 
Python :: list(my_enumerate(your_sequence)) == list(enumerate(your_sequence)) 
Python :: How did you determine the chromosome numbers and how does that relate to heredity? 
Python :: how to change a kivy button text in kivy lang from python file 
Python :: truc python 
Python :: setup python in windows tikinter 
Python :: even number list generator 
Python :: python write string in multiple lines 
Python :: defining a class in python 
Python :: no repetir elementos en una lista python 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =