External Exam Download Resources Web Applications Games Recycle Bin

Output

hi.py

#1. import modules (e.g. TkInter) and init a new window:
from tkinter import *
window = Tk()

#2. declare gui widgets and their initial properties:     
button = Button(text="click me")
label = Label()

#3. define events for the gui widgets:
def sayHi(event):
  label.configure(text="hello mate!")

#4. bind events to widgets:
button.bind("<ButtonPress>", sayHi)

#5. pack IN ORDER into the window:
button.pack()
label.pack()

#6. commence main loop:
window.mainloop()