From 9ab77080a39111393ca3b4e343f786701cc14c30 Mon Sep 17 00:00:00 2001 From: gac-maloja Date: Wed, 29 Sep 2021 18:56:36 +0200 Subject: [PATCH] handle None (albeit in an ugly way); also handle TypeError when converting values back to original type; update value type also in SetValue --- mathentry.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mathentry.py b/mathentry.py index 8119ac3..f23c7d5 100644 --- a/mathentry.py +++ b/mathentry.py @@ -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)