daily pastebin goal
25%
SHARE
TWEET

Untitled

a guest Nov 19th, 2017 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Tkinter as tk
  2.  
  3.  
  4. def main():    
  5.     global root
  6.  
  7.     root = tk.Tk()   # parent window
  8.  
  9.  
  10.     message = tk.Label(root, text = "Hello World")
  11.     message.pack()
  12.  
  13.     buttton = tk.Button(root, text="exit", command = buttonPushed)
  14.     button.pack()
  15.  
  16.     tk.mainloop()  
  17.  
  18.  
  19. def buttonPushed():
  20.     global root
  21.     root.destroy()
  22.  
  23. main()
  24.    
  25. buttton = tk.Button(root, text="exit", command = buttonPushed(root))
  26. button.pack()
  27.  
  28.  
  29. def buttonPushed(root):
  30.     root.destroy()
  31.    
  32. button = tk.Button(root, text="exit", command=root.destroy)
  33.    
  34. import Tkinter as tk
  35.  
  36. def main():    
  37.  
  38.     root = tk.Tk()
  39.  
  40.     message = tk.Label(root, text="Hello World")
  41.     message.pack()
  42.  
  43.     button = tk.Button(root, text="exit", command=root.destroy)
  44.     button.pack()
  45.  
  46.     tk.mainloop()  
  47.  
  48. main()
  49.    
  50. import Tkinter as tk
  51.  
  52. class interface(tk.Frame):
  53.     def __init__(self, root):
  54.         tk.Frame.__init__(self, root)
  55.  
  56.         self.root = root
  57.         message = tk.Label(self.root, text = "Hello World")
  58.         button = tk.Button(self.root, text="exit", command = self.buttonPushed)
  59.  
  60.         message.pack()
  61.         button.pack()
  62.  
  63.     def buttonPushed(self):
  64.         self.root.destroy()
  65.  
  66. root = tk.Tk()
  67. inter = interface(root)
  68. root.mainloop()
RAW Paste Data
Top