Advertisement
healyrj2001

Using Classes

Oct 23rd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. from tkinter import *
  2.  
  3.  
  4. class QuitButton:
  5.  
  6. def __init__(self, master):
  7. frame = Frame(master)
  8. frame.pack()
  9.  
  10. self.printButton = Button(frame, text="Print Message", command=self.printMessage)
  11. self.printButton.pack(side=LEFT)
  12.  
  13. self.quitButton = Button(frame, text="Quit", command=frame.master.destroy)
  14. self.quitButton.pack(side=LEFT)
  15.  
  16. def printMessage(self):
  17. print("Wow, this actually worked")
  18.  
  19.  
  20. root = Tk()
  21. b = QuitButton(root)
  22. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement