commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r8590 - in grc/trunk: notes src/grc src/grc/gui src/gr


From: jblum
Subject: [Commit-gnuradio] r8590 - in grc/trunk: notes src/grc src/grc/gui src/grc_gnuradio src/grc_gnuradio/blocks src/grc_gnuradio/blocks/graphical_sinks src/grc_gnuradio/blocks/variables src/grc_gnuradio/wxgui
Date: Sat, 14 Jun 2008 16:25:30 -0600 (MDT)

Author: jblum
Date: 2008-06-14 16:25:28 -0600 (Sat, 14 Jun 2008)
New Revision: 8590

Modified:
   grc/trunk/notes/todo.txt
   grc/trunk/src/grc/ActionHandler.py
   grc/trunk/src/grc/Preferences.py
   grc/trunk/src/grc/gui/MainWindow.py
   grc/trunk/src/grc_gnuradio/Param.py
   
grc/trunk/src/grc_gnuradio/blocks/graphical_sinks/wxgui_constellationsink2.xml
   grc/trunk/src/grc_gnuradio/blocks/graphical_sinks/wxgui_fftsink2.xml
   grc/trunk/src/grc_gnuradio/blocks/graphical_sinks/wxgui_numbersink2.xml
   grc/trunk/src/grc_gnuradio/blocks/graphical_sinks/wxgui_scopesink2.xml
   grc/trunk/src/grc_gnuradio/blocks/graphical_sinks/wxgui_waterfallsink2.xml
   grc/trunk/src/grc_gnuradio/blocks/preferences.xml
   grc/trunk/src/grc_gnuradio/blocks/variables/variable_chooser.xml
   grc/trunk/src/grc_gnuradio/blocks/variables/variable_slider.xml
   grc/trunk/src/grc_gnuradio/wxgui/top_block_gui.py
Log:
save/restore open file, empty grid pos for default graphical placement

Modified: grc/trunk/notes/todo.txt
===================================================================
--- grc/trunk/notes/todo.txt    2008-06-13 23:50:06 UTC (rev 8589)
+++ grc/trunk/notes/todo.txt    2008-06-14 22:25:28 UTC (rev 8590)
@@ -15,7 +15,6 @@
 -disable blocks (grey out, keep in design file, but generate ignores)
 -param editor, expand entry boxes in focus
 -change param dialog to panel within main window
--default grid params of -1, -1 for auto placement
 
 ############   Suggestions:    ####################
 -scope sink constructor needs average option and triggering option

Modified: grc/trunk/src/grc/ActionHandler.py
===================================================================
--- grc/trunk/src/grc/ActionHandler.py  2008-06-13 23:50:06 UTC (rev 8589)
+++ grc/trunk/src/grc/ActionHandler.py  2008-06-14 22:25:28 UTC (rev 8590)
@@ -172,6 +172,7 @@
                        if not self.init_file_paths and 
Preferences.restore_files(): self.init_file_paths = Preferences.files_open()
                        if not self.init_file_paths: self.init_file_paths = ['']
                        for file_path in self.init_file_paths: 
self.main_window.new_page(file_path) #load pages from file paths
+                       if Preferences.file_open() in self.init_file_paths: 
self.main_window.new_page(Preferences.file_open(), show=True)
                        if not self.get_page(): self.main_window.new_page() 
#ensure that at least a blank page exists
                elif state == APPLICATION_QUIT:
                        if self.main_window.close_pages():

Modified: grc/trunk/src/grc/Preferences.py
===================================================================
--- grc/trunk/src/grc/Preferences.py    2008-06-13 23:50:06 UTC (rev 8589)
+++ grc/trunk/src/grc/Preferences.py    2008-06-14 22:25:28 UTC (rev 8590)
@@ -1,5 +1,5 @@
 """
-Copyright 2007 Free Software Foundation, Inc.
+Copyright 2008 Free Software Foundation, Inc.
 This file is part of GNU Radio
 
 GNU Radio Companion is free software; you can redistribute it and/or
@@ -20,7 +20,7 @@
 #Holds global paramerences
 address@hidden Josh Blum
 
-from grc.Constants import PREFERENCES_FILE_PATH, DATA_DIR
+from Constants import PREFERENCES_FILE_PATH, DATA_DIR
 import ParseXML
 import Messages
 
@@ -42,6 +42,7 @@
 restore_files_param = block.get_param('restore_files')
 
 window_size_param = block.get_param('window_size')
+file_open_param = block.get_param('file_open')
 files_open_param = block.get_param('files_open')
 show_params_param = block.get_param('show_params')
 show_id_param = block.get_param('show_id')
@@ -74,30 +75,17 @@
        ),
 ]
 
-def load(window=None):
+def load():
        """!
        Load the preferences from the preferences file.
-       @param window optional flow graph window
        """
        try: 
                ParseXML.validate_dtd(PREFERENCES_FILE_PATH, DATA_DIR + 
'/flow_graph.dtd')
                n = ParseXML.from_file(PREFERENCES_FILE_PATH)
                block.import_data(n['block'])
-               #set window size
-               try:
-                       size = window_size_param.evaluate()
-                       if window: window.resize(*size)
-               except: pass
        except: Messages.send_fail_load_preferences()           
 
-def save(window=None):
-       """!
-       Save the preferences to the preferences file.
-       @param window optional flow graph window
-       """
-       if window:
-               size = str(window.get_size())
-               window_size_param.set_value(size)
+def save():
        try: ParseXML.to_file({'block': block.export_data()}, 
PREFERENCES_FILE_PATH)    
        except IOError: Messages.send_fail_save_preferences()
                
@@ -105,15 +93,23 @@
 #      Special methods for specific program functionalities
 ###########################################################################
        
+def window_size(size=None):
+       if size: window_size_param.set_value(size)
+       else: 
+               try: return window_size_param.evaluate()
+               except: return (-1, -1)
+       
 def restore_files():
        return restore_files_param.get_value() == 'yes' 
        
-def files_open():
-       return files_open_param.get_value().split('\n')
+def file_open(file=None):
+       if file: file_open_param.set_value(file)
+       else: return file_open_param.get_value()
+
+def files_open(files=None):
+       if files: files_open_param.set_value('\n'.join(files))
+       else: return files_open_param.get_value().split('\n')
        
-def save_files_open(files):
-       files_open_param.set_value('\n'.join(files))
-       
 def show_reports_window():
        return show_reports_param.get_value() == 'show'
        

Modified: grc/trunk/src/grc/gui/MainWindow.py
===================================================================
--- grc/trunk/src/grc/gui/MainWindow.py 2008-06-13 23:50:06 UTC (rev 8589)
+++ grc/trunk/src/grc/gui/MainWindow.py 2008-06-14 22:25:28 UTC (rev 8590)
@@ -53,7 +53,7 @@
                vbox = gtk.VBox()
                hbox = gtk.HBox()
                self.add(vbox)
-               #create the menu bar    and toolbar     
+               #create the menu bar and toolbar        
                vbox.pack_start(Bars.MenuBar(), False)  
                vbox.pack_start(Bars.Toolbar(), False)          
                #setup scrolled window
@@ -62,7 +62,7 @@
                self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, 
gtk.POLICY_AUTOMATIC)
                self.drawing_area = DrawingArea(self)
                self.scrolled_window.add_with_viewport(self.drawing_area)
-               # create the notebook #         
+               #create the notebook
                self.notebook = gtk.Notebook()
                self.page_to_be_closed = None
                self.current_page = None
@@ -86,12 +86,13 @@
                self.reports_scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, 
gtk.POLICY_AUTOMATIC)
                
self.reports_scrolled_window.add_with_viewport(self.text_display)       
                fg_and_report_box.pack_end(self.reports_scrolled_window, False) 
#dont allow resize, fg should get all the space
-               # show all but the main window container and the reports window 
+               #show all but the main window container and the reports window  
                vbox.show_all()
                self.notebook.hide()
                self._show_reports_window(False) 
                # load preferences and show the main window 
-               Preferences.load(self)
+               Preferences.load()
+               self.resize(*Preferences.window_size())
                self.show()#show after resize in preferences
 
        ############################################################
@@ -190,14 +191,17 @@
                Close all the pages in this notebook.           
                @return true if all closed
                """
-               files = filter(lambda file: file, self._get_files()) #filter 
blank files
+               open_files = filter(lambda file: file, self._get_files()) 
#filter blank files
+               open_file = self.get_page().get_file_path()
                for page in self._get_pages():
                        
self._set_page(self.notebook.get_nth_page(self.notebook.get_n_pages()-1)) #show 
last page
                        self.page_to_be_closed = page
                        self.close_page(False)
                if self.notebook.get_n_pages(): return False
-               Preferences.save_files_open(files)
-               Preferences.save(self)
+               Preferences.files_open(open_files)
+               Preferences.file_open(open_file)
+               Preferences.window_size(self.get_size())
+               Preferences.save()
                return True
                        
        def close_page(self, ensure=True):

Modified: grc/trunk/src/grc_gnuradio/Param.py
===================================================================
--- grc/trunk/src/grc_gnuradio/Param.py 2008-06-13 23:50:06 UTC (rev 8589)
+++ grc/trunk/src/grc_gnuradio/Param.py 2008-06-14 22:25:28 UTC (rev 8590)
@@ -177,6 +177,8 @@
                                raise Exception
                        return e
                elif t == 'grid_pos':
+                       self._hostage_cells = list()
+                       if not v: return '' #allow for empty grid pos
                        e = self.get_parent().get_parent().evaluate(v)
                        try: 
                                assert(isinstance(e, (list, tuple)) and len(e) 
== 4)
@@ -196,7 +198,6 @@
                                self._add_error_message('Row and column span 
must be greater than zero.')
                                raise Exception
                        #calculate hostage cells
-                       self._hostage_cells = list()
                        for r in range(row_span):
                                for c in range(col_span):
                                        self._hostage_cells.append((row+r, 
col+c))

Modified: 
grc/trunk/src/grc_gnuradio/blocks/graphical_sinks/wxgui_constellationsink2.xml
===================================================================
--- 
grc/trunk/src/grc_gnuradio/blocks/graphical_sinks/wxgui_constellationsink2.xml  
    2008-06-13 23:50:06 UTC (rev 8589)
+++ 
grc/trunk/src/grc_gnuradio/blocks/graphical_sinks/wxgui_constellationsink2.xml  
    2008-06-14 22:25:28 UTC (rev 8590)
@@ -17,7 +17,11 @@
 )
 $(id).win.$(marker)()
 #set $grid_pos = $grid_pos.eval
-tb.GridAdd($(id).win, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])</make>
+#if not grid_pos
+tb.Add($(id).win)
+#else
+tb.GridAdd($(id).win, $grid_pos[0], $grid_pos[1], $grid_pos[2], $grid_pos[3])
+#end if</make>
        <callback>set_sample_rate($samp_rate)</callback>
        <param>
                <name>Title</name>      
@@ -58,7 +62,7 @@
        <param>
                <name>Grid Position</name>
                <key>grid_pos</key>
-               <value>0, 0, 2, 4</value>
+               <value></value>
                <type>grid_pos</type>
        </param>
        <sink>

Modified: grc/trunk/src/grc_gnuradio/blocks/graphical_sinks/wxgui_fftsink2.xml
===================================================================
--- grc/trunk/src/grc_gnuradio/blocks/graphical_sinks/wxgui_fftsink2.xml        
2008-06-13 23:50:06 UTC (rev 8589)
+++ grc/trunk/src/grc_gnuradio/blocks/graphical_sinks/wxgui_fftsink2.xml        
2008-06-14 22:25:28 UTC (rev 8590)
@@ -28,7 +28,11 @@
        peak_hold=$peak_hold,
 )
 #set $grid_pos = $grid_pos.eval
-tb.GridAdd($(id).win, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])</make>
+#if not grid_pos
+tb.Add($(id).win)
+#else
+tb.GridAdd($(id).win, $grid_pos[0], $grid_pos[1], $grid_pos[2], $grid_pos[3])
+#end if</make>
        <param>
                <name>Type</name>       
                <key>type</key>
@@ -130,7 +134,7 @@
        <param>
                <name>Grid Position</name>
                <key>grid_pos</key>
-               <value>0, 0, 2, 4</value>
+               <value></value>
                <type>grid_pos</type>
        </param>
        <sink>

Modified: 
grc/trunk/src/grc_gnuradio/blocks/graphical_sinks/wxgui_numbersink2.xml
===================================================================
--- grc/trunk/src/grc_gnuradio/blocks/graphical_sinks/wxgui_numbersink2.xml     
2008-06-13 23:50:06 UTC (rev 8589)
+++ grc/trunk/src/grc_gnuradio/blocks/graphical_sinks/wxgui_numbersink2.xml     
2008-06-14 22:25:28 UTC (rev 8590)
@@ -31,7 +31,11 @@
 )
 $(id).set_show_gauge($show_gauge)
 #set $grid_pos = $grid_pos.eval
-tb.GridAdd($(id).win, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])</make>
+#if not grid_pos
+tb.Add($(id).win)
+#else
+tb.GridAdd($(id).win, $grid_pos[0], $grid_pos[1], $grid_pos[2], $grid_pos[3])
+#end if</make>
        <param>
                <name>Type</name>       
                <key>type</key>
@@ -155,7 +159,7 @@
        <param>
                <name>Grid Position</name>
                <key>grid_pos</key>
-               <value>0, 0, 2, 4</value>
+               <value></value>
                <type>grid_pos</type>
        </param>
        <sink>

Modified: grc/trunk/src/grc_gnuradio/blocks/graphical_sinks/wxgui_scopesink2.xml
===================================================================
--- grc/trunk/src/grc_gnuradio/blocks/graphical_sinks/wxgui_scopesink2.xml      
2008-06-13 23:50:06 UTC (rev 8589)
+++ grc/trunk/src/grc_gnuradio/blocks/graphical_sinks/wxgui_scopesink2.xml      
2008-06-14 22:25:28 UTC (rev 8590)
@@ -25,7 +25,11 @@
 )
 $(id).win.$(marker)()
 #set $grid_pos = $grid_pos.eval
-tb.GridAdd($(id).win, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])</make>
+#if not grid_pos
+tb.Add($(id).win)
+#else
+tb.GridAdd($(id).win, $grid_pos[0], $grid_pos[1], $grid_pos[2], $grid_pos[3])
+#end if</make>
 <!-- 
 $(id).win.info.scopesink.set_trigger_channel($(trigger_channel))
 $(id).win.info.scopesink.set_trigger_mode(gr.$(trigger_mode)) -->
@@ -127,7 +131,7 @@
        <param>
                <name>Grid Position</name>
                <key>grid_pos</key>
-               <value>0, 0, 2, 4</value>
+               <value></value>
                <type>grid_pos</type>
        </param>
        <sink>

Modified: 
grc/trunk/src/grc_gnuradio/blocks/graphical_sinks/wxgui_waterfallsink2.xml
===================================================================
--- grc/trunk/src/grc_gnuradio/blocks/graphical_sinks/wxgui_waterfallsink2.xml  
2008-06-13 23:50:06 UTC (rev 8589)
+++ grc/trunk/src/grc_gnuradio/blocks/graphical_sinks/wxgui_waterfallsink2.xml  
2008-06-14 22:25:28 UTC (rev 8590)
@@ -26,7 +26,11 @@
        title=$title,
 )
 #set $grid_pos = $grid_pos.eval
-tb.GridAdd($(id).win, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])</make>
+#if not grid_pos
+tb.Add($(id).win)
+#else
+tb.GridAdd($(id).win, $grid_pos[0], $grid_pos[1], $grid_pos[2], $grid_pos[3])
+#end if</make>
        <param>
                <name>Type</name>       
                <key>type</key>
@@ -110,7 +114,7 @@
        <param>
                <name>Grid Position</name>
                <key>grid_pos</key>
-               <value>0, 0, 2, 4</value>
+               <value></value>
                <type>grid_pos</type>
        </param>
        <sink>

Modified: grc/trunk/src/grc_gnuradio/blocks/preferences.xml
===================================================================
--- grc/trunk/src/grc_gnuradio/blocks/preferences.xml   2008-06-13 23:50:06 UTC 
(rev 8589)
+++ grc/trunk/src/grc_gnuradio/blocks/preferences.xml   2008-06-14 22:25:28 UTC 
(rev 8590)
@@ -12,6 +12,12 @@
        <make></make>
        <!-- Hidden Prefs -->
        <param>
+               <name>File Open</name>
+               <key>file_open</key>
+               <value></value>
+               <type>string</type>     
+       </param>
+       <param>
                <name>Files Open</name>
                <key>files_open</key>
                <value></value>

Modified: grc/trunk/src/grc_gnuradio/blocks/variables/variable_chooser.xml
===================================================================
--- grc/trunk/src/grc_gnuradio/blocks/variables/variable_chooser.xml    
2008-06-13 23:50:06 UTC (rev 8589)
+++ grc/trunk/src/grc_gnuradio/blocks/variables/variable_chooser.xml    
2008-06-14 22:25:28 UTC (rev 8590)
@@ -22,7 +22,11 @@
        labels=$labels,
 )
 #set $grid_pos = $grid_pos.eval
-tb.GridAdd(_$(id)_control, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])</make>
+#if not grid_pos
+tb.Add(_$(id)_control)
+#else
+tb.GridAdd(_$(id)_control, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])
+#end if</make>
        <param>
                <name>Label</name>
                <key>label</key>
@@ -72,7 +76,7 @@
        <param>
                <name>Grid Position</name>
                <key>grid_pos</key>
-               <value>0, 0, 1, 2</value>
+               <value></value>
                <type>grid_pos</type>
        </param>
        <check>$value_index in range(len($choices))</check>

Modified: grc/trunk/src/grc_gnuradio/blocks/variables/variable_slider.xml
===================================================================
--- grc/trunk/src/grc_gnuradio/blocks/variables/variable_slider.xml     
2008-06-13 23:50:06 UTC (rev 8589)
+++ grc/trunk/src/grc_gnuradio/blocks/variables/variable_slider.xml     
2008-06-14 22:25:28 UTC (rev 8590)
@@ -23,7 +23,11 @@
        num_steps=$num_steps,
 )
 #set $grid_pos = $grid_pos.eval
-tb.GridAdd(_$(id)_control, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])</make>
+#if not grid_pos
+tb.Add(_$(id)_control)
+#else
+tb.GridAdd(_$(id)_control, $grid_pos[0], $grid_pos[1], $grid_pos[2], 
$grid_pos[3])
+#end if</make>
        <param>
                <name>Label</name>
                <key>label</key>
@@ -71,7 +75,7 @@
        <param>
                <name>Grid Position</name>
                <key>grid_pos</key>
-               <value>0, 0, 1, 2</value>
+               <value></value>
                <type>grid_pos</type>
        </param>
        <check>$min &lt;= $value &lt;= $max</check>

Modified: grc/trunk/src/grc_gnuradio/wxgui/top_block_gui.py
===================================================================
--- grc/trunk/src/grc_gnuradio/wxgui/top_block_gui.py   2008-06-13 23:50:06 UTC 
(rev 8589)
+++ grc/trunk/src/grc_gnuradio/wxgui/top_block_gui.py   2008-06-14 22:25:28 UTC 
(rev 8590)
@@ -45,6 +45,7 @@
                self._wx_app = wx.App()
                self._wx_frame = wx.Frame(None , -1, title)
                self._wx_grid = wx.GridBagSizer(5, 5)
+               self._wx_vbox = wx.BoxSizer(wx.VERTICAL)
                                        
        def GetWin(self): 
                """!
@@ -53,6 +54,13 @@
                """
                return self._wx_frame
        
+       def Add(self, win):
+               """!
+               Add a window to the wx vbox.
+               @param win the wx window
+               """
+               self._wx_vbox.Add(win)
+       
        def GridAdd(self, win, row, col, row_span=1, col_span=1):
                """!
                Add a window to the wx grid at the given position.
@@ -80,8 +88,9 @@
                        self._wx_frame.Destroy()
                        exit(0)
                #setup app      
+               self.Add(self._wx_grid)
                self._wx_frame.Bind(wx.EVT_CLOSE, _quit)
-               self._wx_frame.SetSizerAndFit(self._wx_grid)    
+               self._wx_frame.SetSizerAndFit(self._wx_vbox)    
                self._wx_frame.Show()
                self._wx_app.SetTopWindow(self._wx_frame)
                #start flow graph





reply via email to

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