commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r11127 - in gnuradio/branches/developers/jblum/wxgui/g


From: jblum
Subject: [Commit-gnuradio] r11127 - in gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python: . forms
Date: Tue, 26 May 2009 02:03:55 -0600 (MDT)

Author: jblum
Date: 2009-05-26 02:03:54 -0600 (Tue, 26 May 2009)
New Revision: 11127

Modified:
   gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/const_window.py
   gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/constants.py
   gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/fft_window.py
   
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/forms/__init__.py
   gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/forms/forms.py
   gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/histo_window.py
   gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/number_window.py
   gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/scope_window.py
   
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/waterfall_window.py
Log:
Modified all gl window classes to use the forms module.
Made modification to forms as seen fit.



Modified: 
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/const_window.py
===================================================================
--- 
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/const_window.py    
    2009-05-26 01:23:46 UTC (rev 11126)
+++ 
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/const_window.py    
    2009-05-26 08:03:54 UTC (rev 11127)
@@ -30,6 +30,7 @@
 import pubsub
 from constants import *
 from gnuradio import gr #for gr.prefs
+import forms
 
 ##################################################
 # Constants
@@ -63,34 +64,53 @@
                """
                self.parent = parent
                wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER)
-               control_box = wx.BoxSizer(wx.VERTICAL)
-               self.marker_index = 2
-               #begin control box
-               control_box.Add(common.LabelText(self, 'Options'), 0, 
wx.ALIGN_CENTER)
+               control_box = forms.static_box_sizer(
+                       parent=self, label='Options',
+                       bold=True, orient=wx.VERTICAL,
+               )
                #alpha
                control_box.AddStretchSpacer()
-               alpha_slider = common.LogSliderController(
-                       self, 'Alpha',
-                       ALPHA_MIN_EXP, ALPHA_MAX_EXP, SLIDER_STEPS,
-                       parent, ALPHA_KEY,
+               forms.text_box(
+                       sizer=control_box, parent=self, label='Alpha',
+                       converter=forms.float_converter(),
+                       ps=parent, key=ALPHA_KEY,
                )
-               control_box.Add(alpha_slider, 0, wx.EXPAND)
+               forms.log_slider(
+                       sizer=control_box, parent=self,
+                       min_exp=ALPHA_MIN_EXP,
+                       max_exp=ALPHA_MAX_EXP,
+                       num_steps=SLIDER_STEPS,
+                       ps=parent, key=ALPHA_KEY,
+               )
                #gain_mu
                control_box.AddStretchSpacer()
-               gain_mu_slider = common.LogSliderController(
-                       self, 'Gain Mu',
-                       GAIN_MU_MIN_EXP, GAIN_MU_MAX_EXP, SLIDER_STEPS,
-                       parent, GAIN_MU_KEY,
+               forms.text_box(
+                       sizer=control_box, parent=self, label='Gain Mu',
+                       converter=forms.float_converter(),
+                       ps=parent, key=GAIN_MU_KEY,
                )
-               control_box.Add(gain_mu_slider, 0, wx.EXPAND)
+               forms.log_slider(
+                       sizer=control_box, parent=self,
+                       min_exp=GAIN_MU_MIN_EXP,
+                       max_exp=GAIN_MU_MAX_EXP,
+                       num_steps=SLIDER_STEPS,
+                       ps=parent, key=GAIN_MU_KEY,
+               )
                #marker
                control_box.AddStretchSpacer()
-               marker_chooser = common.DropDownController(self, MARKER_TYPES, 
parent, MARKER_KEY)
-               control_box.Add(common.LabelBox(self, 'Marker', 
marker_chooser), 0, wx.EXPAND)
+               forms.drop_down(
+                       sizer=control_box, parent=self,
+                       ps=parent, key=MARKER_KEY, label='Marker',
+                       choices=map(lambda x: x[1], MARKER_TYPES),
+                       labels=map(lambda x: x[0], MARKER_TYPES),
+               )
                #run/stop
                control_box.AddStretchSpacer()
-               self.run_button = common.ToggleButtonController(self, parent, 
RUNNING_KEY, 'Stop', 'Run')
-               control_box.Add(self.run_button, 0, wx.EXPAND)
+               forms.toggle_button(
+                       sizer=control_box, parent=self,
+                       true_label='Stop', false_label='Run',
+                       ps=parent, key=RUNNING_KEY,
+               )
                #set sizer
                self.SetSizerAndFit(control_box)
 
@@ -121,6 +141,11 @@
                self.proxy(GAIN_OMEGA_KEY, controller, gain_omega_key)
                self.proxy(OMEGA_KEY, controller, omega_key)
                self.proxy(SAMPLE_RATE_KEY, controller, sample_rate_key)
+               #initialize values
+               self[RUNNING_KEY] = True
+               self[X_DIVS_KEY] = 8
+               self[Y_DIVS_KEY] = 8
+               self[MARKER_KEY] = DEFAULT_MARKER_TYPE
                #init panel and plot
                wx.Panel.__init__(self, parent, style=wx.SIMPLE_BORDER)
                self.plotter = plotter.channel_plotter(self)
@@ -141,13 +166,6 @@
                self.subscribe(ALPHA_KEY, set_beta)
                def set_gain_omega(gain_mu): self[GAIN_OMEGA_KEY] = 
.25*gain_mu**2
                self.subscribe(GAIN_MU_KEY, set_gain_omega)
-               #initialize values
-               self[ALPHA_KEY] = self[ALPHA_KEY]
-               self[GAIN_MU_KEY] = self[GAIN_MU_KEY]
-               self[RUNNING_KEY] = True
-               self[X_DIVS_KEY] = 8
-               self[Y_DIVS_KEY] = 8
-               self[MARKER_KEY] = DEFAULT_MARKER_TYPE
                #register events
                self.subscribe(MSG_KEY, self.handle_msg)
                self.subscribe(X_DIVS_KEY, self.update_grid)

Modified: 
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/constants.py
===================================================================
--- gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/constants.py   
2009-05-26 01:23:46 UTC (rev 11126)
+++ gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/constants.py   
2009-05-26 08:03:54 UTC (rev 11127)
@@ -66,3 +66,4 @@
 MINIMUM_KEY = 'minimum'
 NUM_BINS_KEY = 'num_bins'
 FRAME_SIZE_KEY = 'frame_size'
+CHANNEL_OPTIONS_KEY = 'channel_options'

Modified: 
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/fft_window.py
===================================================================
--- gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/fft_window.py  
2009-05-26 01:23:46 UTC (rev 11126)
+++ gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/fft_window.py  
2009-05-26 08:03:54 UTC (rev 11127)
@@ -60,8 +60,8 @@
                self.parent = parent
                wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER)
                control_box = wx.BoxSizer(wx.VERTICAL)
+               control_box.AddStretchSpacer()
                #checkboxes for average and peak hold
-               control_box.AddStretchSpacer()
                options_box = forms.static_box_sizer(
                        parent=self, sizer=control_box, label='Options',
                        bold=True, orient=wx.VERTICAL,
@@ -75,7 +75,7 @@
                        ps=parent, key=AVERAGE_KEY,
                )
                #static text and slider for averaging
-               forms.static_text(
+               avg_alpha_text = forms.static_text(
                        sizer=options_box, parent=self, label='Avg Alpha',
                        converter=forms.float_converter(lambda x: '%.4f'%x),
                        ps=parent, key=AVG_ALPHA_KEY, width=50,
@@ -87,34 +87,34 @@
                        num_steps=SLIDER_STEPS,
                        ps=parent, key=AVG_ALPHA_KEY,
                )
-               parent.subscribe(AVERAGE_KEY, avg_alpha_slider.Enable)
+               for widget in (avg_alpha_text, avg_alpha_slider):
+                       parent.subscribe(AVERAGE_KEY, widget.Enable)
+                       widget.Enable(parent[AVERAGE_KEY])
                #radio buttons for div size
                control_box.AddStretchSpacer()
-               db_div_box = forms.static_box_sizer(
-                       parent=self, sizer=control_box, label='Set dB/div',
+               y_ctrl_box = forms.static_box_sizer(
+                       parent=self, sizer=control_box, label='Axis Options',
                        bold=True, orient=wx.VERTICAL,
                )
                forms.radio_buttons(
-                       sizer=db_div_box, parent=self,
+                       sizer=y_ctrl_box, parent=self,
                        ps=parent, key=Y_PER_DIV_KEY,
                        style=wx.RA_VERTICAL|wx.NO_BORDER, choices=DIV_LEVELS,
                        labels=map(lambda x: '%s dB/div'%x, DIV_LEVELS),
                )
                #ref lvl buttons
-               control_box.AddStretchSpacer()
-               ref_lvl_box = forms.static_box_sizer(
-                       parent=self, sizer=control_box, label='Set Ref Level',
-                       bold=True, orient=wx.VERTICAL,
+               forms.incr_decr_buttons(
+                       parent=self, sizer=y_ctrl_box, label='Ref Level',
+                       on_incr=self._on_incr_ref_level, 
on_decr=self._on_decr_ref_level,
                )
-               _ref_lvl_buttons = common.IncrDecrButtons(self, 
self._on_incr_ref_level, self._on_decr_ref_level)
-               ref_lvl_box.Add(_ref_lvl_buttons, 0, wx.ALIGN_CENTER)
+               y_ctrl_box.AddSpacer(2)
                #autoscale
-               control_box.AddStretchSpacer()
                forms.single_button(
-                       sizer=control_box, parent=self, label='Autoscale',
+                       sizer=y_ctrl_box, parent=self, label='Autoscale',
                        callback=self.parent.autoscale,
                )
                #run/stop
+               control_box.AddStretchSpacer()
                forms.toggle_button(
                        sizer=control_box, parent=self,
                        true_label='Stop', false_label='Run',

Modified: 
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/forms/__init__.py
===================================================================
--- 
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/forms/__init__.py  
    2009-05-26 01:23:46 UTC (rev 11126)
+++ 
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/forms/__init__.py  
    2009-05-26 08:03:54 UTC (rev 11127)
@@ -37,7 +37,8 @@
        radio_buttons, drop_down, notebook, \
        button, toggle_button, single_button, \
        check_box, text_box, static_text, \
-       slider, log_slider, make_bold
+       slider, log_slider, \
+       make_bold, DataEvent, EVT_DATA
 
 ########################################################################
 # Helpful widgets
@@ -50,3 +51,36 @@
                if bold: make_bold(box)
                wx.StaticBoxSizer.__init__(self, box=box, orient=orient)
                if sizer: sizer.Add(self, 0, wx.EXPAND)
+
+class incr_decr_buttons(wx.BoxSizer):
+       """
+       A horizontal box sizer with a increment and a decrement button.
+       """
+       def __init__(self, parent, on_incr, on_decr, label='', sizer=None, 
proportion=0, flag=wx.EXPAND):
+               """
+               @param parent the parent window
+               @param on_incr the event handler for increment
+               @param on_decr the event handler for decrement
+               """
+               wx.BoxSizer.__init__(self, wx.HORIZONTAL)
+               buttons_box = wx.BoxSizer(wx.HORIZONTAL)
+               self._incr_button = wx.Button(parent, label='+', 
style=wx.BU_EXACTFIT)
+               self._incr_button.Bind(wx.EVT_BUTTON, on_incr)
+               buttons_box.Add(self._incr_button, 0, wx.ALIGN_CENTER_VERTICAL)
+               self._decr_button = wx.Button(parent, label=' - ', 
style=wx.BU_EXACTFIT)
+               self._decr_button.Bind(wx.EVT_BUTTON, on_decr)
+               buttons_box.Add(self._decr_button, 0, wx.ALIGN_CENTER_VERTICAL)
+               if label: #add label
+                       self.Add(wx.StaticText(parent, label='%s: '%label), 1, 
wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
+                       self.Add(buttons_box, 0, wx.ALIGN_CENTER_VERTICAL | 
wx.ALIGN_RIGHT)
+               else: self.Add(buttons_box, 0, wx.ALIGN_CENTER_VERTICAL)
+               if sizer: sizer.Add(self, proportion, flag)
+
+       def Disable(self, disable=True): self.Enable(not disable)
+       def Enable(self, enable=True):
+               if enable:
+                       self._incr_button.Enable()
+                       self._decr_button.Enable()
+               else:
+                       self._incr_button.Disable()
+                       self._decr_button.Disable()

Modified: 
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/forms/forms.py
===================================================================
--- gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/forms/forms.py 
2009-05-26 01:23:46 UTC (rev 11126)
+++ gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/forms/forms.py 
2009-05-26 08:03:54 UTC (rev 11127)
@@ -37,6 +37,10 @@
 Known problems:
   * An empty label in the radio box still consumes space.
   * The static text cannot resize the parent at runtime.
+
+TODO:
+  * Add @flag to docstrings
+  * Remove stuff in common
 """
 
 EXT_KEY = 'external'
@@ -66,6 +70,7 @@
                pubsub.__init__(self)
                wx.BoxSizer.__init__(self, wx.HORIZONTAL)
                self._parent = parent
+               self._key = key
                self._converter = converter
                self._callback = callback
                self._widgets = list()
@@ -78,7 +83,10 @@
                #no pubsub passed, must set initial value
                else: self.set_value(value)
 
-       def _add_widget(self, widget, label='', flag=0):
+       def __str__(self):
+               return "Form: %s -> %s"%(self.__class__, self._key)
+
+       def _add_widget(self, widget, label='', flag=0, label_prop=0, 
widget_prop=1):
                """
                Add the main widget to this object sizer.
                If label is passed, add a label as well.
@@ -89,6 +97,8 @@
                @param widget the main widget
                @param label the optional label
                @param flag additional flags for widget
+               @param label_prop the proportion for the label
+               @param widget_prop the proportion for the widget
                """
                #setup data event
                widget.Bind(EVT_DATA, lambda x: self._update(x.data))
@@ -96,12 +106,12 @@
                #register widget
                self._widgets.append(widget)
                #create optional label
-               if not label: self.Add(widget, 1, wx.ALIGN_CENTER_VERTICAL | 
flag)
+               if not label: self.Add(widget, widget_prop, 
wx.ALIGN_CENTER_VERTICAL | flag)
                else:
                        label_text = wx.StaticText(self._parent, label='%s: 
'%label)
                        self._widgets.append(label_text)
-                       self.Add(label_text, 0, wx.ALIGN_CENTER_VERTICAL | 
wx.ALIGN_LEFT)
-                       self.Add(widget, 1, wx.ALIGN_CENTER_VERTICAL | 
wx.ALIGN_RIGHT | flag)
+                       self.Add(label_text, label_prop, 
wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
+                       self.Add(widget, widget_prop, wx.ALIGN_CENTER_VERTICAL 
| wx.ALIGN_RIGHT | flag)
                #initialize without triggering pubsubs
                self._translate_external_to_internal(self[EXT_KEY])
                update(self[INT_KEY])
@@ -130,7 +140,7 @@
                        self[EXT_KEY] = self[EXT_KEY] #reset to last good 
setting
 
        def _err_msg(self, value, e):
-               print >> sys.stderr, 'Error translating value: 
"%s"\n\t%s\n\t%s'%(value, e, self._converter.help())
+               print >> sys.stderr, self, 'Error translating value: 
"%s"\n\t%s\n\t%s'%(value, e, self._converter.help())
 
        #override in subclasses to handle the wxgui object
        def _update(self, value): raise NotImplementedError
@@ -317,12 +327,13 @@
        @param choices list of possible values
        @param labels list of labels for each choice (default=choices)
        @param label title label for this widget (optional)
+       @param width the form width in px (optional)
        """
-       def __init__(self, label='', **kwargs):
+       def __init__(self, label='', width=-1, **kwargs):
                _chooser_base.__init__(self, **kwargs)
-               self._drop_down = wx.Choice(self._parent, choices=self._labels)
+               self._drop_down = wx.Choice(self._parent, choices=self._labels, 
size=wx.Size(width, -1))
                self._drop_down.Bind(wx.EVT_CHOICE, self._handle)
-               self._add_widget(self._drop_down, label)
+               self._add_widget(self._drop_down, label, widget_prop=0, 
label_prop=1)
 
        def _handle(self, event): self[INT_KEY] = self._drop_down.GetSelection()
        def _update(self, i): self._drop_down.SetSelection(i)
@@ -352,7 +363,7 @@
                _chooser_base.__init__(self, **kwargs)
                self._button = wx.Button(self._parent, size=wx.Size(width, -1), 
style=style)
                self._button.Bind(wx.EVT_BUTTON, self._handle)
-               self._add_widget(self._button, label)
+               self._add_widget(self._button, label, widget_prop=((not 
style&wx.BU_EXACTFIT) and 1 or 0))
 
        def _handle(self, event): self[INT_KEY] = (self[INT_KEY] + 
1)%len(self._choices) #circularly increment index
        def _update(self, i): self._button.SetLabel(self._labels[i]); 
self.Layout()

Modified: 
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/histo_window.py
===================================================================
--- 
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/histo_window.py    
    2009-05-26 01:23:46 UTC (rev 11126)
+++ 
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/histo_window.py    
    2009-05-26 08:03:54 UTC (rev 11127)
@@ -30,6 +30,7 @@
 import pubsub
 from constants import *
 from gnuradio import gr #for gr.prefs
+import forms
 
 ##################################################
 # Constants
@@ -53,23 +54,31 @@
                wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER)
                control_box = wx.BoxSizer(wx.VERTICAL)
                SIZE = (100, -1)
-               control_box.Add(common.LabelText(self, 'Options'), 0, 
wx.ALIGN_CENTER)
-               control_box.AddStretchSpacer()
+               control_box = forms.static_box_sizer(
+                       parent=self, label='Options',
+                       bold=True, orient=wx.VERTICAL,
+               )
                #num bins
-               def num_bins_cast(num):
-                       num = int(num)
-                       assert num > 1
-                       return num
-               num_bins_ctrl = common.TextBoxController(self, parent, 
NUM_BINS_KEY, cast=num_bins_cast)
-               control_box.Add(common.LabelBox(self, ' Num Bins ', 
num_bins_ctrl), 0, wx.EXPAND)
                control_box.AddStretchSpacer()
+               forms.text_box(
+                       sizer=control_box, parent=self, label='Num Bins',
+                       converter=forms.int_converter(),
+                       ps=parent, key=NUM_BINS_KEY,
+               )
                #frame size
-               frame_size_ctrl = common.TextBoxController(self, parent, 
FRAME_SIZE_KEY, cast=num_bins_cast)
-               control_box.Add(common.LabelBox(self, ' Frame Size ', 
frame_size_ctrl), 0, wx.EXPAND)
                control_box.AddStretchSpacer()
+               forms.text_box(
+                       sizer=control_box, parent=self, label='Frame Size',
+                       converter=forms.int_converter(),
+                       ps=parent, key=FRAME_SIZE_KEY,
+               )
                #run/stop
-               self.run_button = common.ToggleButtonController(self, parent, 
RUNNING_KEY, 'Stop', 'Run')
-               control_box.Add(self.run_button, 0, wx.EXPAND)
+               control_box.AddStretchSpacer()
+               forms.toggle_button(
+                       sizer=control_box, parent=self,
+                       true_label='Stop', false_label='Run',
+                       ps=parent, key=RUNNING_KEY,
+               )
                #set sizer
                self.SetSizerAndFit(control_box)
 
@@ -98,6 +107,10 @@
                self.proxy(NUM_BINS_KEY, controller, num_bins_key)
                self.proxy(FRAME_SIZE_KEY, controller, frame_size_key)
                self.proxy(MSG_KEY, controller, msg_key)
+               #initialize values
+               self[RUNNING_KEY] = True
+               self[X_DIVS_KEY] = 8
+               self[Y_DIVS_KEY] = 4
                #init panel and plot
                wx.Panel.__init__(self, parent, style=wx.SIMPLE_BORDER)
                self.plotter = plotter.bar_plotter(self)
@@ -111,12 +124,6 @@
                main_box.Add(self.plotter, 1, wx.EXPAND)
                main_box.Add(self.control_panel, 0, wx.EXPAND)
                self.SetSizerAndFit(main_box)
-               #initialize values
-               self[NUM_BINS_KEY] = self[NUM_BINS_KEY]
-               self[FRAME_SIZE_KEY] = self[FRAME_SIZE_KEY]
-               self[RUNNING_KEY] = True
-               self[X_DIVS_KEY] = 8
-               self[Y_DIVS_KEY] = 4
                #register events
                self.subscribe(MSG_KEY, self.handle_msg)
                self.subscribe(X_DIVS_KEY, self.update_grid)

Modified: 
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/number_window.py
===================================================================
--- 
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/number_window.py   
    2009-05-26 01:23:46 UTC (rev 11126)
+++ 
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/number_window.py   
    2009-05-26 08:03:54 UTC (rev 11127)
@@ -28,6 +28,7 @@
 import pubsub
 from constants import *
 from gnuradio import gr #for gr.prefs
+import forms
 
 ##################################################
 # Constants
@@ -57,24 +58,41 @@
                control_box = wx.BoxSizer(wx.VERTICAL)
                #checkboxes for average and peak hold
                control_box.AddStretchSpacer()
-               control_box.Add(common.LabelText(self, 'Options'), 0, 
wx.ALIGN_CENTER)
-               self.peak_hold_check_box = common.CheckBoxController(self, 
'Peak Hold', parent, PEAK_HOLD_KEY)
-               control_box.Add(self.peak_hold_check_box, 0, wx.EXPAND)
-               self.average_check_box = common.CheckBoxController(self, 
'Average', parent, AVERAGE_KEY)
-               control_box.Add(self.average_check_box, 0, wx.EXPAND)
-               control_box.AddSpacer(2)
-               self.avg_alpha_slider = common.LogSliderController(
-                       self, 'Avg Alpha',
-                       AVG_ALPHA_MIN_EXP, AVG_ALPHA_MAX_EXP, SLIDER_STEPS,
-                       parent, AVG_ALPHA_KEY,
-                       formatter=lambda x: ': %.4f'%x,
+               options_box = forms.static_box_sizer(
+                       parent=self, sizer=control_box, label='Options',
+                       bold=True, orient=wx.VERTICAL,
                )
-               parent.subscribe(AVERAGE_KEY, self.avg_alpha_slider.Enable)
-               control_box.Add(self.avg_alpha_slider, 0, wx.EXPAND)
+               forms.check_box(
+                       sizer=options_box, parent=self, label='Peak Hold',
+                       ps=parent, key=PEAK_HOLD_KEY,
+               )
+               forms.check_box(
+                       sizer=options_box, parent=self, label='Average',
+                       ps=parent, key=AVERAGE_KEY,
+               )
+               #static text and slider for averaging
+               avg_alpha_text = forms.static_text(
+                       sizer=options_box, parent=self, label='Avg Alpha',
+                       converter=forms.float_converter(lambda x: '%.4f'%x),
+                       ps=parent, key=AVG_ALPHA_KEY, width=50,
+               )
+               avg_alpha_slider = forms.log_slider(
+                       sizer=options_box, parent=self,
+                       min_exp=AVG_ALPHA_MIN_EXP,
+                       max_exp=AVG_ALPHA_MAX_EXP,
+                       num_steps=SLIDER_STEPS,
+                       ps=parent, key=AVG_ALPHA_KEY,
+               )
+               for widget in (avg_alpha_text, avg_alpha_slider):
+                       parent.subscribe(AVERAGE_KEY, widget.Enable)
+                       widget.Enable(parent[AVERAGE_KEY])
                #run/stop
                control_box.AddStretchSpacer()
-               self.run_button = common.ToggleButtonController(self, parent, 
RUNNING_KEY, 'Stop', 'Run')
-               control_box.Add(self.run_button, 0, wx.EXPAND)
+               forms.toggle_button(
+                       sizer=control_box, parent=self,
+                       true_label='Stop', false_label='Run',
+                       ps=parent, key=RUNNING_KEY,
+               )
                #set sizer
                self.SetSizerAndFit(control_box)
 
@@ -115,6 +133,9 @@
                self.proxy(AVERAGE_KEY, controller, average_key)
                self.proxy(AVG_ALPHA_KEY, controller, avg_alpha_key)
                self.proxy(SAMPLE_RATE_KEY, controller, sample_rate_key)
+               #initialize values
+               self[PEAK_HOLD_KEY] = peak_hold
+               self[RUNNING_KEY] = True
                #setup the box with display and controls
                self.control_panel = control_panel(self)
                main_box = wx.BoxSizer(wx.HORIZONTAL)
@@ -131,14 +152,9 @@
                sizer.Add(self.gauge_real, 1, wx.EXPAND)
                sizer.Add(self.gauge_imag, 1, wx.EXPAND)
                self.SetSizerAndFit(main_box)
-               #initialize values
-               self[PEAK_HOLD_KEY] = peak_hold
-               self[RUNNING_KEY] = True
-               self[AVERAGE_KEY] = self[AVERAGE_KEY]
-               self[AVG_ALPHA_KEY] = self[AVG_ALPHA_KEY]
                #register events
                self.subscribe(MSG_KEY, self.handle_msg)
-               self.Bind(common.EVT_DATA, self.update)
+               self.Bind(forms.EVT_DATA, self.update)
 
        def show_gauges(self, show_gauge):
                """
@@ -157,7 +173,7 @@
                Allow wx to handle the event to avoid threading issues.
                @param msg the incoming numbersink data
                """
-               wx.PostEvent(self, common.DataEvent(msg))
+               wx.PostEvent(self, forms.DataEvent(msg))
 
        def update(self, event):
                """

Modified: 
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/scope_window.py
===================================================================
--- 
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/scope_window.py    
    2009-05-26 01:23:46 UTC (rev 11126)
+++ 
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/scope_window.py    
    2009-05-26 08:03:54 UTC (rev 11127)
@@ -30,6 +30,7 @@
 import pubsub
 from constants import *
 from gnuradio import gr #for gr.prefs, trigger modes
+import forms
 
 ##################################################
 # Constants
@@ -78,7 +79,7 @@
                Create a new control panel.
                @param parent the wx parent window
                """
-               SIZE = (100, -1)
+               WIDTH = 100
                self.parent = parent
                wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER)
                control_box = wx.BoxSizer(wx.VERTICAL)
@@ -86,161 +87,238 @@
                # Axes Options
                ##################################################
                control_box.AddStretchSpacer()
-               control_box.Add(common.LabelText(self, 'Axes Options'), 0, 
wx.ALIGN_CENTER)
-               control_box.AddSpacer(2)
+               axes_options_box = forms.static_box_sizer(
+                       parent=self, sizer=control_box, label='Axes Options',
+                       bold=True, orient=wx.VERTICAL,
+               )
                ##################################################
                # Scope Mode Box
                ##################################################
                scope_mode_box = wx.BoxSizer(wx.VERTICAL)
-               control_box.Add(scope_mode_box, 0, wx.EXPAND)
+               axes_options_box.Add(scope_mode_box, 0, wx.EXPAND)
                #x axis divs
-               x_buttons_scope = common.IncrDecrButtons(self, 
self._on_incr_t_divs, self._on_decr_t_divs)
-               scope_mode_box.Add(common.LabelBox(self, 'Secs/Div', 
x_buttons_scope), 0, wx.EXPAND)
+               forms.incr_decr_buttons(
+                       parent=self, sizer=scope_mode_box, label='Secs/Div',
+                       on_incr=self._on_incr_t_divs, 
on_decr=self._on_decr_t_divs,
+               )
                #y axis divs
-               y_buttons_scope = common.IncrDecrButtons(self, 
self._on_incr_y_divs, self._on_decr_y_divs)
-               parent.subscribe(AUTORANGE_KEY, lambda x: 
y_buttons_scope.Enable(not x))
-               scope_mode_box.Add(common.LabelBox(self, 'Counts/Div', 
y_buttons_scope), 0, wx.EXPAND)
+               y_buttons_scope = forms.incr_decr_buttons(
+                       parent=self, sizer=scope_mode_box, label='Counts/Div',
+                       on_incr=self._on_incr_y_divs, 
on_decr=self._on_decr_y_divs,
+               )
                #y axis ref lvl
-               y_off_buttons_scope = common.IncrDecrButtons(self, 
self._on_incr_y_off, self._on_decr_y_off)
-               parent.subscribe(AUTORANGE_KEY, lambda x: 
y_off_buttons_scope.Enable(not x))
-               scope_mode_box.Add(common.LabelBox(self, 'Y Offset', 
y_off_buttons_scope), 0, wx.EXPAND)
+               y_off_buttons_scope = forms.incr_decr_buttons(
+                       parent=self, sizer=scope_mode_box, label='Y Offset',
+                       on_incr=self._on_incr_y_off, 
on_decr=self._on_decr_y_off,
+               )
                #t axis ref lvl
                scope_mode_box.AddSpacer(5)
-               t_off_slider = wx.Slider(self, size=SIZE, 
style=wx.SL_HORIZONTAL)
-               t_off_slider.SetRange(0, 1000)
-               def t_off_slider_changed(evt): parent[T_FRAC_OFF_KEY] = 
float(t_off_slider.GetValue())/t_off_slider.GetMax()
-               t_off_slider.Bind(wx.EVT_SLIDER, t_off_slider_changed)
-               parent.subscribe(T_FRAC_OFF_KEY, lambda x: 
t_off_slider.SetValue(int(round(x*t_off_slider.GetMax()))))
-               scope_mode_box.Add(common.LabelBox(self, 'T Offset', 
t_off_slider), 0, wx.EXPAND)
+               forms.slider(
+                       parent=self, sizer=scope_mode_box,
+                       ps=parent, key=T_FRAC_OFF_KEY, label='T Offset',
+                       minimum=0, maximum=1, num_steps=1000,
+               )
                scope_mode_box.AddSpacer(5)
                ##################################################
                # XY Mode Box
                ##################################################
                xy_mode_box = wx.BoxSizer(wx.VERTICAL)
-               control_box.Add(xy_mode_box, 0, wx.EXPAND)
+               axes_options_box.Add(xy_mode_box, 0, wx.EXPAND)
                #x div controls
-               x_buttons = common.IncrDecrButtons(self, self._on_incr_x_divs, 
self._on_decr_x_divs)
-               parent.subscribe(AUTORANGE_KEY, lambda x: x_buttons.Enable(not 
x))
-               xy_mode_box.Add(common.LabelBox(self, 'X/Div', x_buttons), 0, 
wx.EXPAND)
+               x_buttons = forms.incr_decr_buttons(
+                       parent=self, sizer=xy_mode_box, label='X/Div',
+                       on_incr=self._on_incr_x_divs, 
on_decr=self._on_decr_x_divs,
+               )
                #y div controls
-               y_buttons = common.IncrDecrButtons(self, self._on_incr_y_divs, 
self._on_decr_y_divs)
-               parent.subscribe(AUTORANGE_KEY, lambda x: y_buttons.Enable(not 
x))
-               xy_mode_box.Add(common.LabelBox(self, 'Y/Div', y_buttons), 0, 
wx.EXPAND)
+               y_buttons = forms.incr_decr_buttons(
+                       parent=self, sizer=xy_mode_box, label='Y/Div',
+                       on_incr=self._on_incr_y_divs, 
on_decr=self._on_decr_y_divs,
+               )
                #x offset controls
-               x_off_buttons = common.IncrDecrButtons(self, 
self._on_incr_x_off, self._on_decr_x_off)
-               parent.subscribe(AUTORANGE_KEY, lambda x: 
x_off_buttons.Enable(not x))
-               xy_mode_box.Add(common.LabelBox(self, 'X Off', x_off_buttons), 
0, wx.EXPAND)
+               x_off_buttons = forms.incr_decr_buttons(
+                       parent=self, sizer=xy_mode_box, label='X Off',
+                       on_incr=self._on_incr_x_off, 
on_decr=self._on_decr_x_off,
+               )
                #y offset controls
-               y_off_buttons = common.IncrDecrButtons(self, 
self._on_incr_y_off, self._on_decr_y_off)
-               parent.subscribe(AUTORANGE_KEY, lambda x: 
y_off_buttons.Enable(not x))
-               xy_mode_box.Add(common.LabelBox(self, 'Y Off', y_off_buttons), 
0, wx.EXPAND)
+               y_off_buttons = forms.incr_decr_buttons(
+                       parent=self, sizer=xy_mode_box, label='Y Off',
+                       on_incr=self._on_incr_y_off, 
on_decr=self._on_decr_y_off,
+               )
+               for widget in (y_buttons_scope, y_off_buttons_scope, x_buttons, 
y_buttons, x_off_buttons, y_off_buttons):
+                       parent.subscribe(AUTORANGE_KEY, widget.Disable)
+                       widget.Disable(parent[AUTORANGE_KEY])
                xy_mode_box.ShowItems(False)
                #autorange check box
-               self.autorange_check_box = common.CheckBoxController(self, 
'Autorange', parent, AUTORANGE_KEY)
-               control_box.Add(self.autorange_check_box, 0, wx.ALIGN_LEFT)
-               control_box.AddStretchSpacer()
+               forms.check_box(
+                       parent=self, sizer=axes_options_box, label='Autorange',
+                       ps=parent, key=AUTORANGE_KEY,
+               )
                ##################################################
                # Channel Options
                ##################################################
                TRIGGER_PAGE_INDEX = parent.num_inputs
                XY_PAGE_INDEX = parent.num_inputs+1
-               control_box.Add(common.LabelText(self, 'Channel Options'), 0, 
wx.ALIGN_CENTER)
-               control_box.AddSpacer(2)
+               control_box.AddStretchSpacer()
+               chan_options_box = forms.static_box_sizer(
+                       parent=self, sizer=control_box, label='Channel Options',
+                       bold=True, orient=wx.VERTICAL,
+               )
                options_notebook = wx.Notebook(self)
-               control_box.Add(options_notebook, 0, wx.EXPAND)
-               def options_notebook_changed(evt):
-                       try:
-                               parent[TRIGGER_SHOW_KEY] = 
options_notebook.GetSelection() == TRIGGER_PAGE_INDEX
-                               parent[XY_MODE_KEY] = 
options_notebook.GetSelection() == XY_PAGE_INDEX
-                       except wx.PyDeadObjectError: pass
-               options_notebook.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, 
options_notebook_changed)
-               def xy_mode_changed(mode):
-                       #ensure xy tab is selected
-                       if mode and options_notebook.GetSelection() != 
XY_PAGE_INDEX:
-                               options_notebook.SetSelection(XY_PAGE_INDEX)
-                       #ensure xy tab is not selected
-                       elif not mode and options_notebook.GetSelection() == 
XY_PAGE_INDEX:
-                               options_notebook.SetSelection(0)
-                       #show/hide control buttons
-                       scope_mode_box.ShowItems(not mode)
-                       xy_mode_box.ShowItems(mode)
-                       control_box.Layout()
-               parent.subscribe(XY_MODE_KEY, xy_mode_changed)
+               options_notebook_args = list()
+               CHANNELS = [('Channel %d'%(i+1), i) for i in 
range(parent.num_inputs)]
                ##################################################
                # Channel Menu Boxes
                ##################################################
                for i in range(parent.num_inputs):
                        channel_menu_panel = wx.Panel(options_notebook)
-                       options_notebook.AddPage(channel_menu_panel, 
'Ch%d'%(i+1))
+                       options_notebook_args.append((channel_menu_panel, i, 
'Ch%d'%(i+1)))
                        channel_menu_box = wx.BoxSizer(wx.VERTICAL)
                        channel_menu_panel.SetSizer(channel_menu_box)
                        #ac couple check box
                        channel_menu_box.AddStretchSpacer()
-                       coupling_chooser = 
common.DropDownController(channel_menu_panel, COUPLING_MODES, parent, 
common.index_key(AC_COUPLE_KEY, i), SIZE)
-                       
channel_menu_box.Add(common.LabelBox(channel_menu_panel, 'Coupling', 
coupling_chooser), 0, wx.EXPAND)
+                       forms.drop_down(
+                               parent=channel_menu_panel, 
sizer=channel_menu_box,
+                               ps=parent, key=common.index_key(AC_COUPLE_KEY, 
i),
+                               choices=map(lambda x: x[1], COUPLING_MODES),
+                               labels=map(lambda x: x[0], COUPLING_MODES),
+                               label='Coupling', width=WIDTH,
+                       )
                        #marker
                        channel_menu_box.AddStretchSpacer()
-                       marker_chooser = 
common.DropDownController(channel_menu_panel, MARKER_TYPES, parent, 
common.index_key(MARKER_KEY, i), SIZE)
-                       
channel_menu_box.Add(common.LabelBox(channel_menu_panel, 'Marker', 
marker_chooser), 0, wx.EXPAND)
+                       forms.drop_down(
+                               parent=channel_menu_panel, 
sizer=channel_menu_box,
+                               ps=parent, key=common.index_key(MARKER_KEY, i),
+                               choices=map(lambda x: x[1], MARKER_TYPES),
+                               labels=map(lambda x: x[0], MARKER_TYPES),
+                               label='Marker', width=WIDTH,
+                       )
                        channel_menu_box.AddStretchSpacer()
                ##################################################
                # Trigger Menu Box
                ##################################################
                trigger_menu_panel = wx.Panel(options_notebook)
-               options_notebook.AddPage(trigger_menu_panel, 'Trig')
+               options_notebook_args.append((trigger_menu_panel, 
TRIGGER_PAGE_INDEX, 'Trig'))
                trigger_menu_box = wx.BoxSizer(wx.VERTICAL)
                trigger_menu_panel.SetSizer(trigger_menu_box)
                #trigger mode
-               trigger_mode_chooser = 
common.DropDownController(trigger_menu_panel, TRIGGER_MODES, parent, 
TRIGGER_MODE_KEY, SIZE)
-               trigger_menu_box.Add(common.LabelBox(trigger_menu_panel, 
'Mode', trigger_mode_chooser), 0, wx.EXPAND)
+               forms.drop_down(
+                       parent=trigger_menu_panel, sizer=trigger_menu_box,
+                       ps=parent, key=TRIGGER_MODE_KEY,
+                       choices=map(lambda x: x[1], TRIGGER_MODES),
+                       labels=map(lambda x: x[0], TRIGGER_MODES),
+                       label='Mode', width=WIDTH,
+               )
                #trigger slope
-               trigger_slope_chooser = 
common.DropDownController(trigger_menu_panel, TRIGGER_SLOPES, parent, 
TRIGGER_SLOPE_KEY, SIZE)
-               parent.subscribe(TRIGGER_MODE_KEY, lambda x: 
trigger_slope_chooser.Enable(x!=gr.gr_TRIG_MODE_FREE))
-               trigger_menu_box.Add(common.LabelBox(trigger_menu_panel, 
'Slope', trigger_slope_chooser), 0, wx.EXPAND)
+               trigger_slope_chooser = forms.drop_down(
+                       parent=trigger_menu_panel, sizer=trigger_menu_box,
+                       ps=parent, key=TRIGGER_SLOPE_KEY,
+                       choices=map(lambda x: x[1], TRIGGER_SLOPES),
+                       labels=map(lambda x: x[0], TRIGGER_SLOPES),
+                       label='Slope', width=WIDTH,
+               )
                #trigger channel
-               choices = [('Channel %d'%(i+1), i) for i in 
range(parent.num_inputs)]
-               trigger_channel_chooser = 
common.DropDownController(trigger_menu_panel, choices, parent, 
TRIGGER_CHANNEL_KEY, SIZE)
-               parent.subscribe(TRIGGER_MODE_KEY, lambda x: 
trigger_channel_chooser.Enable(x!=gr.gr_TRIG_MODE_FREE))
-               trigger_menu_box.Add(common.LabelBox(trigger_menu_panel, 
'Channel', trigger_channel_chooser), 0, wx.EXPAND)
+               trigger_channel_chooser = forms.drop_down(
+                       parent=trigger_menu_panel, sizer=trigger_menu_box,
+                       ps=parent, key=TRIGGER_CHANNEL_KEY,
+                       choices=map(lambda x: x[1], CHANNELS),
+                       labels=map(lambda x: x[0], CHANNELS),
+                       label='Channel', width=WIDTH,
+               )
                #trigger level
                hbox = wx.BoxSizer(wx.HORIZONTAL)
                trigger_menu_box.Add(hbox, 0, wx.EXPAND)
-               hbox.Add(wx.StaticText(trigger_menu_panel, label=' Level '), 1, 
wx.ALIGN_CENTER_VERTICAL)
-               trigger_level_button = wx.Button(trigger_menu_panel, 
label='50%', style=wx.BU_EXACTFIT)
-               parent.subscribe(TRIGGER_MODE_KEY, lambda x: 
trigger_level_button.Enable(x!=gr.gr_TRIG_MODE_FREE))
-               trigger_level_button.Bind(wx.EVT_BUTTON, 
self.parent.set_auto_trigger_level)
-               hbox.Add(trigger_level_button, 0, wx.ALIGN_CENTER_VERTICAL)
-               hbox.AddSpacer(10)
-               trigger_level_buttons = 
common.IncrDecrButtons(trigger_menu_panel, self._on_incr_trigger_level, 
self._on_decr_trigger_level)
-               parent.subscribe(TRIGGER_MODE_KEY, lambda x: 
trigger_level_buttons.Enable(x!=gr.gr_TRIG_MODE_FREE))
-               hbox.Add(trigger_level_buttons, 0, wx.ALIGN_CENTER_VERTICAL)
+               hbox.Add(wx.StaticText(trigger_menu_panel, label='Level:'), 1, 
wx.ALIGN_CENTER_VERTICAL)
+               trigger_level_button = forms.single_button(
+                       parent=trigger_menu_panel, sizer=hbox, label='50%',
+                       callback=parent.set_auto_trigger_level, 
style=wx.BU_EXACTFIT,
+               )
+               hbox.AddSpacer(40)
+               trigger_level_buttons = forms.incr_decr_buttons(
+                       parent=trigger_menu_panel, sizer=hbox,
+                       on_incr=self._on_incr_trigger_level, 
on_decr=self._on_decr_trigger_level,
+               )
+               def disable_all(trigger_mode):
+                       for widget in (trigger_slope_chooser, 
trigger_channel_chooser, trigger_level_buttons, trigger_level_button):
+                               widget.Disable(trigger_mode == 
gr.gr_TRIG_MODE_FREE)
+               parent.subscribe(TRIGGER_MODE_KEY, disable_all)
+               disable_all(parent[TRIGGER_MODE_KEY])
                ##################################################
                # XY Menu Box
                ##################################################
                if parent.num_inputs > 1:
                        xy_menu_panel = wx.Panel(options_notebook)
-                       options_notebook.AddPage(xy_menu_panel, 'XY')
+                       options_notebook_args.append((xy_menu_panel, 
XY_PAGE_INDEX, 'XY'))
                        xy_menu_box = wx.BoxSizer(wx.VERTICAL)
                        xy_menu_panel.SetSizer(xy_menu_box)
                        #x and y channel choosers
                        xy_menu_box.AddStretchSpacer()
-                       choices = [('Ch%d'%(i+1), i) for i in 
range(parent.num_inputs)]
-                       x_channel_chooser = 
common.DropDownController(xy_menu_panel, choices, parent, X_CHANNEL_KEY, SIZE)
-                       xy_menu_box.Add(common.LabelBox(xy_menu_panel, 'Ch X', 
x_channel_chooser), 0, wx.EXPAND)
+                       forms.drop_down(
+                               parent=xy_menu_panel, sizer=xy_menu_box,
+                               ps=parent, key=X_CHANNEL_KEY,
+                               choices=map(lambda x: x[1], CHANNELS),
+                               labels=map(lambda x: x[0], CHANNELS),
+                               label='Channel X', width=WIDTH,
+                       )
                        xy_menu_box.AddStretchSpacer()
-                       y_channel_chooser = 
common.DropDownController(xy_menu_panel, choices, parent, Y_CHANNEL_KEY, SIZE)
-                       xy_menu_box.Add(common.LabelBox(xy_menu_panel, 'Ch Y', 
y_channel_chooser), 0, wx.EXPAND)
+                       forms.drop_down(
+                               parent=xy_menu_panel, sizer=xy_menu_box,
+                               ps=parent, key=Y_CHANNEL_KEY,
+                               choices=map(lambda x: x[1], CHANNELS),
+                               labels=map(lambda x: x[0], CHANNELS),
+                               label='Channel Y', width=WIDTH,
+                       )
                        #marker
                        xy_menu_box.AddStretchSpacer()
-                       marker_chooser = 
common.DropDownController(xy_menu_panel, MARKER_TYPES, parent, XY_MARKER_KEY, 
SIZE)
-                       xy_menu_box.Add(common.LabelBox(xy_menu_panel, 
'Marker', marker_chooser), 0, wx.EXPAND)
+                       forms.drop_down(
+                               parent=xy_menu_panel, sizer=xy_menu_box,
+                               ps=parent, key=XY_MARKER_KEY,
+                               choices=map(lambda x: x[1], MARKER_TYPES),
+                               labels=map(lambda x: x[0], MARKER_TYPES),
+                               label='Marker', width=WIDTH,
+                       )
                        xy_menu_box.AddStretchSpacer()
                ##################################################
+               # Setup Options Notebook
+               ##################################################
+               forms.notebook(
+                       parent=self, sizer=chan_options_box,
+                       notebook=options_notebook,
+                       ps=parent, key=CHANNEL_OPTIONS_KEY,
+                       pages=map(lambda x: x[0], options_notebook_args),
+                       choices=map(lambda x: x[1], options_notebook_args),
+                       labels=map(lambda x: x[2], options_notebook_args),
+               )
+               #gui handling for channel options changing
+               def options_notebook_changed(chan_opt):
+                       try:
+                               parent[TRIGGER_SHOW_KEY] = chan_opt == 
TRIGGER_PAGE_INDEX
+                               parent[XY_MODE_KEY] = chan_opt == XY_PAGE_INDEX
+                       except wx.PyDeadObjectError: pass
+               parent.subscribe(CHANNEL_OPTIONS_KEY, options_notebook_changed)
+               #gui handling for xy mode changing
+               def xy_mode_changed(mode):
+                       #ensure xy tab is selected
+                       if mode and parent[CHANNEL_OPTIONS_KEY] != 
XY_PAGE_INDEX:
+                               parent[CHANNEL_OPTIONS_KEY] = XY_PAGE_INDEX
+                       #ensure xy tab is not selected
+                       elif not mode and parent[CHANNEL_OPTIONS_KEY] == 
XY_PAGE_INDEX:
+                               parent[CHANNEL_OPTIONS_KEY] = 0
+                       #show/hide control buttons
+                       scope_mode_box.ShowItems(not mode)
+                       xy_mode_box.ShowItems(mode)
+                       control_box.Layout()
+               parent.subscribe(XY_MODE_KEY, xy_mode_changed)
+               xy_mode_changed(parent[XY_MODE_KEY])
+               ##################################################
                # Run/Stop Button
                ##################################################
                #run/stop
-               self.run_button = common.ToggleButtonController(self, parent, 
RUNNING_KEY, 'Stop', 'Run')
-               control_box.Add(self.run_button, 0, wx.EXPAND)
+               control_box.AddStretchSpacer()
+               forms.toggle_button(
+                       sizer=control_box, parent=self,
+                       true_label='Stop', false_label='Run',
+                       ps=parent, key=RUNNING_KEY,
+               )
                #set sizer
                self.SetSizerAndFit(control_box)
                #mouse wheel event
@@ -323,28 +401,10 @@
                self.proxy(TRIGGER_SLOPE_KEY, controller, trigger_slope_key)
                self.proxy(TRIGGER_CHANNEL_KEY, controller, trigger_channel_key)
                self.proxy(DECIMATION_KEY, controller, decimation_key)
-               for i in range(num_inputs):
-                       self.proxy(common.index_key(AC_COUPLE_KEY, i), 
controller, common.index_key(ac_couple_key, i))
-               #init panel and plot
-               wx.Panel.__init__(self, parent, style=wx.SIMPLE_BORDER)
-               self.plotter = plotter.channel_plotter(self)
-               self.plotter.SetSize(wx.Size(*size))
-               self.plotter.set_title(title)
-               self.plotter.enable_legend(True)
-               self.plotter.enable_point_label(True)
-               self.plotter.enable_grid_lines(True)
-               #setup the box with plot and controls
-               self.control_panel = control_panel(self)
-               main_box = wx.BoxSizer(wx.HORIZONTAL)
-               main_box.Add(self.plotter, 1, wx.EXPAND)
-               main_box.Add(self.control_panel, 0, wx.EXPAND)
-               self.SetSizerAndFit(main_box)
                #initialize values
                self[RUNNING_KEY] = True
-               for i in range(self.num_inputs):
-                       self[common.index_key(AC_COUPLE_KEY, i)] = 
self[common.index_key(AC_COUPLE_KEY, i)]
-                       self[common.index_key(MARKER_KEY, i)] = 
DEFAULT_MARKER_TYPE
                self[XY_MARKER_KEY] = 2.0
+               self[CHANNEL_OPTIONS_KEY] = 0
                self[XY_MODE_KEY] = xy_mode
                self[X_CHANNEL_KEY] = 0
                self[Y_CHANNEL_KEY] = self.num_inputs-1
@@ -364,6 +424,22 @@
                self[TRIGGER_MODE_KEY] = gr.gr_TRIG_MODE_AUTO
                self[TRIGGER_SLOPE_KEY] = gr.gr_TRIG_SLOPE_POS
                self[T_FRAC_OFF_KEY] = 0.5
+               for i in range(num_inputs):
+                       self.proxy(common.index_key(AC_COUPLE_KEY, i), 
controller, common.index_key(ac_couple_key, i))
+               #init panel and plot
+               wx.Panel.__init__(self, parent, style=wx.SIMPLE_BORDER)
+               self.plotter = plotter.channel_plotter(self)
+               self.plotter.SetSize(wx.Size(*size))
+               self.plotter.set_title(title)
+               self.plotter.enable_legend(True)
+               self.plotter.enable_point_label(True)
+               self.plotter.enable_grid_lines(True)
+               #setup the box with plot and controls
+               self.control_panel = control_panel(self)
+               main_box = wx.BoxSizer(wx.HORIZONTAL)
+               main_box.Add(self.plotter, 1, wx.EXPAND)
+               main_box.Add(self.control_panel, 0, wx.EXPAND)
+               self.SetSizerAndFit(main_box)
                #register events for message
                self.subscribe(MSG_KEY, self.handle_msg)
                #register events for grid

Modified: 
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/waterfall_window.py
===================================================================
--- 
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/waterfall_window.py
    2009-05-26 01:23:46 UTC (rev 11126)
+++ 
gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/waterfall_window.py
    2009-05-26 08:03:54 UTC (rev 11127)
@@ -30,6 +30,7 @@
 import pubsub
 from constants import *
 from gnuradio import gr #for gr.prefs
+import forms
 
 ##################################################
 # Constants
@@ -64,54 +65,75 @@
                wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER)
                control_box = wx.BoxSizer(wx.VERTICAL)
                control_box.AddStretchSpacer()
-               control_box.Add(common.LabelText(self, 'Options'), 0, 
wx.ALIGN_CENTER)
-               #color mode
-               control_box.AddStretchSpacer()
-               color_mode_chooser = common.DropDownController(self, 
COLOR_MODES, parent, COLOR_MODE_KEY)
-               control_box.Add(common.LabelBox(self, 'Color', 
color_mode_chooser), 0, wx.EXPAND)
+               options_box = forms.static_box_sizer(
+                       parent=self, sizer=control_box, label='Options',
+                       bold=True, orient=wx.VERTICAL,
+               )
                #average
+               forms.check_box(
+                       sizer=options_box, parent=self, label='Average',
+                       ps=parent, key=AVERAGE_KEY,
+               )
+               avg_alpha_text = forms.static_text(
+                       sizer=options_box, parent=self, label='Avg Alpha',
+                       converter=forms.float_converter(lambda x: '%.4f'%x),
+                       ps=parent, key=AVG_ALPHA_KEY, width=50,
+               )
+               avg_alpha_slider = forms.log_slider(
+                       sizer=options_box, parent=self,
+                       min_exp=AVG_ALPHA_MIN_EXP,
+                       max_exp=AVG_ALPHA_MAX_EXP,
+                       num_steps=SLIDER_STEPS,
+                       ps=parent, key=AVG_ALPHA_KEY,
+               )
+               for widget in (avg_alpha_text, avg_alpha_slider):
+                       parent.subscribe(AVERAGE_KEY, widget.Enable)
+                       widget.Enable(parent[AVERAGE_KEY])
+               #begin axes box
                control_box.AddStretchSpacer()
-               average_check_box = common.CheckBoxController(self, 'Average', 
parent, AVERAGE_KEY)
-               control_box.Add(average_check_box, 0, wx.EXPAND)
-               control_box.AddSpacer(2)
-               avg_alpha_slider = common.LogSliderController(
-                       self, 'Avg Alpha',
-                       AVG_ALPHA_MIN_EXP, AVG_ALPHA_MAX_EXP, SLIDER_STEPS,
-                       parent, AVG_ALPHA_KEY,
-                       formatter=lambda x: ': %.4f'%x,
+               axes_box = forms.static_box_sizer(
+                       parent=self, sizer=control_box, label='Axes Options',
+                       bold=True, orient=wx.VERTICAL,
                )
-               parent.subscribe(AVERAGE_KEY, avg_alpha_slider.Enable)
-               control_box.Add(avg_alpha_slider, 0, wx.EXPAND)
+               #num lines buttons
+               forms.incr_decr_buttons(
+                       parent=self, sizer=axes_box, label='Time Scale',
+                       on_incr=self._on_incr_time_scale, 
on_decr=self._on_decr_time_scale,
+               )
                #dyanmic range buttons
-               control_box.AddStretchSpacer()
-               control_box.Add(common.LabelText(self, 'Dynamic Range'), 0, 
wx.ALIGN_CENTER)
-               control_box.AddSpacer(2)
-               dynamic_range_buttons = common.IncrDecrButtons(self, 
self._on_incr_dynamic_range, self._on_decr_dynamic_range)
-               control_box.Add(dynamic_range_buttons, 0, wx.ALIGN_CENTER)
+               forms.incr_decr_buttons(
+                       parent=self, sizer=axes_box, label='Dyn Range',
+                       on_incr=self._on_incr_dynamic_range, 
on_decr=self._on_decr_dynamic_range,
+               )
                #ref lvl buttons
-               control_box.AddStretchSpacer()
-               control_box.Add(common.LabelText(self, 'Set Ref Level'), 0, 
wx.ALIGN_CENTER)
-               control_box.AddSpacer(2)
-               ref_lvl_buttons = common.IncrDecrButtons(self, 
self._on_incr_ref_level, self._on_decr_ref_level)
-               control_box.Add(ref_lvl_buttons, 0, wx.ALIGN_CENTER)
-               #num lines buttons
-               control_box.AddStretchSpacer()
-               control_box.Add(common.LabelText(self, 'Set Time Scale'), 0, 
wx.ALIGN_CENTER)
-               control_box.AddSpacer(2)
-               time_scale_buttons = common.IncrDecrButtons(self, 
self._on_incr_time_scale, self._on_decr_time_scale)
-               control_box.Add(time_scale_buttons, 0, wx.ALIGN_CENTER)
+               forms.incr_decr_buttons(
+                       parent=self, sizer=axes_box, label='Ref Level',
+                       on_incr=self._on_incr_ref_level, 
on_decr=self._on_decr_ref_level,
+               )
+               #color mode
+               forms.drop_down(
+                       parent=self, sizer=axes_box, width=100,
+                       ps=parent, key=COLOR_MODE_KEY, label='Color',
+                       choices=map(lambda x: x[1], COLOR_MODES),
+                       labels=map(lambda x: x[0], COLOR_MODES),
+               )
                #autoscale
+               forms.single_button(
+                       parent=self, sizer=axes_box, label='Autoscale',
+                       callback=self.parent.autoscale,
+               )
+               #clear
                control_box.AddStretchSpacer()
-               autoscale_button = wx.Button(self, label='Autoscale', 
style=wx.BU_EXACTFIT)
-               autoscale_button.Bind(wx.EVT_BUTTON, self.parent.autoscale)
-               control_box.Add(autoscale_button, 0, wx.EXPAND)
-               #clear
-               clear_button = wx.Button(self, label='Clear', 
style=wx.BU_EXACTFIT)
-               clear_button.Bind(wx.EVT_BUTTON, self._on_clear_button)
-               control_box.Add(clear_button, 0, wx.EXPAND)
+               forms.single_button(
+                       parent=self, sizer=control_box, label='Clear',
+                       callback=self._on_clear_button,
+               )
                #run/stop
-               run_button = common.ToggleButtonController(self, parent, 
RUNNING_KEY, 'Stop', 'Run')
-               control_box.Add(run_button, 0, wx.EXPAND)
+               forms.toggle_button(
+                       sizer=control_box, parent=self,
+                       true_label='Stop', false_label='Run',
+                       ps=parent, key=RUNNING_KEY,
+               )
                #set sizer
                self.SetSizerAndFit(control_box)
 
@@ -181,18 +203,10 @@
                self.plotter.set_title(title)
                self.plotter.enable_point_label(True)
                self.plotter.enable_grid_lines(False)
-               #setup the box with plot and controls
-               self.control_panel = control_panel(self)
-               main_box = wx.BoxSizer(wx.HORIZONTAL)
-               main_box.Add(self.plotter, 1, wx.EXPAND)
-               main_box.Add(self.control_panel, 0, wx.EXPAND)
-               self.SetSizerAndFit(main_box)
                #plotter listeners
                self.subscribe(COLOR_MODE_KEY, self.plotter.set_color_mode)
                self.subscribe(NUM_LINES_KEY, self.plotter.set_num_lines)
                #initialize values
-               self[AVERAGE_KEY] = self[AVERAGE_KEY]
-               self[AVG_ALPHA_KEY] = self[AVG_ALPHA_KEY]
                self[DYNAMIC_RANGE_KEY] = dynamic_range
                self[NUM_LINES_KEY] = num_lines
                self[Y_DIVS_KEY] = 8
@@ -201,6 +215,12 @@
                self[BASEBAND_FREQ_KEY] = baseband_freq
                self[COLOR_MODE_KEY] = COLOR_MODES[0][1]
                self[RUNNING_KEY] = True
+               #setup the box with plot and controls
+               self.control_panel = control_panel(self)
+               main_box = wx.BoxSizer(wx.HORIZONTAL)
+               main_box.Add(self.plotter, 1, wx.EXPAND)
+               main_box.Add(self.control_panel, 0, wx.EXPAND)
+               self.SetSizerAndFit(main_box)
                #register events
                self.subscribe(MSG_KEY, self.handle_msg)
                for key in (





reply via email to

[Prev in Thread] Current Thread [Next in Thread]