diff options
author | jblum | 2008-10-14 05:16:46 +0000 |
---|---|---|
committer | jblum | 2008-10-14 05:16:46 +0000 |
commit | aeb0f46bd4b6ec474b3fddf0f8947f4fcde633aa (patch) | |
tree | 4599cc45dde1012091c4bfc918b2c4b1cca43a3a | |
parent | 1a08081354384504aca33a6c303f510dea4d1500 (diff) | |
download | gnuradio-aeb0f46bd4b6ec474b3fddf0f8947f4fcde633aa.tar.gz gnuradio-aeb0f46bd4b6ec474b3fddf0f8947f4fcde633aa.tar.bz2 gnuradio-aeb0f46bd4b6ec474b3fddf0f8947f4fcde633aa.zip |
text box control: string mode
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@9793 221aa14e-8319-0410-a670-987f0aec2ac5
-rw-r--r-- | grc/src/grc_gnuradio/wxgui/callback_controls.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/grc/src/grc_gnuradio/wxgui/callback_controls.py b/grc/src/grc_gnuradio/wxgui/callback_controls.py index a8e7a9320..8027a580c 100644 --- a/grc/src/grc_gnuradio/wxgui/callback_controls.py +++ b/grc/src/grc_gnuradio/wxgui/callback_controls.py @@ -263,6 +263,8 @@ class text_box_control(_control_base): for obj in (label_text, text_box): #fill the container with label and text entry box label_text_sizer.Add(obj, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL) self.Add(label_text_sizer, 0, wx.ALIGN_CENTER) + #set the value, detect string mode + self._string_mode = isinstance(value, str) self.text_box.SetValue(str(value)) def get_value(self): @@ -276,8 +278,13 @@ class text_box_control(_control_base): """ An enter key was pressed. Read the text box, call the callback. If the text cannot be evaluated, do not try callback. + Do not evaluate the text box value in string mode. """ - try: self._value = eval(self.text_box.GetValue()) - except: return + if self._string_mode: self._value = self.text_box.GetValue() + else: + try: self._value = eval(self.text_box.GetValue()) + except Exception, e: + print >> sys.stderr, 'Error in evaluate value from handle enter.\n', e + return try: self.call() except Exception, e: print >> sys.stderr, 'Error in exec callback from handle enter.\n', e |