你好,我在圆计算器的区域中添加了一个GUI,但出现此错误
C:\Users\Timothy\Desktop>python aoc.py
File "aoc.py", line 12
var = variable.get()
^
IndentationError: unindent does not match any outer indentation level
这是我的代码,我不知道这是一个漂亮的代码,但对我来说还可以
from tkinter import *
from tkinter import messagebox
pi = 3.14159265359
screen = Tk()
screen.title("Area of Circle Calculator")
screen.geometry("800x500")
C = Canvas(screen, bg="#ED553B", height=25, width=800)
C.grid()
def submit():
r = float(radius.get())
an = int(pi * r*r)
var = variable.get()
if var == "in2":
line = Label(screen, text = "_________________________________________")
ra = Label(screen, text = "Radius: %f" %(r) "in2")
p = Label(screen, text = "PI: 3.14159265359")
a = Label(screen, text = "Area of circle %f" % (an))
eline = Label(screen, text = "_________________________________________")
line.grid()
ra.grid()
p.grid()
a.grid()
eline.grid()
messagebox.showinfo("Information","The area of circle is %f" % (an))
units = Label(screen, text = "Units")
units.grid()
variable = StringVar(screen)
variable.set("Unit") # default value
w = OptionMenu(screen, variable, "in2", "cm2", "m2")
w.grid()
ask = Label(screen, text="What is the radius of the circle?")
ask.grid()
radius = Entry(screen)
radius.grid()
done = Button(screen, text="submit", command=submit)
done.grid()
screen.mainloop()
非常感谢您的答复/答复 我尝试取消缩进,即使我知道我不会工作,但我尝试查看是否可以解决我的问题