개발자 모드/파이썬(python)
파이썬 python 버튼 gui 기초 예제
인생은직구
2021. 6. 17. 06:44
728x90
from tkinter import *
root =Tk()
root.title(" GUI")
btn1 = Button(root, text="버튼1")
btn1.pack()
btn2 = Button(root, padx=5, pady= 10, text="버튼2") # pddx , pady 여백의 의미
btn2.pack()
btn3 = Button(root, padx=10, pady= 5, text="버튼3")
btn3.pack()
btn4 = Button(root, width =10, height =3, text ="버튼4") #width height 고정 크기
btn4.pack()
btn5 = Button(root, fg="red", bg="yellow", text="버튼5")
btn5.pack()
photo = PhotoImage(file = "gui_basic/img.png")
btn6 = Button(root, image = photo)
btn6.pack()
def btncmd():
print("버튼이 클릭됨")
btn7 = Button(root, text ="동작하는 버튼", command =btncmd)
btn7.pack()
root.mainloop()
728x90