Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. import tkinter as tk
  2.  
  3. class Application(tk.Frame):
  4.     def __init__(self, master=None):
  5.         super().__init__(master)
  6.         self.pack()
  7.         self.create_widgets()
  8.  
  9.     def create_widgets(self):
  10.         self.hi_there = tk.Button(self)
  11.         self.hi_there["text"] = "Hello, World!"
  12.         self.hi_there["command"] = self.say_hi
  13.         self.hi_there.pack(side="top")
  14.  
  15.         self.quit = tk.Button(self, text="QUIT", fg="red",
  16.                               command=root.destroy)
  17.         self.quit.pack(side="bottom")
  18.  
  19.     def say_hi(self):
  20.         print("Hello, world!")
  21.  
  22. root = tk.Tk()
  23. app = Application(master=root)
  24. app.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement