-
Notifications
You must be signed in to change notification settings - Fork 6
/
lab_callback_args.py
33 lines (26 loc) · 1.03 KB
/
lab_callback_args.py
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
import sys
from tkinter import *
class Gui:
def __init__(self, root):
self.root = root
self.label = Label(self.root,text=0)
self.label.pack(fill=BOTH,expand=True)
self.frame = Frame(self.root,borderwidth=10,relief=GROOVE)
self.frame.pack(fill=BOTH,expand=True)
self.button1 = Button(self.frame, text='1', command=self.button_press(1))
self.button2 = Button(self.frame, text='2', command=self.button_press(2))
self.button3 = Button(self.frame, text='3', command=self.button_press(3))
self.button1.pack(side=LEFT,fill=BOTH,expand=True)
self.button2.pack(side=LEFT,fill=BOTH,expand=True)
self.button3.pack(side=LEFT,fill=BOTH,expand=True)
def button_press(self, val):
print('Pressed %d' % val)
self.label.config(text=val)
def main():
root = Tk()
# set the starting size of the window
#root.geometry('%dx%d' % (320,240))
gui = Gui(root)
root.mainloop()
if __name__ == '__main__':
sys.exit(main())