Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import*
- def add_button():
- button1 = Button(text = "Button")
- button1.pack()
- def add_text():
- label1 = Label(text = "Text")
- label1.pack()
- root = Tk()
- root.title("Application")
- root.resizable(width=False, height=False) #Not resizable<--!-->
- root.geometry("500x300") #Set width and height<--!-->
- menu1 = Menu(root)
- root.config(menu = menu1)
- subMenu1 = Menu(menu1)
- menu1.add_cascade(label = "Add", menu = subMenu1) #Add subMenu1 as dropdown menu on main menu1.
- subMenu1.add_command(label = "Button", command = add_button) #Add item to subMenu1 and command.
- subMenu1.add_separator()
- subMenu1.add_command(label = "Text", command = add_text)
- root.mainloop() #When mainloop is breaked the program ends.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement