-3
首先我的規格: 蟒蛇3.6.1 窗口10 好吧,我不能弄清楚爲什麼這些代碼給了我這些錯誤:爲什麼tkinter無法識別輸入值?
異常在Tkinter的回調 回溯(最近通話最後一個): 文件「C:\ Users \ Juan \ AppData \ Local \ Programs \ Python \ Python36 \ lib \ tkinter__init __。py」,行1699,在調用 return self.func(* args) File「C:\ Users \ Juan Diego \ Desktop \ cosasque no son programas(miosno)\ Test1 - copia.py「,in line 11,in run1 num = int(num_Entry.get()) AttributeError:'NoneType'object has no屬性'得到'
據我所知python不承認num_Entry
作爲一個條目,但爲什麼?
import tkinter
import fractions
#declares the function
main= tkinter.Tk(className="main")
num_Entry =tkinter.Entry(main).pack()
den_Entry = tkinter.Entry(main).pack()
def run1():
global den_Entry
global num_Entry
num= int(num_Entry.get())
den= int(den_Entry.get())
den=int(input("denominator 1\n:-:->"))
Fraction1= fractions.Fraction(num,den)
print(Fraction1)
#runs the code
button = tkinter.Button(main, text="run!",command= run1).pack()
main.mainloop()`