편집 기록

편집 기록
  • 프로필 nowp님의 편집
    날짜2021.07.21

    버튼 클릭해서 1씩 증가하게 하고 싶습니다.


    파이썬 버튼 눌러서 1씩 증가하게 하고 싶은데 1,2,3,4...이렇게가 아니라 1111이렇게 증가합니다.. 뭐가 잘못된건가요?

    from tkinter import *
    
    window = Tk()
    
    l1=Label(window, text="계수기")
    l1.grid(row=0, column=0)
    
    e1=Entry(window)
    e1.grid(row=0, column=1)
    
    button_list=["증가"]
    
    def click(key):
        global total
        total=0
        if key =="증가":
            total+=1
            e1.insert(END, total)
        else:
            total==0
            e1.insert(END, total)
    
    
    for button_1 in button_list:
        def process(x=button_1):
            click(x)
        Button(window, text=button_1, command=process).grid(row=1, column=1, columnspan=2)
    
    
  • 프로필 알 수 없는 사용자님의 편집
    날짜2021.07.21

    버튼 클릭해서 1씩 증가하게 하고 싶습니다.


    파이썬 버튼 눌러서 1씩 증가하게 하고 싶은데 1,2,3,4...이렇게가 아니라 1111이렇게 증가합니다.. 뭐가 잘못된건가요?

    from tkinter import *

    window = Tk()

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

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

    e1=Entry(window)

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

    button_list=["증가"]

    def click(key):

    global total
    total=0
    if key =="증가":
        total+=1
        e1.insert(END, total)
    else:
        total==0
        e1.insert(END, total)
    

    for button_1 in button_list:

    def process(x=button_1):
        click(x)
    Button(window, text=button_1, command=process).grid(row=1, column=1, columnspan=2)