为什么Python中的IF输出错误?

问题描述 投票:0回答:1

我正在tkinter中编写一个小程序,但是它不起作用,因为当我按F5键执行代码时,会出现一个弹出窗口,显示:Tab/space error这是我的代码:

def codigo():
global text2
f2=Frame(f, width=300, height=500)
f2.pack()
f2.config(bg='dark grey')
text2=Label(f, text=spin.get(), font=('Arial Bold', 90), bg=('dark grey'))
text2.place(x=80, y=200)
timer.current = int(spin.get())
timer()
if text2 == 0:
    timerc = int(spin3.get())
    timer2()
text3=Label(f, text=int(spin3.get()), font=('Arial Bold', 30), bg=('dark grey'))
text3.place(x=200, y=350)
text4=Label(f, text=spin4.get(), font=('Arial Bold', 30), bg=('dark grey'))
text4.place(x=170, y=400)
text5=Label(f, text='Ejercicios:', font=('Arial Bold', 30), bg=('dark grey'))
text5.place(x=5, y=350)
text6=Label(f, text='Rondas:', font=('Arial Bold', 30), bg=('dark grey'))
text6.place(x=5, y=400)
if text2==0:
    text3(text=(int(spin3.get())-1))        

问题出在text3(text=(int(spin3.get())-1))中,但我不知道为什么。

谢谢。

python python-3.x tkinter tabs spaces
1个回答
0
投票

有正确的代码:

def codigo():
    global text2
    f2=Frame(f, width=300, height=500)
    f2.pack()
    f2.config(bg='dark grey')
    text2=Label(f, text=spin.get(), font=('Arial Bold', 90), bg=('dark grey'))
    text2.place(x=80, y=200)
    timer.current = int(spin.get())
    timer()
    if text2 == 0:
        timerc = int(spin3.get())
        timer2()
    text3=Label(f, text=int(spin3.get()), font=('Arial Bold', 30), bg=('dark grey'))
    text3.place(x=200, y=350)
    text4=Label(f, text=spin4.get(), font=('Arial Bold', 30), bg=('dark grey'))
    text4.place(x=170, y=400)
    text5=Label(f, text='Ejercicios:', font=('Arial Bold', 30), bg=('dark grey'))
    text5.place(x=5, y=350)
    text6=Label(f, text='Rondas:', font=('Arial Bold', 30), bg=('dark grey'))
    text6.place(x=5, y=400)
    if text2==0:
        text3(text=(int(spin3.get())-1))
© www.soinside.com 2019 - 2024. All rights reserved.