증가 버튼을 누르면 엔트리 값이 1씩 증가하도록 하고 싶은데 어떻게 해야 할까요

조회수 686회
from tkinter import *

from tkinter import messagebox

window=Tk()


global total
total=0
#버튼 명령

def click(key):

    global total
    if key=='증가':
        total+=1
    else:
        total=0
    num_var.set(total)
#라벨생성


sum=Entry(window)

sum.grid(row=0,column=1)

l1=Label(window, text="계수기")

l1.grid(row=0,column=0)


b1=Button(window,text="증가", command=update_add)

b1.grid(row=1, column=2)



operator_list=['증가']


r=1

for x in operator_list:

    def process():
        click(x)
    b1=Button(window, text="증가",command=process)
    b1.grid(row=1, column=2)

window.mainloop()

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)