handle None (albeit in an ugly way); also handle TypeError when converting values back to original type; update value type also in SetValue

This commit is contained in:
gac-maloja
2021-09-29 18:56:36 +02:00
parent 4988469bf1
commit 9ab77080a3

View File

@ -24,14 +24,20 @@ class MathEntry(wx.TextCtrl):
def GetValue(self):
val = super().GetValue()
if val == "None": #TODO?
return None
try:
val = self.value_type(val)
except ValueError:
pass
except (ValueError, TypeError) as e:
print(e)
return val
def SetValue(self, val):
self.value_type = type(val)
val = str(val)
super().SetValue(val)