I am trying to set a text-box or EntryBox to 0 if this entry box is empty I can do it if the entrybox's textvariable is a String, but I cant if is a DoubleVar or an IntVar
here is my code
mGui = Tk()
mGui.title("GUI")
mGui.geometry('1250x650+10+10')
def mCheck():
if len(name1.get()) == 0:
name1.set('noidea')
mGui.update()
if (len(name2.get()) == 0):
name2.set('nofkidea')
mGui.update()
if (value1.get()== Empty or (len(str(value2.get()))=0) or (len(str(float(value2.get()))) == 0)):
name2.set(10)
mGui.update()
if (value2.get()== None or (len(str(value2.get()))=0) or (len(str(float(value2.get()))) == 0)):
name2.set(99999)
mGui.update()
value1 = DoubleVar()
value2 = DoubleVar()
name1 = StringVar()
name2 = StringVar()
mButtonLoad = Button(mGui, text = "check", command = mCheck, fg = 'Red').place(x=550,y=140)
tText1 = Entry(mGui, textvariable = name1).place(x=10,y=80)
tText2 = Entry(mGui, textvariable = name2).place(x=10,y=100)
vText1 = Entry(mGui, textvariable = value1).place(x=200,y=80)
vText2 = Entry(mGui, textvariable = value2).place(x=200,y=100)
mGui.after(1, mGui.update)
mGui.mainloop()
I am getting this error when I Try to set the DoubleVar textboxes to 0 if these ones are empty
ValueError: could not convert string to float:
(len(str(value2.get()))=0)
should be(len(str(value2.get()))==0)
. Also what isEmpty
? Is it some variable or what?