from tkinter import *
root = Tk()
def myClick():
myLabel = Label(root, text="Look! I clicked a Button!")
myLabel.pack()
myButton = Button(root, text="Click Me!", padx=50, pady=50, command=myClick,fg="red", bg="black")
myButton.pack()
root.mainloop()
- 가로 길이 padx
- 세로 길이 pady
- 버튼 눌렀을때 함수 실행할때는 ()를 붙이지 않는다 ➡️ ()을 붙이면 버튼을 누르기 전에 먼저 실행되기 때문
- fg 글 색깔
- bg 버튼 색깔이라는데 바뀌지 않는다. 왜그럴까.
출처 : https://www.youtube.com/watch?v=yuuDJ3-EdNQ&list=PLCC34OHNcOtoC6GglhF3ncJ5rLwQrLGnV&index=3
'프로그래밍 > python' 카테고리의 다른 글
[tkinter] 04. input박스 만들기 (0) | 2024.04.13 |
---|---|
[tkinter] 02. 행렬 지정하기(row, column) (0) | 2024.04.13 |
[tkinter] 01. hello 창 띄우기 (0) | 2024.04.13 |
chatGPT API (0) | 2024.04.12 |
파이썬 기초 진행기(수시 업데이트 예정) (0) | 2024.04.11 |
댓글