개발자 모드/파이썬(python)
파이썬 위젯에 포커스 설정하는 법
인생은직구
2022. 8. 1. 22:17
728x90
import tkinter as tk
from tkinter import ttk
win = tk.Tk()
win.title("python gui")
def click_me():
action.configure(text ="hello "+ name.get())
ttk.Label(win, text ="Enter a name :").grid(column =0, row =0)
name = tk.StringVar()
name_entered = ttk.Entry(win, width =12, textvariable= name)
name_entered.grid(column =0, row =1)
action = ttk.Button(win, text = "Click me!", command = click_me)
action.grid(column =1, row =1)
name_entered.focus()
win.mainloop()
728x90