Advertisement
Guest User

Menubar Python

a guest
Aug 15th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. from tkinter import *
  2. import functools as fc
  3.  
  4. root = Tk()
  5. root.geometry("600x400")
  6. root.title("Menubar Test")
  7. root.configure(bg = "Black")
  8.  
  9. friends = ("Gandalf","Meister Dieb","Pokémon","Green")
  10.  
  11. def toggle(buttonName):
  12.     print("Du hast {} gedrückt".format(buttonName))
  13.  
  14. menubar = Menu(root)
  15.  
  16. filemenu = Menu(menubar, tearoff = False)
  17.          
  18. for friend in friends:
  19.           filemenu.add_command(label = friend ,command = fc.partial(toggle, friend))
  20.  
  21. menubar.add_cascade(label = "Freunde", menu=filemenu)
  22. root.config(menu=menubar)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement