简体   繁体   English

我正在使用 tkinter 构建一个应用程序,但是显示“top”为无效语法的错误,我该如何解决这个问题

[英]i am building a app using tkinter but theres an error showing “top” as an invaild syntax, how do i solve this

i am learning python but i am on the early stages.....so i stupidly decided to build a app...i know its stupid but i still do try, i make the program but theres an unvalid indent at " from Tkinter import" specificly at "from"....how can i solve this..here's the code:我正在学习 python 但我处于早期阶段......所以我愚蠢地决定构建一个应用程序......我知道它很愚蠢但我仍然尝试,我制作程序但在 Tkinter 处有一个无效缩进import”,特别是在“from”..我该如何解决这个..这是代码:

    from Tkinter import *
except ImportError:
    from tkinter import *
from tkinter import messagebox
def proces():

I=Entry.get(E1)
R=Entry.get(E2)
v=Entry.get(E3)
I=int(I)
R=int(R)
v=int(v)
n = 0.5
V = v * R * I * n
Entry.insert(E4,0,V)
print(V)

top = tkinter
top.title("potential difference calculator")
L1 = Label(top, text="Potential Diffrence Calculator",).grid(row=0,column=1)
L2 = Label(top, text="current",).grid(row=1,column=0)
L3 = Label(top, text="Resistace",).grid(row=2,column=0)
L4 = Label(top, text="volume",).grid(row=3,column=0)
L4 = Label(top, text="Answer",).grid(row=4,column=0)
E1 = Entry(top, bd =5)
E1.grid(row=1,column=1)
E2 = Entry(top, bd =5)
E2.grid(row=2,column=1)
E3 = Entry(top, bd =5)
E3.grid(row=3,column=1)
E4 = Entry(top, bd =5)
E4.grid(row=4,column=1)
B=Button(top, text ="Submit",command = proces).grid(row=5,column=1,)

top.mainloop()

This will work fine这将正常工作

top = Tk()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM