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:
10
mathentry.py
10
mathentry.py
@ -24,14 +24,20 @@ class MathEntry(wx.TextCtrl):
|
|||||||
|
|
||||||
def GetValue(self):
|
def GetValue(self):
|
||||||
val = super().GetValue()
|
val = super().GetValue()
|
||||||
|
|
||||||
|
if val == "None": #TODO?
|
||||||
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
val = self.value_type(val)
|
val = self.value_type(val)
|
||||||
except ValueError:
|
except (ValueError, TypeError) as e:
|
||||||
pass
|
print(e)
|
||||||
|
|
||||||
return val
|
return val
|
||||||
|
|
||||||
|
|
||||||
def SetValue(self, val):
|
def SetValue(self, val):
|
||||||
|
self.value_type = type(val)
|
||||||
val = str(val)
|
val = str(val)
|
||||||
super().SetValue(val)
|
super().SetValue(val)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user