commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r10727 - in gnuradio/branches/developers/jblum/grc/grc


From: jblum
Subject: [Commit-gnuradio] r10727 - in gnuradio/branches/developers/jblum/grc/grc: data/platforms/python data/platforms/python/blocks src/grc_gnuradio/wxgui src/platforms/python
Date: Tue, 31 Mar 2009 19:25:12 -0600 (MDT)

Author: jblum
Date: 2009-03-31 19:25:11 -0600 (Tue, 31 Mar 2009)
New Revision: 10727

Modified:
   
gnuradio/branches/developers/jblum/grc/grc/data/platforms/python/blocks/variable_chooser.xml
   
gnuradio/branches/developers/jblum/grc/grc/data/platforms/python/blocks/variable_slider.xml
   
gnuradio/branches/developers/jblum/grc/grc/data/platforms/python/blocks/variable_text_box.xml
   
gnuradio/branches/developers/jblum/grc/grc/data/platforms/python/flow_graph.tmpl
   gnuradio/branches/developers/jblum/grc/grc/src/grc_gnuradio/wxgui/__init__.py
   
gnuradio/branches/developers/jblum/grc/grc/src/grc_gnuradio/wxgui/callback_controls.py
   gnuradio/branches/developers/jblum/grc/grc/src/platforms/python/FlowGraph.py
Log:
Work on the grc callback controls, and related.
Actual controls will be replaced by new forms.py
In the meantime, this work is a step towards that direction.



Modified: 
gnuradio/branches/developers/jblum/grc/grc/data/platforms/python/blocks/variable_chooser.xml
===================================================================
--- 
gnuradio/branches/developers/jblum/grc/grc/data/platforms/python/blocks/variable_chooser.xml
        2009-04-01 01:01:28 UTC (rev 10726)
+++ 
gnuradio/branches/developers/jblum/grc/grc/data/platforms/python/blocks/variable_chooser.xml
        2009-04-01 01:25:11 UTC (rev 10727)
@@ -7,24 +7,27 @@
 <block>
        <name>Variable Chooser</name>
        <key>variable_chooser</key>
-       <make>$(choices)[$value_index]
-_$(id)_control = grc_wxgui.$(chooser_type)_control(
+       <make>$value
+self._$(id)_control = grc_wxgui.$(type)_control(
        window=self.GetWin(),
        callback=self.set_$(id),
-               #if $label.eval
+       #if $label.eval
        label=$label,
-               #else
+       #else
        label='$id',
-               #end if
-       index=$value_index,
+       #end if
+       value=$value,
        choices=$choices,
        labels=$labels,
+#if $type.eval == 'radio_buttons'
+       style=$style,
+#end if
 )
 #set $grid_pos = $grid_pos.eval
 #if not grid_pos
-self.Add(_$(id)_control)
+self.Add(self._$(id)_control)
 #else
-self.GridAdd(_$(id)_control, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])
+self.GridAdd(self._$(id)_control, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])
 #end if</make>
        <param>
                <name>Label</name>
@@ -33,10 +36,10 @@
                <type>string</type>
        </param>
        <param>
-               <name>Value Index</name>
-               <key>value_index</key>
-               <value>0</value>
-               <type>int</type>
+               <name>Default Value</name>
+               <key>value</key>
+               <value>1</value>
+               <type>raw</type>
        </param>
        <param>
                <name>Choices</name>
@@ -51,8 +54,8 @@
                <type>raw</type>
        </param>
        <param>
-               <name>Chooser Type</name>
-               <key>chooser_type</key>
+               <name>Type</name>
+               <key>type</key>
                <value>drop_down</value>
                <type>enum</type>
                <option>
@@ -60,25 +63,36 @@
                        <key>drop_down</key>
                </option>
                <option>
-                       <name>Radio Buttons Horizontal</name>
-                       <key>radio_buttons_horizontal</key>
+                       <name>Radio Buttons</name>
+                       <key>radio_buttons</key>
                </option>
                <option>
-                       <name>Radio Buttons Vertical</name>
-                       <key>radio_buttons_vertical</key>
-               </option>
-               <option>
                        <name>Button</name>
                        <key>button</key>
                </option>
        </param>
        <param>
+               <name>Style</name>
+               <key>style</key>
+               <value>wx.HORIZONTAL</value>
+               <type>enum</type>
+               <hide>#if $type.eval == 'radio_buttons' then 'part' else 
'all'#</hide>
+               <option>
+                       <name>Horizontal</name>
+                       <key>wx.HORIZONTAL</key>
+               </option>
+               <option>
+                       <name>Vertical</name>
+                       <key>wx.VERTICAL</key>
+               </option>
+       </param>
+       <param>
                <name>Grid Position</name>
                <key>grid_pos</key>
                <value></value>
                <type>grid_pos</type>
        </param>
-       <check>$value_index in range(len($choices))</check>
+       <check>$value in $choices</check>
        <check>not $labels or len($labels) == len($choices)</check>
        <doc>
 This block creates a variable with a drop down, radio buttons, or a button. \

Modified: 
gnuradio/branches/developers/jblum/grc/grc/data/platforms/python/blocks/variable_slider.xml
===================================================================
--- 
gnuradio/branches/developers/jblum/grc/grc/data/platforms/python/blocks/variable_slider.xml
 2009-04-01 01:01:28 UTC (rev 10726)
+++ 
gnuradio/branches/developers/jblum/grc/grc/data/platforms/python/blocks/variable_slider.xml
 2009-04-01 01:25:11 UTC (rev 10727)
@@ -8,25 +8,26 @@
        <name>Variable Slider</name>
        <key>variable_slider</key>
        <make>$value
-_$(id)_control = grc_wxgui.slider_$(slider_type)_control(
+self._$(id)_control = grc_wxgui.slider_control(
        window=self.GetWin(),
        callback=self.set_$(id),
-               #if $label.eval
+       #if $label.eval
        label=$label,
-               #else
+       #else
        label='$id',
-               #end if
+       #end if
        value=$id,
        min=$min,
        max=$max,
        num_steps=$num_steps,
        slider_length=$slider_length,
+       style=$style,
 )
 #set $grid_pos = $grid_pos.eval
 #if not grid_pos
-self.Add(_$(id)_control)
+self.Add(self._$(id)_control)
 #else
-self.GridAdd(_$(id)_control, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])
+self.GridAdd(self._$(id)_control, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])
 #end if</make>
        <param>
                <name>Label</name>
@@ -67,17 +68,18 @@
                <hide>part</hide>
        </param>
        <param>
-               <name>Slider Type</name>
-               <key>slider_type</key>
-               <value>horizontal</value>
+               <name>Style</name>
+               <key>style</key>
+               <value>wx.HORIZONTAL</value>
                <type>enum</type>
+               <hide>part</hide>
                <option>
                        <name>Horizontal</name>
-                       <key>horizontal</key>
+                       <key>wx.HORIZONTAL</key>
                </option>
                <option>
                        <name>Vertical</name>
-                       <key>vertical</key>
+                       <key>wx.VERTICAL</key>
                </option>
        </param>
        <param>

Modified: 
gnuradio/branches/developers/jblum/grc/grc/data/platforms/python/blocks/variable_text_box.xml
===================================================================
--- 
gnuradio/branches/developers/jblum/grc/grc/data/platforms/python/blocks/variable_text_box.xml
       2009-04-01 01:01:28 UTC (rev 10726)
+++ 
gnuradio/branches/developers/jblum/grc/grc/data/platforms/python/blocks/variable_text_box.xml
       2009-04-01 01:25:11 UTC (rev 10727)
@@ -8,21 +8,21 @@
        <name>Variable Text Box</name>
        <key>variable_text_box</key>
        <make>$value
-_$(id)_control = grc_wxgui.text_box_control(
+self._$(id)_control = grc_wxgui.text_box_control(
        window=self.GetWin(),
        callback=self.set_$(id),
-               #if $label.eval
+       #if $label.eval
        label=$label,
-               #else
+       #else
        label='$id',
-               #end if
+       #end if
        value=$id,
 )
 #set $grid_pos = $grid_pos.eval
 #if not grid_pos
-self.Add(_$(id)_control)
+self.Add(self._$(id)_control)
 #else
-self.GridAdd(_$(id)_control, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])
+self.GridAdd(self._$(id)_control, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])
 #end if</make>
        <param>
                <name>Label</name>

Modified: 
gnuradio/branches/developers/jblum/grc/grc/data/platforms/python/flow_graph.tmpl
===================================================================
--- 
gnuradio/branches/developers/jblum/grc/grc/data/platforms/python/flow_graph.tmpl
    2009-04-01 01:01:28 UTC (rev 10726)
+++ 
gnuradio/branches/developers/jblum/grc/grc/data/platforms/python/flow_graph.tmpl
    2009-04-01 01:25:11 UTC (rev 10727)
@@ -170,6 +170,9 @@
        #for $callback in $var_id2cbs[$id]
                self.$callback
        #end for
+       #if $var.get_key() in ('variable_chooser', 'variable_slider', 
'variable_text_box')
+               self._$(id)_control.set_value(self.$id)
+       #end if
 
 #end for
 ########################################################

Modified: 
gnuradio/branches/developers/jblum/grc/grc/src/grc_gnuradio/wxgui/__init__.py
===================================================================
--- 
gnuradio/branches/developers/jblum/grc/grc/src/grc_gnuradio/wxgui/__init__.py   
    2009-04-01 01:01:28 UTC (rev 10726)
+++ 
gnuradio/branches/developers/jblum/grc/grc/src/grc_gnuradio/wxgui/__init__.py   
    2009-04-01 01:25:11 UTC (rev 10727)
@@ -21,9 +21,7 @@
 from callback_controls import \
        button_control, \
        drop_down_control, \
-       radio_buttons_horizontal_control, \
-       radio_buttons_vertical_control, \
-       slider_horizontal_control, \
-       slider_vertical_control, \
+       radio_buttons_control, \
+       slider_control, \
        text_box_control
 from top_block_gui import top_block_gui

Modified: 
gnuradio/branches/developers/jblum/grc/grc/src/grc_gnuradio/wxgui/callback_controls.py
===================================================================
--- 
gnuradio/branches/developers/jblum/grc/grc/src/grc_gnuradio/wxgui/callback_controls.py
      2009-04-01 01:01:28 UTC (rev 10726)
+++ 
gnuradio/branches/developers/jblum/grc/grc/src/grc_gnuradio/wxgui/callback_controls.py
      2009-04-01 01:25:11 UTC (rev 10727)
@@ -35,56 +35,44 @@
        """Control base class"""
 
        def __init__(self, window, callback):
-               self.window = window
-               self.callback = callback
+               self._window = window
+               self._callback = callback
                wx.BoxSizer.__init__(self, wx.VERTICAL)
 
-       def get_window(self): return self.window
-
-       def call(self): return self.callback(self.get_value())
-
+       def get_window(self): return self._window
+       def call(self): self._callback(self.get_value())
        def get_value(self): raise NotImplementedError
-
        def set_value(self): raise NotImplementedError
 
 class _chooser_control_base(_control_base):
        """House a drop down or radio buttons for variable control."""
 
-       def __init__(self, window, callback, label='Label', index=0, 
choices=[0], labels=[]):
+       def __init__(self, window, callback, label='Label', value=0, 
choices=[0], labels=[], style=None):
                """
                Chooser contructor.
                Create the slider, text box, and label.
                @param window the wx parent window
                @param callback call the callback on changes
                @param label the label title
-               @param index the default choice index
+               @param value the default choice
                @param choices a list of choices
                @param labels the choice labels or empty list
+               @param style optional wx style flags
                """
                #initialize
                _control_base.__init__(self, window, callback)
                label_text = LabelText(self.get_window(), label)
                self.Add(label_text, 0, wx.ALIGN_CENTER)
-               self.index = index
-               self.choices = choices
-               self.labels = map(str, labels or choices)
+               self._choices = choices
+               self._labels = map(str, labels or choices)
+               self._style = style
                self._init()
+               self.set_value(value)
 
-       def _handle_changed(self, event=None):
-               """
-               A change is detected. Call the callback.
-               """
-               try: self.call()
-               except Exception, e: print >> sys.stderr, 'Error in exec 
callback from handle changed.\n', e
+       def call(self):
+               try: _control_base.call(self)
+               except Exception, e: print >> sys.stderr, 'Error in exec 
callback from handler.\n', e
 
-       def get_value(self):
-               """
-               Update the chooser.
-               @return one of the possible choices
-               """
-               self._update()
-               return self.choices[self.index]
-
 
##############################################################################################
 # Button Control
 
##############################################################################################
@@ -92,14 +80,23 @@
        """House a button for variable control."""
 
        def _init(self):
-               self.button = wx.Button(self.get_window(), 
label=self.labels[self.index])
-               self.button.Bind(wx.EVT_BUTTON, self._handle_changed)
-               self.Add(self.button, 0, wx.ALIGN_CENTER)
+               self._button = wx.Button(self.get_window())
+               self._button.Bind(wx.EVT_BUTTON, lambda evt: self.call())
+               self.Add(self._button, 0, wx.ALIGN_CENTER)
 
-       def _update(self):
-               self.index = (self.index + 1)%len(self.choices) #circularly 
increment index
-               self.button.SetLabel(self.labels[self.index])
+       def call(self):
+               self.set_value(self._choices[(self._index + 
1)%len(self._choices)]) #circularly increment index
+               _chooser_control_base.call(self)
 
+       def get_value(self):
+               return self._choices[self._index]
+
+       def set_value(self, value):
+               try:
+                       self._index = self._choices.index(value)
+                       self._button.SetLabel(self._labels[self._index])
+               except ValueError: pass
+
 
##############################################################################################
 # Drop Down Control
 
##############################################################################################
@@ -107,55 +104,44 @@
        """House a drop down for variable control."""
 
        def _init(self):
-               self.drop_down = wx.Choice(self.get_window(), 
choices=self.labels)
-               self.Add(self.drop_down, 0, wx.ALIGN_CENTER)
-               self.drop_down.Bind(wx.EVT_CHOICE, self._handle_changed)
-               self.drop_down.SetSelection(self.index)
+               self._drop_down = wx.Choice(self.get_window(), 
choices=self._labels)
+               self.Add(self._drop_down, 0, wx.ALIGN_CENTER)
+               self._drop_down.Bind(wx.EVT_CHOICE, lambda evt: self.call())
 
-       def _update(self):
-               self.index = self.drop_down.GetSelection()
+       def get_value(self):
+               return self._choices[self._drop_down.GetSelection()]
 
+       def set_value(self, value):
+               try: self._drop_down.SetSelection(self._choices.index(value))
+               except ValueError: pass
+
 
##############################################################################################
 # Radio Buttons Control
 
##############################################################################################
-class _radio_buttons_control_base(_chooser_control_base):
+class radio_buttons_control(_chooser_control_base):
        """House radio buttons for variable control."""
 
        def _init(self):
-               #create box for radio buttons
-               radio_box = wx.BoxSizer(self.radio_box_orientation)
-               panel = wx.Panel(self.get_window())
-               panel.SetSizer(radio_box)
-               self.Add(panel, 0, wx.ALIGN_CENTER)
-               #create radio buttons
-               self.radio_buttons = list()
-               for label in self.labels:
-                       radio_button = wx.RadioButton(panel, label=label)
-                       radio_button.SetValue(False)
-                       self.radio_buttons.append(radio_button)
-                       radio_box.Add(radio_button, 0, self.radio_button_align)
-                       radio_button.Bind(wx.EVT_RADIOBUTTON, 
self._handle_changed)
-               #set one radio button active
-               self.radio_buttons[self.index].SetValue(True)
+               if self._style is None: self._style = wx.VERTICAL
+               radio_box_style = {wx.HORIZONTAL: wx.RA_HORIZONTAL, 
wx.VERTICAL: wx.RA_VERTICAL}[self._style] | wx.NO_BORDER
+               self._radio_buttons = wx.RadioBox(self.get_window(), 
choices=self._labels, style=radio_box_style)
+               self.Add(self._radio_buttons, 0, wx.ALIGN_CENTER)
+               self._radio_buttons.Bind(wx.EVT_RADIOBOX, lambda evt: 
self.call())
 
-       def _update(self):
-               selected_radio_button = filter(lambda rb: rb.GetValue(), 
self.radio_buttons)[0]
-               self.index = self.radio_buttons.index(selected_radio_button)
+       def get_value(self):
+               return self._choices[self._radio_buttons.GetSelection()]
 
-class radio_buttons_horizontal_control(_radio_buttons_control_base):
-       radio_box_orientation = wx.HORIZONTAL
-       radio_button_align = wx.ALIGN_CENTER
-class radio_buttons_vertical_control(_radio_buttons_control_base):
-       radio_box_orientation = wx.VERTICAL
-       radio_button_align = wx.ALIGN_LEFT
+       def set_value(self, value):
+               try: 
self._radio_buttons.SetSelection(self._choices.index(value))
+               except ValueError: pass
 
 
##############################################################################################
 # Slider Control
 
##############################################################################################
-class _slider_control_base(_control_base):
+class slider_control(_control_base):
        """House a Slider and a Text Box for variable control."""
 
-       def __init__(self, window, callback, label='Label', value=50, min=0, 
max=100, num_steps=100, slider_length=200):
+       def __init__(self, window, callback, label='Label', value=50, min=0, 
max=100, num_steps=100, slider_length=200, style=wx.HORIZONTAL):
                """
                Slider contructor.
                Create the slider, text box, and label.
@@ -173,23 +159,25 @@
                self.min = float(min)
                self.max = float(max)
                self.num_steps = int(num_steps)
-               self.slider_length = slider_length
+               self._slider_length = slider_length
                #create gui elements
-               label_text_sizer = wx.BoxSizer(self.label_text_orientation) 
#label and text box container
+               label_text_sizer = wx.BoxSizer(style) #label and text box 
container
                label_text = LabelText(self.get_window(), '%s: '%str(label))
-               self.text_box = text_box = wx.TextCtrl(self.get_window(), 
style=wx.TE_PROCESS_ENTER)
+               self._text_box = text_box = wx.TextCtrl(self.get_window(), 
style=wx.TE_PROCESS_ENTER)
                text_box.Bind(wx.EVT_TEXT_ENTER, self._handle_enter) #bind this 
special enter hotkey event
                for obj in (label_text, text_box): #fill the container with 
label and text entry box
                        label_text_sizer.Add(obj, 0, wx.ALIGN_CENTER)
                self.Add(label_text_sizer, 0, wx.ALIGN_CENTER)
                #make the slider
-               self.slider = slider = wx.Slider(self.get_window(), 
size=wx.Size(*self.get_slider_size()), style=self.slider_style)
-               try: slider.SetRange(0, num_steps)
+               slider_style = {wx.HORIZONTAL: wx.SL_HORIZONTAL, wx.VERTICAL: 
wx.SL_VERTICAL}[style]
+               slider_size = {wx.HORIZONTAL: (slider_length, -1), wx.VERTICAL: 
(-1, slider_length)}[style]
+               self._slider = wx.Slider(self.get_window(), 
size=wx.Size(*slider_size), style=slider_style)
+               try: self._slider.SetRange(0, num_steps)
                except Exception, e:
                        print >> sys.stderr, 'Error in set slider range: 
"%s".'%e
                        exit(-1)
-               slider.Bind(wx.EVT_SCROLL, self._handle_scroll) #bind the 
scrolling event
-               self.Add(slider, 0, wx.ALIGN_CENTER)
+               self._slider.Bind(wx.EVT_SCROLL, self._handle_scroll) #bind the 
scrolling event
+               self.Add(self._slider, 0, wx.ALIGN_CENTER)
                #init slider and text box
                self.set_value(value)
 
@@ -214,20 +202,20 @@
                Translate the real numerical value into a slider value.
                """
                slider_value = (float(self.get_value()) - 
self.min)*self.num_steps/(self.max - self.min)
-               self.slider.SetValue(slider_value)
+               self._slider.SetValue(slider_value)
 
        def _update_text_box(self):
                """
                Update the text box value.
                Convert the value into engineering notation.
                """
-               
self.text_box.SetValue(eng_notation.num_to_str(self.get_value()))
+               
self._text_box.SetValue(eng_notation.num_to_str(self.get_value()))
 
        def _handle_scroll(self, event=None):
                """
                A scroll event is detected. Read the slider, call the callback.
                """
-               slider_value = self.slider.GetValue()
+               slider_value = self._slider.GetValue()
                new_value = slider_value*(self.max - self.min)/self.num_steps + 
self.min
                self.set_value(new_value)
                try: self.call()
@@ -237,20 +225,11 @@
                """
                An enter key was pressed. Read the text box, call the callback.
                """
-               new_value = eng_notation.str_to_num(self.text_box.GetValue())
+               new_value = eng_notation.str_to_num(self._text_box.GetValue())
                self.set_value(new_value)
                try: self.call()
                except Exception, e: print >> sys.stderr, 'Error in exec 
callback from handle enter.\n', e
 
-class slider_horizontal_control(_slider_control_base):
-       label_text_orientation = wx.HORIZONTAL
-       slider_style = wx.SL_HORIZONTAL
-       def get_slider_size(self): return self.slider_length, -1
-class slider_vertical_control(_slider_control_base):
-       label_text_orientation = wx.VERTICAL
-       slider_style = wx.SL_VERTICAL
-       def get_slider_size(self): return -1, self.slider_length
-
 
##############################################################################################
 # Text Box Control
 
##############################################################################################
@@ -271,33 +250,22 @@
                #create gui elements
                label_text_sizer = wx.BoxSizer(wx.HORIZONTAL) #label and text 
box container
                label_text = LabelText(self.get_window(), '%s: '%str(label))
-               self.text_box = text_box = wx.TextCtrl(self.get_window(), 
value=str(value), style=wx.TE_PROCESS_ENTER)
-               text_box.Bind(wx.EVT_TEXT_ENTER, self._handle_enter) #bind this 
special enter hotkey event
-               for obj in (label_text, text_box): #fill the container with 
label and text entry box
+               self._text_box = wx.TextCtrl(self.get_window(), 
style=wx.TE_PROCESS_ENTER)
+               self._text_box.Bind(wx.EVT_TEXT_ENTER, lambda evt: self.call()) 
#bind this special enter hotkey event
+               for obj in (label_text, self._text_box): #fill the container 
with label and text entry box
                        label_text_sizer.Add(obj, 0, wx.ALIGN_CENTER)
                self.Add(label_text_sizer, 0, wx.ALIGN_CENTER)
                #detect string mode
                self._string_mode = isinstance(value, str)
+               self.set_value(value)
 
        def get_value(self):
-               """
-               Get the current set value.
-               @return the value (float)
-               """
-               return self._value
+               if self._string_mode: return str(self._text_box.GetValue())
+               else: return eval(self._text_box.GetValue())
 
-       def _handle_enter(self, event=None):
-               """
-               An enter key was pressed. Read the text box, call the callback.
-               If the text cannot be evaluated, do not try callback.
-               Do not evaluate the text box value in string mode.
-               """
-               if self._string_mode:
-                       self._value = str(self.text_box.GetValue())
-               else:
-                       try: self._value = eval(self.text_box.GetValue())
-                       except Exception, e:
-                               print >> sys.stderr, 'Error in evaluate value 
from handle enter.\n', e
-                               return
-               try: self.call()
+       def set_value(self, value):
+               self._text_box.SetValue(str(value))
+
+       def call(self):
+               try: _control_base.call(self)
                except Exception, e: print >> sys.stderr, 'Error in exec 
callback from handle enter.\n', e

Modified: 
gnuradio/branches/developers/jblum/grc/grc/src/platforms/python/FlowGraph.py
===================================================================
--- 
gnuradio/branches/developers/jblum/grc/grc/src/platforms/python/FlowGraph.py    
    2009-04-01 01:01:28 UTC (rev 10726)
+++ 
gnuradio/branches/developers/jblum/grc/grc/src/platforms/python/FlowGraph.py    
    2009-04-01 01:25:11 UTC (rev 10727)
@@ -22,22 +22,6 @@
 from Block import Block
 from Connection import Connection
 
-def get_variable_code(variable):
-       """
-       Get the code representation for a variable.
-       Normally this is the value parameter.
-       For the variable chooser, use the index and choices.
-       Avoid using the to_code method of the variables,
-       as this forces evaluation before the variables are evaluated.
-       @param variable the variable block
-       @return the code string
-       """
-       if variable.get_key() == 'variable_chooser':
-               choices = variable.get_param('choices').get_value()
-               value_index = variable.get_param('value_index').get_value()
-               return "(%s)[%s]"%(choices, value_index)
-       return variable.get_param('value').get_value()
-
 class FlowGraph(_FlowGraph):
 
        _eval_cache = dict()
@@ -117,7 +101,7 @@
                id2var = dict([(var.get_id(), var) for var in variables])
                #map var id to variable code
                #variable code is a concatenation of all param code (without 
the id param)
-               id2expr = dict([(var.get_id(), get_variable_code(var)) for var 
in variables])
+               id2expr = dict([(var.get_id(), 
var.get_param('value').get_value()) for var in variables])
                #sort according to dependency
                sorted_ids = expr_utils.sort_variables(id2expr)
                #create list of sorted variable blocks
@@ -158,7 +142,7 @@
                        #load variables
                        for variable in self.get_variables():
                                try:
-                                       e = 
self._eval(get_variable_code(variable), n)
+                                       e = 
self._eval(variable.get_param('value').to_code(), n)
                                        n[variable.get_id()] = e
                                except: pass
                        #make namespace public





reply via email to

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