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 :: flask abort 
Python :: data frame 
Python :: python pandas read_csv tsv 
Python :: repeat rows in a pandas dataframe based on column value 
Python :: Max fonction code in python 
Python :: python tableau 
Python :: use mark down with flask 
Python :: python template strings 
Python :: # extract images from pdf file 
Python :: coinflip 
Python :: get lastest files from directory python 
Python :: how to concatenate two lists in python 
Python :: style django forms with crisp 
Python :: 2d array row and column 
Python :: Django rest framework update or delete 
Python :: knuth morris pratt algorithm 
Python :: ipython and virtualenvs 
Python :: Python program to print positive numbers in a list 
Python :: python online practice test 
Python :: Python NumPy append Function Syntax 
Python :: remove a first array of item in python 
Python :: python dict in dict 
Python :: change tuple python 
Python :: if start and end point is same in range function python 
Python :: python save image pytelegrambotapi 
Python :: for in list start with index python 
Python :: How To Let Your Main Window Appear after succesful login in Tkinter 
Python :: housie numbers using python 
Python :: for loop in python array 
Python :: python get object parameters 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =