diff options
author | Johnathan Corgan | 2009-09-09 17:37:01 -0700 |
---|---|---|
committer | Johnathan Corgan | 2009-09-09 17:37:01 -0700 |
commit | 3c8af34f675eadd64b5fc3f0065793f3b3ff47f0 (patch) | |
tree | ff620f07d17a3774198d654b159df1813ca97ffd | |
parent | 101e510842241be068e7e56a666f8cd9b34de248 (diff) | |
parent | 3b5fc17434361cb7698e9dd9b0f16e4fbdea7f78 (diff) | |
download | gnuradio-3c8af34f675eadd64b5fc3f0065793f3b3ff47f0.tar.gz gnuradio-3c8af34f675eadd64b5fc3f0065793f3b3ff47f0.tar.bz2 gnuradio-3c8af34f675eadd64b5fc3f0065793f3b3ff47f0.zip |
Merge branch 'forms' of http://gnuradio.org/git/jblum into master
* 'forms' of http://gnuradio.org/git/jblum:
set text box bg color on change
Round the slider's value, but not the internal representation.
-rw-r--r-- | gr-wxgui/src/python/forms/converters.py | 3 | ||||
-rw-r--r-- | gr-wxgui/src/python/forms/forms.py | 11 |
2 files changed, 10 insertions, 4 deletions
diff --git a/gr-wxgui/src/python/forms/converters.py b/gr-wxgui/src/python/forms/converters.py index 9f757aa84..3cc13466a 100644 --- a/gr-wxgui/src/python/forms/converters.py +++ b/gr-wxgui/src/python/forms/converters.py @@ -134,8 +134,7 @@ class slider_converter(abstract_converter): self._scaler = float(maximum - minimum)/num_steps self._cast = cast def external_to_internal(self, v): - #slider's internal representation is an integer - return int(round((v - self._offset)/self._scaler)) + return (v - self._offset)/self._scaler def internal_to_external(self, v): return self._cast(v*self._scaler + self._offset) def help(self): diff --git a/gr-wxgui/src/python/forms/forms.py b/gr-wxgui/src/python/forms/forms.py index c69315b03..8dc58367d 100644 --- a/gr-wxgui/src/python/forms/forms.py +++ b/gr-wxgui/src/python/forms/forms.py @@ -176,7 +176,7 @@ class _slider_base(_form_base): self._add_widget(self._slider, label, flag=wx.EXPAND) def _handle(self, event): self[INT_KEY] = self._slider.GetValue() - def _update(self, value): self._slider.SetValue(value) + def _update(self, value): self._slider.SetValue(int(round(value))) ######################################################################## # Static Text Form @@ -224,11 +224,18 @@ class text_box(_form_base): def __init__(self, label='', width=-1, converter=converters.eval_converter(), **kwargs): _form_base.__init__(self, converter=converter, **kwargs) self._text_box = wx.TextCtrl(self._parent, size=wx.Size(width, -1), style=wx.TE_PROCESS_ENTER) + self._default_bg_colour = self._text_box.GetBackgroundColour() self._text_box.Bind(wx.EVT_TEXT_ENTER, self._handle) + self._text_box.Bind(wx.EVT_TEXT, self._update_color) self._add_widget(self._text_box, label) + def _update_color(self, *args): + if self._text_box.GetValue() == self[INT_KEY]: + self._text_box.SetBackgroundColour(self._default_bg_colour) + else: self._text_box.SetBackgroundColour('#EEDDDD') + def _handle(self, event): self[INT_KEY] = self._text_box.GetValue() - def _update(self, value): self._text_box.SetValue(value) + def _update(self, value): self._text_box.SetValue(value); self._update_color() ######################################################################## # Slider Form |