파이썬 tkinter 버튼색깔 바꾸기 질문
조회수 621회
버튼이 눌렸을때 버튼 색깔이 바뀌게하고싶은데 인터넷에는 class 활용한 예제밖에 안보여서 어떻게 하는지를 모르겠습니다.. 제가 def 안에 btn1.configure(bg="red") 이 코드를 넣어서 버튼이 눌렸을때 색깔이 바뀌게 하려고했는데 안되네요..이건 왜 그런건가요?
def math():
global sum
global a
global count
score = int(input("수학등급을 입력하세요"))
entry = tk.Entry(fg="gray19", bg="snow", width=20)
entry.place(relx= 0.3 , rely = 0.7)
a = 4
sum = int(sum) + int(score*a)
count = count+1
btn1.configure(bg="red")
print(count)
btn1 = Button(win, width=10, height=3, text="수학")
btn1.configure(bg="white")
btn1.grid(column = 1, row = 1 ) # 버튼 배치
btn1.config(command = math)
댓글 입력