Article Outline
Python tkinter (gui) example 'hw classes'
hw classes
Python tkinter example: hw classes
from Tkinter import *
class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self,master)
self.pack()
self.create_widgets()
def create_widgets(self):
self.hi_there = Button(self)
self.hi_there["text"] = "Hello World\n(click me)"
self.hi_there["command"] = self.say_hi
self.hi_there.pack(side="top")
self.quit = Button(self, text="QUIT", fg="red",
command=root.destroy)
self.quit.pack(side="bottom")
def say_hi(self):
print("hi there, everyone!")
root = Tk()
app = Application(master=root)
app.mainloop()
Useful links
- Learn Tkinter: https://pythonbasics.org/tkinter/
- Wikipedia tkinter: https://en.wikipedia.org/wiki/Tkinter