개발자 모드/파이썬(python)
파이썬 tkinter GUI button 추가
인생은직구
2022. 6. 30. 23:35
728x90
#=======================================
# imports
#=======================================
import tkinter as tk
from tkinter import ttk
# Create instance
win = tk.Tk()
# Add a title
win.title("Python GUI")
# Adding a Label
a_label = ttk.Label(win, text="A label")
a_label.grid(column =0, row =0)
# Button Click Event Function
def click_me() :
action.configure(text = "** I have been Clicked ! **")
a_label.configure(foreground ="red")
a_label.configure(text = " A red Label")
action = ttk.Button(win, text = "Click Me !!!", command = click_me)
action.grid(column = 1, row = 0)
#=======================================
# Start GUI
#=======================================
win.mainloop()
클릭시
728x90