본문 바로가기

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

파이썬 python 레이블 label 기초예제

728x90
from tkinter import *

root =Tk()
root.title(" GUI")

root.geometry("640x480")
label1 = Label(root, text ="안녕하세요")
label1.pack()


photo = PhotoImage(file = "gui_basic/img.png")
label2 = Label(root, image = photo)
label2.pack()


def change() :
    label1.config(text= " 또만나요")

    global photo2

    photo2 = PhotoImage(file="gui_basic/img2.png")
    label2.config(image=photo2)



btn = Button(root, text ="클릭", command = change)
btn.pack()


root.mainloop()
728x90