라즈베리파이에서 GUI 프로그래밍을 실습한다.
[tk_textbox.py]
# tk_textbox.py
import tkinter as tk
from tkinter import ttk
# Create instance
win = tk.Tk()
# Add a Title
win.title('RaspberryPI GUI ')
# Add a Label
ttk.Label(win, text='Input: ').grid(column=0, row=0)
# Add a Button & Text Box
def push_bt():
print(it.get())
it = tk.StringVar()
tx = ttk.Entry(win, width=12, textvariable=it)
tx.grid(column=1, row=0)
bt = ttk.Button(win, text='Push', command=push_bt)
bt.grid(column=2, row=0)
# Start GUI
win.mainloop()
$ python3 tk_textbox.py
[참조]
'찐s > Raspberry Pi' 카테고리의 다른 글
[RPi] Lab.05-5: GUI (tkinter) (0) | 2021.10.03 |
---|---|
[RPi] Lab.05-4: GUI (tkinter) (0) | 2021.09.25 |
[RPi] Lab.05-2: GUI (tkinter) (0) | 2021.07.17 |
[RPi] Lab.05-1: GUI (matplotlib) (0) | 2021.07.03 |