commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r11126 - in gnuradio/branches/developers/jblum/wxgui:


From: jblum
Subject: [Commit-gnuradio] r11126 - in gnuradio/branches/developers/jblum/wxgui: gr-wxgui/src/python/forms grc/data/platforms/python/blocks grc/src/grc_gnuradio/wxgui
Date: Mon, 25 May 2009 19:23:46 -0600 (MDT)

Author: jblum
Date: 2009-05-25 19:23:46 -0600 (Mon, 25 May 2009)
New Revision: 11126

Removed:
   gnuradio/branches/developers/jblum/wxgui/grc/src/grc_gnuradio/wxgui/forms/
Modified:
   gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/forms/forms.py
   
gnuradio/branches/developers/jblum/wxgui/grc/data/platforms/python/blocks/variable_chooser.xml
   
gnuradio/branches/developers/jblum/wxgui/grc/data/platforms/python/blocks/variable_slider.xml
   
gnuradio/branches/developers/jblum/wxgui/grc/data/platforms/python/blocks/variable_text_box.xml
   
gnuradio/branches/developers/jblum/wxgui/grc/src/grc_gnuradio/wxgui/Makefile.am
Log:
Switched grc to use forms module in wxgui.
Added docstrings to forms.py



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 00:36:39 UTC (rev 11125)
+++ gnuradio/branches/developers/jblum/wxgui/gr-wxgui/src/python/forms/forms.py 
2009-05-26 01:23:46 UTC (rev 11126)
@@ -33,6 +33,10 @@
     * provided external access to the user
     * set_value, get_value, and optional callback
     * set and get through optional pubsub and key
+
+Known problems:
+  * An empty label in the radio box still consumes space.
+  * The static text cannot resize the parent at runtime.
 """
 
 EXT_KEY = 'external'
@@ -144,9 +148,47 @@
                        for widget in self._widgets: widget.Disable()
 
 ########################################################################
+# Base Class Chooser Form
+########################################################################
+class _chooser_base(_form_base):
+       def __init__(self, choices=[], labels=None, **kwargs):
+               _form_base.__init__(self, 
converter=converters.chooser_converter(choices), **kwargs)
+               self._choices = choices
+               self._labels = map(str, labels or choices)
+
+########################################################################
+# Base Class Slider Form
+########################################################################
+class _slider_base(_form_base):
+       def __init__(self, label='', length=-1, converter=None, num_steps=100, 
style=wx.SL_HORIZONTAL, **kwargs):
+               _form_base.__init__(self, converter=converter, **kwargs)
+               if style & wx.SL_HORIZONTAL: slider_size = wx.Size(length, -1)
+               elif style & wx.SL_VERTICAL: slider_size = wx.Size(-1, length)
+               else: raise NotImplementedError
+               self._slider = wx.Slider(self._parent, minValue=0, 
maxValue=num_steps, size=slider_size, style=style)
+               self._slider.Bind(wx.EVT_SCROLL, self._handle)
+               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)
+
+########################################################################
 # Static Text Form
 ########################################################################
 class static_text(_form_base):
+       """
+       A text box form.
+       @param parent the parent widget
+       @param sizer add this widget to sizer if provided (optional)
+       @param proportion the proportion when added to the sizer (default=0)
+       @param ps the pubsub object (optional)
+       @param key the pubsub key (optional)
+       @param value the default value (optional)
+       @param label title label for this widget (optional)
+       @param width the width of the form in px
+       @param bold true to bold-ify the text (default=False)
+       @param converter forms.str_converter(), int_converter(), 
float_converter()...
+       """
        def __init__(self, label='', width=-1, bold=False, 
converter=converters.str_converter(), **kwargs):
                _form_base.__init__(self, converter=converter, **kwargs)
                self._static_text = wx.StaticText(self._parent, 
size=wx.Size(width, -1))
@@ -159,6 +201,18 @@
 # Text Box Form
 ########################################################################
 class text_box(_form_base):
+       """
+       A text box form.
+       @param parent the parent widget
+       @param sizer add this widget to sizer if provided (optional)
+       @param proportion the proportion when added to the sizer (default=0)
+       @param ps the pubsub object (optional)
+       @param key the pubsub key (optional)
+       @param value the default value (optional)
+       @param label title label for this widget (optional)
+       @param width the width of the form in px
+       @param converter forms.str_converter(), int_converter(), 
float_converter()...
+       """
        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)
@@ -170,28 +224,26 @@
 
 ########################################################################
 # Slider Form
+#  Linear Slider
+#  Logarithmic Slider
 ########################################################################
-class _slider_base(_form_base):
-       """
-       Base class for linear and log slider.
-       @param length the length of the slider in px
-       @param style wx.SL_HORIZONTAL or wx.SL_VERTICAL
-       """
-       def __init__(self, label='', length=-1, converter=None, num_steps=100, 
style=wx.SL_HORIZONTAL, **kwargs):
-               _form_base.__init__(self, converter=converter, **kwargs)
-               if style & wx.SL_HORIZONTAL: slider_size = wx.Size(length, -1)
-               elif style & wx.SL_VERTICAL: slider_size = wx.Size(-1, length)
-               else: raise NotImplementedError
-               self._slider = wx.Slider(self._parent, minValue=0, 
maxValue=num_steps, size=slider_size, style=style)
-               self._slider.Bind(wx.EVT_SCROLL, self._handle)
-               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)
-
 class slider(_slider_base):
        """
        A generic linear slider.
+       @param parent the parent widget
+       @param sizer add this widget to sizer if provided (optional)
+       @param proportion the proportion when added to the sizer (default=0)
+       @param ps the pubsub object (optional)
+       @param key the pubsub key (optional)
+       @param value the default value (optional)
+       @param label title label for this widget (optional)
+       @param length the length of the slider in px (optional)
+       @param style wx.SL_HORIZONTAL or wx.SL_VERTICAL (default=horizontal)
+       @param minimum the minimum value
+       @param maximum the maximum value
+       @param base the exponent base
+       @param num_steps the number of slider steps (or specify step_size)
+       @param step_size the step between slider jumps (or specify num_steps)
        @param cast a cast function, int, or float (default=float)
        """
        def __init__(self, minimum=-100, maximum=100, num_steps=100, 
step_size=None, cast=float, **kwargs):
@@ -202,7 +254,22 @@
 
 class log_slider(_slider_base):
        """
-       A generic log slider.
+       A generic logarithmic slider.
+       The sliders min and max values are base**min_exp and base**max_exp.
+       @param parent the parent widget
+       @param sizer add this widget to sizer if provided (optional)
+       @param proportion the proportion when added to the sizer (default=0)
+       @param ps the pubsub object (optional)
+       @param key the pubsub key (optional)
+       @param value the default value (optional)
+       @param label title label for this widget (optional)
+       @param length the length of the slider in px (optional)
+       @param style wx.SL_HORIZONTAL or wx.SL_VERTICAL (default=horizontal)
+       @param min_exp the minimum exponent
+       @param max_exp the maximum exponent
+       @param base the exponent base in base**exp
+       @param num_steps the number of slider steps (or specify step_size)
+       @param step_size the exponent step size (or specify num_steps)
        """
        def __init__(self, min_exp=0, max_exp=1, base=10, num_steps=100, 
step_size=None, **kwargs):
                assert step_size or num_steps
@@ -214,6 +281,18 @@
 # Check Box Form
 ########################################################################
 class check_box(_form_base):
+       """
+       Create a check box form.
+       @param parent the parent widget
+       @param sizer add this widget to sizer if provided (optional)
+       @param proportion the proportion when added to the sizer (default=0)
+       @param ps the pubsub object (optional)
+       @param key the pubsub key (optional)
+       @param value the default value (optional)
+       @param true the value for form when checked (default=True)
+       @param false the value for form when unchecked (default=False)
+       @param label title label for this widget (optional)
+       """
        def __init__(self, label='', true=True, false=False, **kwargs):
                _form_base.__init__(self, 
converter=converters.bool_converter(true=true, false=false), **kwargs)
                self._check_box = wx.CheckBox(self._parent, 
style=wx.CHK_2STATE, label=label)
@@ -224,18 +303,21 @@
        def _update(self, checked): self._check_box.SetValue(checked)
 
 ########################################################################
-# Base Class Chooser Form
-########################################################################
-class _chooser_base(_form_base):
-       def __init__(self, choices=[], labels=None, **kwargs):
-               _form_base.__init__(self, 
converter=converters.chooser_converter(choices), **kwargs)
-               self._choices = choices
-               self._labels = map(str, labels or choices)
-
-########################################################################
 # Drop Down Chooser Form
 ########################################################################
 class drop_down(_chooser_base):
+       """
+       Create a drop down menu form.
+       @param parent the parent widget
+       @param sizer add this widget to sizer if provided (optional)
+       @param proportion the proportion when added to the sizer (default=0)
+       @param ps the pubsub object (optional)
+       @param key the pubsub key (optional)
+       @param value the default value (optional)
+       @param choices list of possible values
+       @param labels list of labels for each choice (default=choices)
+       @param label title label for this widget (optional)
+       """
        def __init__(self, label='', **kwargs):
                _chooser_base.__init__(self, **kwargs)
                self._drop_down = wx.Choice(self._parent, choices=self._labels)
@@ -252,6 +334,20 @@
 #  Can be a 2-state button with two choices.
 ########################################################################
 class button(_chooser_base):
+       """
+       Create a multi-state button.
+       @param parent the parent widget
+       @param sizer add this widget to sizer if provided (optional)
+       @param proportion the proportion when added to the sizer (default=0)
+       @param ps the pubsub object (optional)
+       @param key the pubsub key (optional)
+       @param value the default value (optional)
+       @param choices list of possible values
+       @param labels list of labels for each choice (default=choices)
+       @param width the width of the button in pixels (optional)
+       @param style style arguments (optional)
+       @param label title label for this widget (optional)
+       """
        def __init__(self, label='', style=0, width=-1, **kwargs):
                _chooser_base.__init__(self, **kwargs)
                self._button = wx.Button(self._parent, size=wx.Size(width, -1), 
style=style)
@@ -263,8 +359,18 @@
 
 class toggle_button(button):
        """
-       Create a dual state button.
+       Create a dual-state button.
        This button will alternate between True and False when clicked.
+       @param parent the parent widget
+       @param sizer add this widget to sizer if provided (optional)
+       @param proportion the proportion when added to the sizer (default=0)
+       @param ps the pubsub object (optional)
+       @param key the pubsub key (optional)
+       @param value the default value (optional)
+       @param width the width of the button in pixels (optional)
+       @param style style arguments (optional)
+       @param true_label the button's label in the true state
+       @param false_label the button's label in the false state
        """
        def __init__(self, true_label='On (click to stop)', false_label='Off 
(click to start)', **kwargs):
                button.__init__(self, choices=[True, False], 
labels=[true_label, false_label], **kwargs)
@@ -274,6 +380,15 @@
        Create a single state button.
        This button will callback() when clicked.
        For use when state holding is not important.
+       @param parent the parent widget
+       @param sizer add this widget to sizer if provided (optional)
+       @param proportion the proportion when added to the sizer (default=0)
+       @param ps the pubsub object (optional)
+       @param key the pubsub key (optional)
+       @param value the default value (optional)
+       @param width the width of the button in pixels (optional)
+       @param style style arguments (optional)
+       @param label the button's label
        """
        def __init__(self, label='click for callback', **kwargs):
                toggle_button.__init__(self, true_label=label, 
false_label=label, value=True, **kwargs)

Modified: 
gnuradio/branches/developers/jblum/wxgui/grc/data/platforms/python/blocks/variable_chooser.xml
===================================================================
--- 
gnuradio/branches/developers/jblum/wxgui/grc/data/platforms/python/blocks/variable_chooser.xml
      2009-05-26 00:36:39 UTC (rev 11125)
+++ 
gnuradio/branches/developers/jblum/wxgui/grc/data/platforms/python/blocks/variable_chooser.xml
      2009-05-26 01:23:46 UTC (rev 11126)
@@ -9,7 +9,7 @@
 <block>
        <name>Variable Chooser</name>
        <key>variable_chooser</key>
-       <import>from grc_gnuradio.wxgui import forms</import>
+       <import>from gnuradio.wxgui import forms</import>
        <make>$value
 self['$id'] = $id
 self.subscribe('$id', self.set_$(id))

Modified: 
gnuradio/branches/developers/jblum/wxgui/grc/data/platforms/python/blocks/variable_slider.xml
===================================================================
--- 
gnuradio/branches/developers/jblum/wxgui/grc/data/platforms/python/blocks/variable_slider.xml
       2009-05-26 00:36:39 UTC (rev 11125)
+++ 
gnuradio/branches/developers/jblum/wxgui/grc/data/platforms/python/blocks/variable_slider.xml
       2009-05-26 01:23:46 UTC (rev 11126)
@@ -8,7 +8,7 @@
 <block>
        <name>Variable Slider</name>
        <key>variable_slider</key>
-       <import>from grc_gnuradio.wxgui import forms</import>
+       <import>from gnuradio.wxgui import forms</import>
        <make>$value
 self['$id'] = $id
 self.subscribe('$id', self.set_$(id))

Modified: 
gnuradio/branches/developers/jblum/wxgui/grc/data/platforms/python/blocks/variable_text_box.xml
===================================================================
--- 
gnuradio/branches/developers/jblum/wxgui/grc/data/platforms/python/blocks/variable_text_box.xml
     2009-05-26 00:36:39 UTC (rev 11125)
+++ 
gnuradio/branches/developers/jblum/wxgui/grc/data/platforms/python/blocks/variable_text_box.xml
     2009-05-26 01:23:46 UTC (rev 11126)
@@ -8,7 +8,7 @@
 <block>
        <name>Variable Text Box</name>
        <key>variable_text_box</key>
-       <import>from grc_gnuradio.wxgui import forms</import>
+       <import>from gnuradio.wxgui import forms</import>
        <make>$value
 self['$id'] = $id
 self.subscribe('$id', self.set_$(id))

Modified: 
gnuradio/branches/developers/jblum/wxgui/grc/src/grc_gnuradio/wxgui/Makefile.am
===================================================================
--- 
gnuradio/branches/developers/jblum/wxgui/grc/src/grc_gnuradio/wxgui/Makefile.am 
    2009-05-26 00:36:39 UTC (rev 11125)
+++ 
gnuradio/branches/developers/jblum/wxgui/grc/src/grc_gnuradio/wxgui/Makefile.am 
    2009-05-26 01:23:46 UTC (rev 11126)
@@ -25,9 +25,3 @@
 ourpython_PYTHON = \
        __init__.py \
        top_block_gui.py
-
-oursubpythondir = $(grc_gnuradio_prefix)/wxgui/forms
-oursubpython_PYTHON = \
-       forms/__init__.py \
-       forms/converters.py \
-       forms/forms.py





reply via email to

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