라즈베리파이에서 GUI 프로그래밍을 실습한다.
[tk_combobox.py]
# tk_combobox.py
def sl_value(x):
if sel.get() == 1:
print(int(x)*int(num.get()))
else:
print(int(x))
sel = tk.IntVar()
num = tk.StringVar()
val = tk.IntVar()
en = ttk.Checkbutton(win, text='Sel', variable=sel)
en.grid(column=0, row=1)
co = ttk.Combobox(win, width=12, textvariable=num)
co.grid(column=1, row=1)
co['values'] = (1, 2, 4, 8)
co.current(0)
vl = tk.Scale(win, orient='h', to=127, showvalue=True, variable=val, command=sl_value)
vl.grid(column=2, row=1)
$ python3 tk_combobox.py
[참조]
'찐s > Raspberry Pi' 카테고리의 다른 글
[RPi] Lab.05-6: GUI (tkinter) (0) | 2021.10.09 |
---|---|
[RPi] Lab.05-5: GUI (tkinter) (0) | 2021.10.03 |
[RPi] Lab.05-3: GUI (tkinter) (0) | 2021.08.29 |
[RPi] Lab.05-2: GUI (tkinter) (0) | 2021.07.17 |