Added window size param to all wxgui wrappers.
authorJosh Blum <josh@joshknows.com>
Fri, 9 Oct 2009 20:26:30 +0000 (13:26 -0700)
committerJosh Blum <josh@joshknows.com>
Fri, 9 Oct 2009 20:26:30 +0000 (13:26 -0700)
Modified type parser to allow blank values in vector types as empty vectors.

grc/blocks/wxgui_constellationsink2.xml
grc/blocks/wxgui_fftsink2.xml
grc/blocks/wxgui_histosink2.xml
grc/blocks/wxgui_numbersink2.xml
grc/blocks/wxgui_scopesink2.xml
grc/blocks/wxgui_waterfallsink2.xml
grc/python/Param.py

index 5969d8405322138bc227aeda083bb52c964bc976..598b550642d1dbeb321be11f1e317d5c68970aea 100644 (file)
@@ -23,6 +23,9 @@ constsink_gl.const_sink_c(
        gain_mu=$gain_mu,
        symbol_rate=$symbol_rate,
        omega_limit=$omega_limit,
+#if $win_size()
+       size=$win_size,
+#end if
 )
 #if not $grid_pos()
 $(parent).Add(self.$(id).win)
@@ -102,6 +105,13 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
                <value>0.005</value>
                <type>real</type>
        </param>
+       <param>
+               <name>Window Size</name>
+               <key>win_size</key>
+               <value></value>
+               <type>int_vector</type>
+               <hide>#if $win_size() then 'none' else 'part'#</hide>
+       </param>
        <param>
                <name>Grid Position</name>
                <key>grid_pos</key>
@@ -114,11 +124,14 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
                <value></value>
                <type>notebook</type>
        </param>
+       <check>not $win_size or len($win_size) == 2</check>
        <sink>
                <name>in</name>
                <type>complex</type>
        </sink>
        <doc>
+Leave the window blank for the default size, otherwise enter a tuple of (width, height) pixels.
+
 Use the Grid Position (row, column, row span, column span) to position the graphical element in the window.
 
 Use the Notebook Param (notebook-id, page-index) to place the graphical element inside of a notebook page.
index 6f19f1aa47d3e8c41725791a43da29db4d663006..42bca5ccf3174d82f0152e2d7ded2d802416a4db 100644 (file)
@@ -23,6 +23,9 @@ fftsink2.$(type.fcn)(
        avg_alpha=#if $avg_alpha() then $avg_alpha else 'None'#,
        title=$title,
        peak_hold=$peak_hold,
+#if $win_size()
+       size=$win_size,
+#end if
 )
 #if not $grid_pos()
 $(parent).Add(self.$(id).win)
@@ -158,6 +161,13 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
                <type>real</type>
                <hide>#if $average() == 'True' then 'none' else 'all'#</hide>
        </param>
+       <param>
+               <name>Window Size</name>
+               <key>win_size</key>
+               <value></value>
+               <type>int_vector</type>
+               <hide>#if $win_size() then 'none' else 'part'#</hide>
+       </param>
        <param>
                <name>Grid Position</name>
                <key>grid_pos</key>
@@ -170,6 +180,7 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
                <value></value>
                <type>notebook</type>
        </param>
+       <check>not $win_size or len($win_size) == 2</check>
        <sink>
                <name>in</name>
                <type>$type</type>
@@ -177,6 +188,8 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
        <doc>
 Set Average Alpha to 0 for automatic setting.
 
+Leave the window blank for the default size, otherwise enter a tuple of (width, height) pixels.
+
 Use the Grid Position (row, column, row span, column span) to position the graphical element in the window.
 
 Use the Notebook Param (notebook-id, page-index) to place the graphical element inside of a notebook page.
index 454a4932cfab4aefbd5d00e93c674ec08537a492..9edf9650d849575de9ee471cb706d5604cb856e4 100644 (file)
@@ -14,6 +14,9 @@ histosink_gl.histo_sink_f(
        title=$title,
        num_bins=$num_bins,
        frame_size=$frame_size,
+#if $win_size()
+       size=$win_size,
+#end if
 )
 #if not $grid_pos()
 $(parent).Add(self.$(id).win)
@@ -40,6 +43,13 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
                <value>1000</value>
                <type>int</type>
        </param>
+       <param>
+               <name>Window Size</name>
+               <key>win_size</key>
+               <value></value>
+               <type>int_vector</type>
+               <hide>#if $win_size() then 'none' else 'part'#</hide>
+       </param>
        <param>
                <name>Grid Position</name>
                <key>grid_pos</key>
@@ -52,11 +62,14 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
                <value></value>
                <type>notebook</type>
        </param>
+       <check>not $win_size or len($win_size) == 2</check>
        <sink>
                <name>in</name>
                <type>float</type>
        </sink>
        <doc>
+Leave the window blank for the default size, otherwise enter a tuple of (width, height) pixels.
+
 Use the Grid Position (row, column, row span, column span) to position the graphical element in the window.
 
 Use the Notebook Param (notebook-id, page-index) to place the graphical element inside of a notebook page.
index cc66cdcb088e75d2d7fc820e2cf3dddd8f3f3b2d..5289db8af9f1351338a886e30aa077054fdde9f2 100644 (file)
@@ -24,6 +24,9 @@ numbersink2.$(type.fcn)(
        label=$title,
        peak_hold=$peak_hold,
        show_gauge=$show_gauge,
+#if $win_size()
+       size=$win_size,
+#end if
 )
 #if not $grid_pos()
 $(parent).Add(self.$(id).win)
@@ -151,6 +154,13 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
                        <key>False</key>
                </option>
        </param>
+       <param>
+               <name>Window Size</name>
+               <key>win_size</key>
+               <value></value>
+               <type>int_vector</type>
+               <hide>#if $win_size() then 'none' else 'part'#</hide>
+       </param>
        <param>
                <name>Grid Position</name>
                <key>grid_pos</key>
@@ -163,6 +173,7 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
                <value></value>
                <type>notebook</type>
        </param>
+       <check>not $win_size or len($win_size) == 2</check>
        <sink>
                <name>in</name>
                <type>$type</type>
@@ -170,6 +181,8 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
        <doc>
 Set Average Alpha to 0 for automatic setting.
 
+Leave the window blank for the default size, otherwise enter a tuple of (width, height) pixels.
+
 Use the Grid Position (row, column, row span, column span) to position the graphical element in the window.
 
 Use the Notebook Param (notebook-id, page-index) to place the graphical element inside of a notebook page.
index 503d529727662578e219011abf2117c6c8e574aa..07d29ce8fffc0ddeb68ff9b8fa7e7d7717b28a61 100644 (file)
@@ -19,6 +19,9 @@ scopesink2.$(type.fcn)(
        ac_couple=$ac_couple,
        xy_mode=$xy_mode,
        num_inputs=$num_inputs,
+#if $win_size()
+       size=$win_size,
+#end if
 )
 #if not $grid_pos()
 $(parent).Add(self.$(id).win)
@@ -102,6 +105,13 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
                <value>1</value>
                <type>int</type>
        </param>
+       <param>
+               <name>Window Size</name>
+               <key>win_size</key>
+               <value></value>
+               <type>int_vector</type>
+               <hide>#if $win_size() then 'none' else 'part'#</hide>
+       </param>
        <param>
                <name>Grid Position</name>
                <key>grid_pos</key>
@@ -114,6 +124,7 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
                <value></value>
                <type>notebook</type>
        </param>
+       <check>not $win_size or len($win_size) == 2</check>
        <check>not $xy_mode or '$type' == 'complex' or $num_inputs != 1</check>
        <sink>
                <name>in</name>
@@ -127,6 +138,8 @@ Set the T Scale to 0 for automatic setting.
 
 XY Mode allows the scope to initialize as an XY plotter.
 
+Leave the window blank for the default size, otherwise enter a tuple of (width, height) pixels.
+
 Use the Grid Position (row, column, row span, column span) to position the graphical element in the window.
 
 Use the Notebook Param (notebook-id, page-index) to place the graphical element inside of a notebook page.
index 35790f820b716b68de105d983bcf4b5521f213ba..cee598990e230da499006ff0658eadbec114f4a2 100644 (file)
@@ -21,6 +21,9 @@ waterfallsink2.$(type.fcn)(
        average=$options.average,
        avg_alpha=#if $avg_alpha() then $avg_alpha else 'None'#,
        title=$title,
+#if $win_size()
+       size=$win_size,
+#end if
 )
 #if not $grid_pos()
 $(parent).Add(self.$(id).win)
@@ -115,6 +118,13 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
                        <opt>average:True</opt>
                </option>
        </param>
+       <param>
+               <name>Window Size</name>
+               <key>win_size</key>
+               <value></value>
+               <type>int_vector</type>
+               <hide>#if $win_size() then 'none' else 'part'#</hide>
+       </param>
        <param>
                <name>Grid Position</name>
                <key>grid_pos</key>
@@ -127,6 +137,7 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
                <value></value>
                <type>notebook</type>
        </param>
+       <check>not $win_size or len($win_size) == 2</check>
        <sink>
                <name>in</name>
                <type>$type</type>
@@ -134,6 +145,8 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
        <doc>
 Set Average Alpha to 0 for automatic setting.
 
+Leave the window blank for the default size, otherwise enter a tuple of (width, height) pixels.
+
 Use the Grid Position (row, column, row span, column span) to position the graphical element in the window.
 
 Use the Notebook Param (notebook-id, page-index) to place the graphical element inside of a notebook page.
index 34d5ab116b07e629f16ecf0d70c29361a16579da..81fb6ba7acb7b48407fc2197099223a7a6780fe5 100644 (file)
@@ -251,7 +251,7 @@ class Param(_Param, _GUIParam):
                #########################
                # Numeric Types
                #########################
-               elif t in ('raw', 'complex', 'real', 'int', 'complex_vector', 'real_vector', 'int_vector', 'hex', 'bool'):
+               elif t in ('raw', 'complex', 'real', 'int', 'hex', 'bool'):
                        #raise exception if python cannot evaluate this value
                        try: e = self.get_parent().get_parent().evaluate(v)
                        except Exception, e: raise Exception, 'Value "%s" cannot be evaluated:\n%s'%(v, e)
@@ -269,10 +269,22 @@ class Param(_Param, _GUIParam):
                                try: assert isinstance(e, INT_TYPES)
                                except AssertionError: raise Exception, 'Expression "%s" is invalid for type integer.'%str(e)
                                return e
-                       #########################
-                       # Numeric Vector Types
-                       #########################
-                       elif t == 'complex_vector':
+                       elif t == 'hex': return hex(e)
+                       elif t == 'bool':
+                               try: assert isinstance(e, bool)
+                               except AssertionError: raise Exception, 'Expression "%s" is invalid for type bool.'%str(e)
+                               return e
+                       else: raise TypeError, 'Type "%s" not handled'%t
+               #########################
+               # Numeric Vector Types
+               #########################
+               elif t in ('complex_vector', 'real_vector', 'int_vector'):
+                       if not v: v = '()' #turn a blank string into an empty list, so it will eval
+                       #raise exception if python cannot evaluate this value
+                       try: e = self.get_parent().get_parent().evaluate(v)
+                       except Exception, e: raise Exception, 'Value "%s" cannot be evaluated:\n%s'%(v, e)
+                       #raise an exception if the data is invalid
+                       if t == 'complex_vector':
                                if not isinstance(e, VECTOR_TYPES):
                                        self._lisitify_flag = True
                                        e = [e]
@@ -296,12 +308,6 @@ class Param(_Param, _GUIParam):
                                        for ei in e: assert isinstance(ei, INT_TYPES)
                                except AssertionError: raise Exception, 'Expression "%s" is invalid for type integer vector.'%str(e)
                                return e
-                       elif t == 'hex': return hex(e)
-                       elif t == 'bool':
-                               try: assert isinstance(e, bool)
-                               except AssertionError: raise Exception, 'Expression "%s" is invalid for type bool.'%str(e)
-                               return e
-                       else: raise TypeError, 'Type "%s" not handled'%t
                #########################
                # String Types
                #########################