commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r9154 - in grc/trunk/src/grc: . gui


From: jblum
Subject: [Commit-gnuradio] r9154 - in grc/trunk/src/grc: . gui
Date: Sat, 2 Aug 2008 19:46:06 -0600 (MDT)

Author: jblum
Date: 2008-08-02 19:46:05 -0600 (Sat, 02 Aug 2008)
New Revision: 9154

Modified:
   grc/trunk/src/grc/ParseXML.py
   grc/trunk/src/grc/converter.py
   grc/trunk/src/grc/gui/Bars.py
Log:
updated converter utility

Modified: grc/trunk/src/grc/ParseXML.py
===================================================================
--- grc/trunk/src/grc/ParseXML.py       2008-08-03 00:24:38 UTC (rev 9153)
+++ grc/trunk/src/grc/ParseXML.py       2008-08-03 01:46:05 UTC (rev 9154)
@@ -87,13 +87,13 @@
        @return the xml tree filled with child nodes
        """
        nodes = list()
-       for key,values in nested_data.iteritems():
+       for key, values in nested_data.iteritems():
                #listify the values if not a list
                if not isinstance(values, (list, set, tuple)):
                        values = [values]
                for value in values:
                        node = etree.Element(key)
-                       if isinstance(value, str): node.text = value
+                       if isinstance(value, (str, unicode)): node.text = value
                        else: node.extend(_to_file(value))
                        nodes.append(node)
        return nodes

Modified: grc/trunk/src/grc/converter.py
===================================================================
--- grc/trunk/src/grc/converter.py      2008-08-03 00:24:38 UTC (rev 9153)
+++ grc/trunk/src/grc/converter.py      2008-08-03 01:46:05 UTC (rev 9154)
@@ -102,10 +102,11 @@
        # extract window size, variables, blocks, and connections
        ############################################################
        old_n = ParseXML.from_file(file_path)['flow_graph']
-       window_size = '%s, %s'%(
-               Utils.exists_or_else(old_n, 'window_width', '2048'),
-               Utils.exists_or_else(old_n, 'window_height', '2048'),
-       )
+       try: window_width = min(3*int(old_n['window_width'])/2, 2048)
+       except: window_width = 2048
+       try: window_height = min(3*int(old_n['window_height'])/2, 2048)
+       except: window_height = 2048
+       window_size = '%d, %d'%(window_width, window_height)
        variables = Utils.exists_or_else(old_n, 'vars', {}) or {}
        variables = Utils.listify(variables, 'var')
        blocks = Utils.exists_or_else(old_n, 'signal_blocks', {}) or {}
@@ -134,54 +135,53 @@
        options_block = odict()
        options_block['key'] = 'options'
        options_block['param'] = [
-               _make_param('id', 'options'),
+               _make_param('id', 'top_block'),
                _make_param('title', title),
                _make_param('author', author),
                _make_param('description', desc),
                _make_param('window_size', window_size),
+               _make_param('_coordinate', '(10, 10)'),
        ]
        #append options block
        new_n['block'].append(options_block)
        ############################################################
        # conversion - variables
        ############################################################
-       wxgui_row, wxgui_col = 0, 0
-       #arrange sliders in a row
+       x = 100 
        for variable in variables:
                key = variable['key']
                value = variable['value']
-               min = Utils.exists_or_else(variable, 'min', '')
-               max = Utils.exists_or_else(variable, 'max', '')
+               minimum = Utils.exists_or_else(variable, 'min', '')
+               maximum = Utils.exists_or_else(variable, 'max', '')
                step = Utils.exists_or_else(variable, 'step', '')
+               x = x + 150
+               coor = '(%d, %d)'%(x, 10)
                var_block = odict()
-               if min and max: #slider varible
+               if minimum and maximum: #slider varible
                        #determine num steps
-                       try: num_steps = str(int((float(max) - 
float(min))/float(step)))
+                       try: num_steps = str(int((float(maximum) - 
float(minimum))/float(step)))
                        except: num_steps = '100'
                        var_block['key'] = 'variable_slider'
                        var_block['param'] = [
                                _make_param('id', key),
                                _make_param('value', value),
-                               _make_param('min', min),
-                               _make_param('max', max),
+                               _make_param('min', minimum),
+                               _make_param('max', maximum),
                                _make_param('num_steps', num_steps),
-                               _make_param('grid_pos', '%d, %d, 1, 
2'%(wxgui_row, wxgui_col)),
+                               _make_param('_coordinate', coor),
                        ]
-                       wxgui_col = (wxgui_col + 2)%4
-                       if wxgui_col == 0: wxgui_row = wxgui_row + 1
                else: #regular variable
                        var_block['key'] = 'variable'
                        var_block['param'] = [
                                _make_param('id', key),
                                _make_param('value', value),
+                               _make_param('_coordinate', coor),
                        ]
                #append variable block
                new_n['block'].append(var_block)
        ############################################################
        # conversion - blocks
        ############################################################
-       wxgui_row = wxgui_row + 1
-       wxgui_col = 0
        #create name to key map for all blocks in platform
        name_to_key = dict((b.get_name(), b.get_key()) for b in 
platform.get_blocks())
        for block in blocks:
@@ -190,7 +190,7 @@
                #ignore list
                if tag in ('Note', 'About'): continue
                id = _convert_id(block['id'])
-               coor = '(%s, %s)'%(
+               coor = '(%s, %s + 100)'%(
                        Utils.exists_or_else(block, 'x_coordinate', '0'),
                        Utils.exists_or_else(block, 'y_coordinate', '0'),
                )
@@ -205,25 +205,22 @@
                new_block['key'] = key
                new_block['param'] = [
                        _make_param('id', id),
-                       _make_param('gui_coordinate', coor),
-                       _make_param('gui_rotation', rot),
+                       _make_param('_coordinate', coor),
+                       _make_param('_rotation', rot),
                ]
                #handle specific blocks
                if key == 'wxgui_fftsink2':
                        params = params[0:3] + ['0'] + params[3:4] + ['8'] + 
params[4:]
-               #handle wxgui blocks
-               if key.startswith('wxgui'):
-                       new_block['param'].append(_make_param('grid_pos', '%d, 
%d, 2, 4'%(wxgui_row, wxgui_col)))
-                       wxgui_row = wxgui_row + 2
                #append params
                for i, param in enumerate(params):
                        platform_block = platform.get_block(key)
-                       try: platform_param = platform_block.get_params()[i+1]
+                       try: platform_param = platform_block.get_params()[i+2]
                        except IndexError: break
                        if platform_param.is_enum():
                                try: param_value = 
platform_param.get_option_keys()[int(param)]
                                except: param_value = 
platform_param.get_option_keys()[0]
-                       else: param_value = param.replace('$', '')
+                       else:
+                               param_value = param.replace('$', 
'').replace('^', '**')
                        
new_block['param'].append(_make_param(platform_param.get_key(), param_value))
                #append block
                new_n['block'].append(new_block)

Modified: grc/trunk/src/grc/gui/Bars.py
===================================================================
--- grc/trunk/src/grc/gui/Bars.py       2008-08-03 00:24:38 UTC (rev 9153)
+++ grc/trunk/src/grc/gui/Bars.py       2008-08-03 01:46:05 UTC (rev 9154)
@@ -104,7 +104,7 @@
        def __init__(self):
                """
                Parse the list of action names in the toolbar list.
-               Look up the action for each name        in the action list and 
add it to the toolbar.
+               Look up the action for each name in the action list and add it 
to the toolbar.
                """
                gtk.Toolbar.__init__(self)
                self.set_style(gtk.TOOLBAR_ICONS)
@@ -135,10 +135,9 @@
                        main_menu = gtk.Menu()
                        main_menu_item.set_submenu(main_menu)
                        for action_name in action_names:
-                               if action_name: #append a menu item
+                               if action_name: #append a menu item
                                        action = 
get_action_from_name(action_name)
                                        
main_menu.append(action.create_menu_item())
                                else: main_menu.append(gtk.SeparatorMenuItem())
                        main_menu.show_all() #this show all is required for the 
separators to show
 
-





reply via email to

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