commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r8237 - in grc/branches/grc_reloaded: notes src/grc sr


From: jblum
Subject: [Commit-gnuradio] r8237 - in grc/branches/grc_reloaded: notes src/grc src/grc/gui src/grc/gui/elements src/grc_gnuradio/blocks/graphical_sinks src/grc_gnuradio/blocks/operators src/grc_gnuradio/data src/grc_gnuradio/wxgui
Date: Mon, 21 Apr 2008 15:22:16 -0600 (MDT)

Author: jblum
Date: 2008-04-21 15:22:16 -0600 (Mon, 21 Apr 2008)
New Revision: 8237

Added:
   grc/branches/grc_reloaded/src/grc_gnuradio/wxgui/grc_app.py
Modified:
   grc/branches/grc_reloaded/notes/todo.txt
   grc/branches/grc_reloaded/src/grc/ActionHandler.py
   grc/branches/grc_reloaded/src/grc/Messages.py
   grc/branches/grc_reloaded/src/grc/gui/Dialogs.py
   grc/branches/grc_reloaded/src/grc/gui/elements/Block.py
   grc/branches/grc_reloaded/src/grc/gui/elements/Connection.py
   
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/graphical_sinks/wxgui_constellationsink2.xml
   
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/graphical_sinks/wxgui_fftsink2.xml
   
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/graphical_sinks/wxgui_numbersink2.xml
   
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/graphical_sinks/wxgui_scopesink2.xml
   
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/graphical_sinks/wxgui_waterfallsink2.xml
   
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/operators/gr_add_const_vxx.xml
   
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/operators/gr_multiply_const_vxx.xml
   grc/branches/grc_reloaded/src/grc_gnuradio/data/block_tree.xml
   grc/branches/grc_reloaded/src/grc_gnuradio/data/wx_gui.tmpl
   grc/branches/grc_reloaded/src/grc_gnuradio/wxgui/__init__.py
   grc/branches/grc_reloaded/src/grc_gnuradio/wxgui/callback_controls.py
Log:
bug fix in operators, wx gui app/tb, connection draw speedup

Modified: grc/branches/grc_reloaded/notes/todo.txt
===================================================================
--- grc/branches/grc_reloaded/notes/todo.txt    2008-04-21 21:19:18 UTC (rev 
8236)
+++ grc/branches/grc_reloaded/notes/todo.txt    2008-04-21 21:22:16 UTC (rev 
8237)
@@ -16,7 +16,7 @@
 -save working directory after close
 -create sub-flow graphs to be used in larger flow graphs
 -copy and paste blocks
--pref: hide block labels
+-disable blocks (grey out, keep in design file, but generate ignores)
 
 ############   Suggestions:    ####################
 -scope sink constructor needs average option and triggering option

Modified: grc/branches/grc_reloaded/src/grc/ActionHandler.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/ActionHandler.py  2008-04-21 21:19:18 UTC 
(rev 8236)
+++ grc/branches/grc_reloaded/src/grc/ActionHandler.py  2008-04-21 21:22:16 UTC 
(rev 8237)
@@ -159,7 +159,7 @@
                contructors of many of the classes used in this application 
enabling them to report any state change.
                @param state a string describing the state change
                """
-               print state
+               #print state
                
##############################################################################################
                #       Initalize/Quit
                
##############################################################################################
@@ -368,12 +368,17 @@
                        self.update_exec_stop()
                        self.start()
                except Exception, e:
-                       Messages.send_end_exec([str(e)])                        
+                       Messages.send_verbose_exec(str(e))
+                       Messages.send_end_exec()                        
                
        def run(self):  
                """Wait on the flow graph."""           
                #handle completion
-               Messages.send_end_exec(self.p.stderr.readlines())       
+               r = "\n"
+               while(r): 
+                       Messages.send_verbose_exec(r)
+                       r = self.p.stderr.read(1)               
+               Messages.send_end_exec()        
                self.page.set_pid_file('')
                self.update_exec_stop()
                

Modified: grc/branches/grc_reloaded/src/grc/Messages.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/Messages.py       2008-04-21 21:19:18 UTC 
(rev 8236)
+++ grc/branches/grc_reloaded/src/grc/Messages.py       2008-04-21 21:22:16 UTC 
(rev 8237)
@@ -78,12 +78,11 @@
 def send_start_exec(file_path):
        send('\nExecuting: "%s"'%file_path + '\n')
 
-def send_end_exec(verbose):
-       if verbose: 
-               send(">>> Verbose:      \n")            
-               for verb in verbose: send(verb)
-               send("\n")
-       send(">>> Done\n")
+def send_verbose_exec(verbose):
+       send(verbose)
+
+def send_end_exec():
+       send("\n>>> Done\n")
        
 #################      functions for saving flow graphs        
########################################                
 def send_fail_save(file_path):

Modified: grc/branches/grc_reloaded/src/grc/gui/Dialogs.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/Dialogs.py    2008-04-21 21:19:18 UTC 
(rev 8236)
+++ grc/branches/grc_reloaded/src/grc/gui/Dialogs.py    2008-04-21 21:22:16 UTC 
(rev 8237)
@@ -40,7 +40,7 @@
                gtk.TextView.__init__(self, text_buffer)
                self.set_editable(False)
                self.set_cursor_visible(False)
-               self.set_wrap_mode(gtk.WRAP_WORD)
+               self.set_wrap_mode(gtk.WRAP_WORD_CHAR)
 
 
######################################################################################################
 class PreferencesDialog(gtk.Dialog):

Modified: grc/branches/grc_reloaded/src/grc/gui/elements/Block.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/elements/Block.py     2008-04-21 
21:19:18 UTC (rev 8236)
+++ grc/branches/grc_reloaded/src/grc/gui/elements/Block.py     2008-04-21 
21:22:16 UTC (rev 8237)
@@ -103,6 +103,9 @@
                @param rot the rotation in degrees
                """
                self.get_param('gui_rotation').set_value(str(rot))
+               #update connections for this block
+               for port in self.get_sources() + self.get_sinks():
+                       for connection in port.get_connections(): 
connection.update()
        
        def update(self):
                """Update the block, parameters, and ports when a change 
occurs."""

Modified: grc/branches/grc_reloaded/src/grc/gui/elements/Connection.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/gui/elements/Connection.py        
2008-04-21 21:19:18 UTC (rev 8236)
+++ grc/branches/grc_reloaded/src/grc/gui/elements/Connection.py        
2008-04-21 21:22:16 UTC (rev 8237)
@@ -1,5 +1,5 @@
 """
-Copyright 2007 Free Software Foundation, Inc.
+Copyright 2007, 2008 Free Software Foundation, Inc.
 This file is part of GNU Radio
 
 GNU Radio Companion is free software; you can redistribute it and/or
@@ -43,55 +43,69 @@
                @return 0
                """
                return 0        
-       
+               
        def update(self):
-               """Add the horizontal and vertical lines that will connect the 
two parameters."""
-               self.clear()            
+               """Precalculate relative coordinates."""        
                sink = self.get_sink()
                source = self.get_source()
-               deltaAngle = abs(source.get_connector_direction() - 
sink.get_connector_direction())
                
                #get the source coordinate
-               x, y = source.get_connector_coordinate()
+               x1, y1 = 0, 0
                connector_length = source.get_connector_length()
                if source.get_rotation() == 0:
-                       x = x + connector_length
+                       x1 = 0 + connector_length
                elif source.get_rotation() == 90:
-                       y = y - connector_length
+                       y1 = 0 - connector_length
                elif source.get_rotation() == 180:
-                       x = x - connector_length
+                       x1 = 0 - connector_length
                elif source.get_rotation() == 270:
-                       y = y + connector_length                
-               self.add_line((x, y), source.get_connector_coordinate())
-               x1, y1 = x, y
+                       y1 = 0 + connector_length
+               self.x1, self.y1 = x1, y1
                
-               #get the sink coordinate
-               x, y = sink.get_connector_coordinate()
+               #get the sink coordinate        
+               x2, y2 = 0, 0
                connector_length = sink.get_connector_length() + 
CONNECTOR_ARROW_HEIGHT
                if sink.get_rotation() == 0:
-                       x = x - connector_length
+                       x2 = 0 - connector_length
                elif sink.get_rotation() == 90:
-                       y = y + connector_length
+                       y2 = 0 + connector_length
                elif sink.get_rotation() == 180:
-                       x = x + connector_length
+                       x2 = 0 + connector_length
                elif sink.get_rotation() == 270:
-                       y = y - connector_length
-               self.add_line((x, y), sink.get_connector_coordinate())
-               x2, y2 = x, y   
+                       y2 = 0 - connector_length       
+               self.x2, self.y2 = x2, y2
                
-               #build the arrows
-               x, y = sink.get_connector_coordinate()
+               #build the arrow
                if sink.get_rotation() == 0:
-                       self._arrow = [(x, y), (x-CONNECTOR_ARROW_HEIGHT, 
y-CONNECTOR_ARROW_BASE/2), (x-CONNECTOR_ARROW_HEIGHT, y+CONNECTOR_ARROW_BASE/2)]
+                       self.arrow = [(0, 0), (0-CONNECTOR_ARROW_HEIGHT, 
0-CONNECTOR_ARROW_BASE/2), (0-CONNECTOR_ARROW_HEIGHT, 0+CONNECTOR_ARROW_BASE/2)]
                elif sink.get_rotation() == 90:
-                       self._arrow = [(x, y), (x-CONNECTOR_ARROW_BASE/2, 
y+CONNECTOR_ARROW_HEIGHT), (x+CONNECTOR_ARROW_BASE/2, y+CONNECTOR_ARROW_HEIGHT)]
+                       self.arrow = [(0, 0), (0-CONNECTOR_ARROW_BASE/2, 
0+CONNECTOR_ARROW_HEIGHT), (0+CONNECTOR_ARROW_BASE/2, 0+CONNECTOR_ARROW_HEIGHT)]
                elif sink.get_rotation() == 180:
-                       self._arrow = [(x, y), (x+CONNECTOR_ARROW_HEIGHT, 
y-CONNECTOR_ARROW_BASE/2), (x+CONNECTOR_ARROW_HEIGHT, y+CONNECTOR_ARROW_BASE/2)]
+                       self.arrow = [(0, 0), (0+CONNECTOR_ARROW_HEIGHT, 
0-CONNECTOR_ARROW_BASE/2), (0+CONNECTOR_ARROW_HEIGHT, 0+CONNECTOR_ARROW_BASE/2)]
                elif sink.get_rotation() == 270:
-                       self._arrow = [(x, y), (x-CONNECTOR_ARROW_BASE/2, 
y-CONNECTOR_ARROW_HEIGHT), (x+CONNECTOR_ARROW_BASE/2, 
y-CONNECTOR_ARROW_HEIGHT)]                                      
+                       self.arrow = [(0, 0), (0-CONNECTOR_ARROW_BASE/2, 
0-CONNECTOR_ARROW_HEIGHT), (0+CONNECTOR_ARROW_BASE/2, 
0-CONNECTOR_ARROW_HEIGHT)]                                       
+       
+       def _draw(self):
+               """Add the horizontal and vertical lines that will connect the 
two parameters."""
+               self.clear()            
                
+               #source connector
+               source = self.get_source()
+               X, Y = source.get_connector_coordinate()
+               x1, y1 = self.x1 + X, self.y1 + Y
+               self.add_line((x1, y1), (X, Y))
+               
+               #sink connector
+               sink = self.get_sink()
+               X, Y = sink.get_connector_coordinate()
+               x2, y2 = self.x2 + X, self.y2 + Y
+               self.add_line((x2, y2), (X, Y)) 
+               
+               #adjust arrow 
+               self._arrow = [(x+X, y+Y) for x,y in self.arrow]
+               
                #add the horizontal and vertical lines in this connection
-               if deltaAngle == 180:
+               if abs(source.get_connector_direction() - 
sink.get_connector_direction()) == 180:
                        W = abs(x1 - x2)
                        H = abs(y1 - y2)
                        midX = (x1+x2)/2
@@ -124,7 +138,7 @@
                Draw the connection.
                @param window the gtk window to draw on
                """
-               self.update()   
+               self._draw()    
                Element.draw(self, window)      
                gc = self.get_gc()
                if not self.is_valid(): gc.foreground = Colors.ERROR_COLOR      
                        

Modified: 
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/graphical_sinks/wxgui_constellationsink2.xml
===================================================================
--- 
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/graphical_sinks/wxgui_constellationsink2.xml
      2008-04-21 21:19:18 UTC (rev 8236)
+++ 
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/graphical_sinks/wxgui_constellationsink2.xml
      2008-04-21 21:22:16 UTC (rev 8237)
@@ -10,7 +10,7 @@
        <key>wxgui_constellationsink2</key>
        <import>from gnuradio.wxgui import scopesink2</import>
        <make>scopesink2.constellation_sink(
-       _frame, 
+       tb.GetWin(), 
        title=$title, 
        sample_rate=$samp_rate, 
        frame_decim=$frame_decim,

Modified: 
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/graphical_sinks/wxgui_fftsink2.xml
===================================================================
--- 
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/graphical_sinks/wxgui_fftsink2.xml
        2008-04-21 21:19:18 UTC (rev 8236)
+++ 
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/graphical_sinks/wxgui_fftsink2.xml
        2008-04-21 21:22:16 UTC (rev 8237)
@@ -10,7 +10,7 @@
        <key>wxgui_fftsink2</key>
        <import>from gnuradio.wxgui import fftsink2</import>
        <make>fftsink2.$(type.fcn)(
-       _frame,
+       tb.GetWin(),
        baseband_freq=$baseband_freq,
        y_per_div=$y_per_div,
        y_divs=$y_divs,

Modified: 
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/graphical_sinks/wxgui_numbersink2.xml
===================================================================
--- 
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/graphical_sinks/wxgui_numbersink2.xml
     2008-04-21 21:19:18 UTC (rev 8236)
+++ 
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/graphical_sinks/wxgui_numbersink2.xml
     2008-04-21 21:22:16 UTC (rev 8237)
@@ -10,7 +10,7 @@
        <key>wxgui_numbersink2</key>
        <import>from gnuradio.wxgui import numbersink2</import>
        <make>numbersink2.$(type.fcn)(
-       _frame,
+       tb.GetWin(),
        unit=$units,
        base_value=$base_value,
        minval=$min_value,

Modified: 
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/graphical_sinks/wxgui_scopesink2.xml
===================================================================
--- 
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/graphical_sinks/wxgui_scopesink2.xml
      2008-04-21 21:19:18 UTC (rev 8236)
+++ 
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/graphical_sinks/wxgui_scopesink2.xml
      2008-04-21 21:22:16 UTC (rev 8237)
@@ -11,7 +11,7 @@
        <import>from gnuradio.wxgui import scopesink2</import>
        <import>from gnuradio import gr</import>
        <make>scopesink2.$(type.fcn)(
-       _frame, 
+       tb.GetWin(), 
        title=$title, 
        sample_rate=$samp_rate, 
        frame_decim=$frame_decim, 

Modified: 
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/graphical_sinks/wxgui_waterfallsink2.xml
===================================================================
--- 
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/graphical_sinks/wxgui_waterfallsink2.xml
  2008-04-21 21:19:18 UTC (rev 8236)
+++ 
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/graphical_sinks/wxgui_waterfallsink2.xml
  2008-04-21 21:22:16 UTC (rev 8237)
@@ -10,7 +10,7 @@
        <key>wxgui_waterfallsink2</key>
        <import>from gnuradio.wxgui import waterfallsink2</import>
        <make>waterfallsink2.$(type.fcn)(
-       _frame,
+       tb.GetWin(),
        baseband_freq=$baseband_freq,
        y_per_div=$y_per_div,
        ref_level=$ref_level,

Modified: 
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/operators/gr_add_const_vxx.xml
===================================================================
--- 
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/operators/gr_add_const_vxx.xml
    2008-04-21 21:19:18 UTC (rev 8236)
+++ 
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/operators/gr_add_const_vxx.xml
    2008-04-21 21:22:16 UTC (rev 8237)
@@ -49,20 +49,20 @@
        </param>        
        <param>
                <name>Vec Length</name>
-               <key>vec_len</key>
+               <key>vlen</key>
                <value>1</value>
                <type>int</type>
        </param>
-       <check>len($const) == $vec_len</check>
+       <check>len($const) == $vlen</check>
        <check>$vlen &gt; 0</check>
        <sink>
                <name>in</name>
                <type>$type</type>
-               <vlen>$vec_len</vlen>
+               <vlen>$vlen</vlen>
        </sink> 
        <source>
                <name>out</name>
                <type>$type</type>
-               <vlen>$vec_len</vlen>
+               <vlen>$vlen</vlen>
        </source>               
 </block>

Modified: 
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/operators/gr_multiply_const_vxx.xml
===================================================================
--- 
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/operators/gr_multiply_const_vxx.xml
       2008-04-21 21:19:18 UTC (rev 8236)
+++ 
grc/branches/grc_reloaded/src/grc_gnuradio/blocks/operators/gr_multiply_const_vxx.xml
       2008-04-21 21:22:16 UTC (rev 8237)
@@ -49,20 +49,20 @@
        </param>        
        <param>
                <name>Vec Length</name>
-               <key>vec_len</key>
+               <key>vlen</key>
                <value>1</value>
                <type>int</type>
        </param>
-       <check>len($const) == $vec_len</check>
+       <check>len($const) == $vlen</check>
        <check>$vlen &gt; 0</check>
        <sink>
                <name>in</name>
                <type>$type</type>
-               <vlen>$vec_len</vlen>
+               <vlen>$vlen</vlen>
        </sink> 
        <source>
                <name>out</name>
                <type>$type</type>
-               <vlen>$vec_len</vlen>
+               <vlen>$vlen</vlen>
        </source>               
 </block>

Modified: grc/branches/grc_reloaded/src/grc_gnuradio/data/block_tree.xml
===================================================================
--- grc/branches/grc_reloaded/src/grc_gnuradio/data/block_tree.xml      
2008-04-21 21:19:18 UTC (rev 8236)
+++ grc/branches/grc_reloaded/src/grc_gnuradio/data/block_tree.xml      
2008-04-21 21:22:16 UTC (rev 8237)
@@ -216,8 +216,8 @@
        <cat>
                <name>Variables</name>
                <block>variable</block>
-               <block>variable_chooser</block>
                <block>variable_slider</block>
+               <block>variable_chooser</block>
        </cat>
        <cat>
                <name>Misc</name>
@@ -229,9 +229,8 @@
                <block>blks2_valve</block>
                
                <block>gr_head</block>
-               <block>gr_skiphead</block>
+               <block>gr_skiphead</block>              
                
-               
                <block>gr_kludge_copy</block>           
                <block>gr_nop</block>
        </cat>

Modified: grc/branches/grc_reloaded/src/grc_gnuradio/data/wx_gui.tmpl
===================================================================
--- grc/branches/grc_reloaded/src/grc_gnuradio/data/wx_gui.tmpl 2008-04-21 
21:19:18 UTC (rev 8236)
+++ grc/branches/grc_reloaded/src/grc_gnuradio/data/wx_gui.tmpl 2008-04-21 
21:22:16 UTC (rev 8237)
@@ -14,15 +14,6 @@
 address@hidden graphical_sinks the graphical sink blocks
 ########################################################
 #import time
-#import os
-#import sys
-#from grc.Constants import MAIN_WINDOW_PREFIX,DATA_DIR
-##The default icon for the wx windows.
-#set $WX_APP_ICON = $DATA_DIR + '/grc-icon-32.png'
-##>>> platform dependency! wx under cygwin has issues with icon paths  #
-#if sys.platform == 'cygwin'
-#set $WX_APP_ICON = None
-#end if
 $('#'*40)
 # Gnuradio Python Flow Graph (wx gui)
 $('# Name: %s'%$flow_graph.get_option('name'))
@@ -55,12 +46,7 @@
 $imp
 #end for
 
-########################################################
-##     Create wx objects
-########################################################
-_app = wx.App()
-_frame = wx.Frame(None , -1, $('"%s - Executing: %s"'%($MAIN_WINDOW_PREFIX, 
$flow_graph.get_option('name'))))
-_grid = wx.GridBagSizer(5, 5)
+tb = grc_wxgui.grc_app("$flow_graph.get_option('name')")
 
 ########################################################
 ##     Create Variables
@@ -79,7 +65,6 @@
 ########################################################
 ##     Create Connections
 ########################################################
-tb = gr.top_block()
 #for $con in $connections
        #set $source = $con.get_source()
        #set $sink = $con.get_sink()
@@ -97,7 +82,7 @@
 ########################################################
 #for $graphical_sink in $graphical_sinks
        #set $grid_pos = $graphical_sink.get_param('grid_pos').evaluate()
-_grid.Add($(graphical_sink.get_id()).win, wx.GBPosition($grid_pos[0], 
$grid_pos[1]), wx.GBSpan($grid_pos[2], $grid_pos[3]))
+tb.GridAdd($(graphical_sink.get_id()).win, $grid_pos[0], $grid_pos[1], 
$grid_pos[2], $grid_pos[3])
 #end for
 ########################################################
 ##     Create Sliders
@@ -105,7 +90,7 @@
 #for $slider in $sliders
 $make_callback($slider.get_id())
 slider = grc_wxgui.slider_control(
-       window=_frame, 
+       window=tb.GetWin(), 
        callback=_callback,
 #if $slider.get_param('label').evaluate() 
        label=$slider.get_param('label').to_code(),
@@ -118,7 +103,7 @@
        num_steps=$slider.get_param('num_steps').to_code(),
 )
 #set $grid_pos = $slider.get_param('grid_pos').evaluate()
-_grid.Add(slider, wx.GBPosition($grid_pos[0], $grid_pos[1]), 
wx.GBSpan($grid_pos[2], $grid_pos[3]))
+tb.GridAdd(slider, $grid_pos[0], $grid_pos[1], $grid_pos[2], $grid_pos[3])
 #end for
 ########################################################
 ##     Create Chooser
@@ -126,7 +111,7 @@
 #for $chooser in $choosers
 $make_callback($chooser.get_id())
 chooser = grc_wxgui.chooser_control(
-       window=_frame, 
+       window=tb.GetWin(), 
        callback=_callback, 
 #if $chooser.get_param('label').evaluate() 
        label=$chooser.get_param('label').to_code(),
@@ -139,24 +124,8 @@
        type="$chooser.get_param('chooser_type').to_code()",
 )
 #set $grid_pos = $chooser.get_param('grid_pos').evaluate()
-_grid.Add(chooser, wx.GBPosition($grid_pos[0], $grid_pos[1]), 
wx.GBSpan($grid_pos[2], $grid_pos[3]))
+tb.GridAdd(chooser, $grid_pos[0], $grid_pos[1], $grid_pos[2], $grid_pos[3])
 #end for
        
-########################################################
-##     Setup GUI
-########################################################
-#if $WX_APP_ICON
-_frame.SetIcon(wx.Icon("$os.path.abspath($WX_APP_ICON)", wx.BITMAP_TYPE_ANY))
-#end if        
-_frame.SetSizeHints(200, 100)
-def _quit(event):
-       _frame.Destroy()
-       tb.stop()
-_frame.Bind(wx.EVT_CLOSE, _quit)       
-_frame.SetSizerAndFit(_grid)                   
-_frame.Show()
-tb.start()
-_app.SetTopWindow(_frame)
-_app.MainLoop()
-exit(0)
+tb.Run()
 

Modified: grc/branches/grc_reloaded/src/grc_gnuradio/wxgui/__init__.py
===================================================================
--- grc/branches/grc_reloaded/src/grc_gnuradio/wxgui/__init__.py        
2008-04-21 21:19:18 UTC (rev 8236)
+++ grc/branches/grc_reloaded/src/grc_gnuradio/wxgui/__init__.py        
2008-04-21 21:22:16 UTC (rev 8237)
@@ -1,4 +1,5 @@
 # make this directory a package
 
 from callback_controls import chooser_control, slider_control 
+from grc_app import grc_app
 

Modified: grc/branches/grc_reloaded/src/grc_gnuradio/wxgui/callback_controls.py
===================================================================
--- grc/branches/grc_reloaded/src/grc_gnuradio/wxgui/callback_controls.py       
2008-04-21 21:19:18 UTC (rev 8236)
+++ grc/branches/grc_reloaded/src/grc_gnuradio/wxgui/callback_controls.py       
2008-04-21 21:22:16 UTC (rev 8237)
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Copyright 2008 Free Software Foundation, Inc.
 # 
@@ -111,7 +110,7 @@
                A change is detected. Call the callback.
                """
                try: self.call()
-               except Exception, e: print >> sys.stderr, 'Error in handle 
change: "%s".'%e             
+               except Exception: print >> sys.stderr, 'Error in exec callback 
from handle changed.'    
 
        def get_value(self):
                """!
@@ -201,7 +200,7 @@
                self._set_slider_value(new_value)
                self.text_box.SetValue(new_value)
                try: self.call()
-               except Exception, e: print >> sys.stderr, 'Error in handle 
scroll: "%s".'%e 
+               except Exception: print >> sys.stderr, 'Error in exec callback 
from handle scroll.'
                
        def _handle_enter(self, event=None):
                """!
@@ -211,5 +210,5 @@
                self._set_slider_value(new_value)
                self.text_box.SetValue(new_value)
                try: self.call()
-               except Exception, e: print >> sys.stderr, 'Error in handle 
enter: "%s".'%e 
+               except Exception: print >> sys.stderr, 'Error in exec callback 
from handle enter.'
        

Added: grc/branches/grc_reloaded/src/grc_gnuradio/wxgui/grc_app.py
===================================================================
--- grc/branches/grc_reloaded/src/grc_gnuradio/wxgui/grc_app.py                 
        (rev 0)
+++ grc/branches/grc_reloaded/src/grc_gnuradio/wxgui/grc_app.py 2008-04-21 
21:22:16 UTC (rev 8237)
@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 Free Software Foundation, Inc.
+# 
+# This file is part of GNU Radio
+# 
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+# 
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+# 
+
+import wx
+import sys, os
+from gnuradio import gr
+
+from grc.Constants import MAIN_WINDOW_PREFIX,DATA_DIR
+##set the icon for the wx app
+WX_APP_ICON = DATA_DIR + '/grc-icon-32.png'
+##>>> platform dependency! wx under cygwin has issues with icon paths
+if sys.platform == 'cygwin': WX_APP_ICON = None
+
+class grc_app(gr.top_block):
+       """gr top block with wx gui app and grid sizer."""
+       
+       def __init__(self, name=""):
+               """!
+               Initialize the gr top block.
+               Create the wx gui elements.
+               """
+               #initialize
+               gr.top_block.__init__(self)
+               #create gui elements            
+               self._wx_app = wx.App()
+               self._wx_frame = wx.Frame(None , -1, '%s - Executing: 
%s'%(MAIN_WINDOW_PREFIX, name))
+               self._wx_grid = wx.GridBagSizer(5, 5)
+                                       
+       def GetWin(self): 
+               """!
+               Get the window for wx elements to fit within.
+               @return the wx frame 
+               """
+               return self._wx_frame
+       
+       def GridAdd(self, win, row, col, row_span, col_span):
+               """!
+               Add a window to the wx grid at the given position.
+               @param win the wx window
+               @param row the row specification (integer >= 0)
+               @param col the column specification (integer >= 0)
+               @param row_span the row span specification (integer >= 1)
+               @param col_span the column span specification (integer >= 1)
+               """
+               self._wx_grid.Add(win, wx.GBPosition(row, col), 
wx.GBSpan(row_span, col_span))
+               
+       def Run(self):
+               """!
+               Setup the wx gui elements.
+               Start the gr top block.
+               Block with the wx main loop.
+               """
+               #set wx app icon
+               if WX_APP_ICON:
+                       self._wx_frame.SetIcon(wx.Icon(WX_APP_ICON, 
wx.BITMAP_TYPE_ANY))        
+                       self._wx_frame.SetSizeHints(200, 100)           
+               #create callback for quit       
+               def _quit(event):
+                       gr.top_block.stop(self)
+                       self._wx_frame.Destroy()
+               #setup app      
+               self._wx_frame.Bind(wx.EVT_CLOSE, _quit)        
+               self._wx_frame.SetSizerAndFit(self._wx_grid)                    
+               self._wx_frame.Show()           
+               self._wx_app.SetTopWindow(self._wx_frame)               
+               #start flow graph
+               gr.top_block.start(self)
+               #blocking main loop
+               self._wx_app.MainLoop()
+       





reply via email to

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