-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtkinter-example.py
More file actions
40 lines (27 loc) · 827 Bytes
/
tkinter-example.py
File metadata and controls
40 lines (27 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Example tkinter program
# only for reference
from tkinter import *
"""
TK_Window = Tk()
label = Label(TK_Window, text="this is a label")
#define events
def onClick():
print("click")
button = Button(TK_Window, text="this is a button, click!", fg="green", command=onClick)
#push widgets onto the window
label.pack()
button.pack()
TK_Window.mainloop()"""
class ButtonEvent:
def __init__(self, _text):
self.window = Tk()
self.button = Button(self.window, text=_text, command= self.onClick)
self.label = Label(self.window, text="not clicked yet")
#push widgets and create window
self.button.pack()
self.label.pack()
self.window.mainloop() # start window
def onClick(self):
#change label
print("label changes")
event = ButtonEvent()