본문 바로가기

개발자 모드/파이썬(python)

파이썬 버튼 예제

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())


action = ttk.Button(win, text = "Click me!", command = click_me)
action.grid(column =1, row =1)

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)

win.mainloop()

 

 

728x90