Created
September 22, 2019 22:05
-
-
Save topherPedersen/e11a409ddabd2a89a805522241b8cd71 to your computer and use it in GitHub Desktop.
Hello World with tkinter in Python 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tkinter import * | |
class Application(Frame): | |
def say_hi(self): | |
print("hi there, everyone!") | |
def createWidgets(self): | |
self.QUIT = Button(self) | |
self.QUIT["text"] = "QUIT" | |
self.QUIT["fg"] = "red" | |
self.QUIT["command"] = self.quit | |
self.QUIT.pack({"side": "left"}) | |
self.hi_there = Button(self) | |
self.hi_there["text"] = "Hello", | |
self.hi_there["command"] = self.say_hi | |
self.hi_there.pack({"side": "left"}) | |
def __init__(self, master=None): | |
Frame.__init__(self, master) | |
self.pack() | |
self.createWidgets() | |
root = Tk() | |
app = Application(master=root) | |
app.mainloop() | |
root.destroy() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment