Fixed the usrp and usrp2 probe scripts to work with the new gui param api.
authorJosh Blum <josh@joshknows.com>
Sun, 6 Sep 2009 08:58:25 +0000 (01:58 -0700)
committerJosh Blum <josh@joshknows.com>
Sun, 6 Sep 2009 08:58:25 +0000 (01:58 -0700)
Also fixed the scripts to work since they were broken by previous changes.
Get input in param class now pases a param instance (self) into the object.

grc/gui/Param.py
grc/gui/PropsDialog.py
grc/python/Param.py
grc/scripts/usrp2_probe
grc/scripts/usrp_probe
grc/todo.txt

index b84598e61c7ea87d2fff8102d2afd480450f1a1b..7fabb667131c3fe70504b51214e348207778da49 100644 (file)
@@ -30,7 +30,7 @@ class InputParam(gtk.HBox):
                gtk.HBox.__init__(self)
                self.param = param
                self._callback = callback
-               self.label = gtk.Label('') #no label, markup is added by set_markup
+               self.label = gtk.Label() #no label, markup is added by set_markup
                self.label.set_size_request(150, -1)
                self.pack_start(self.label, False)
                self.set_markup = lambda m: self.label.set_markup(m)
@@ -66,7 +66,11 @@ class InputParam(gtk.HBox):
                self.param.set_value(self.get_text())
                #call the callback
                if self._callback: self._callback()
-               #self.update() #dont update here, parent will update
+               else:
+                       #no callback mode (used in supporting gui scripts)
+                       #internally re-validate the param and update the gui
+                       self.param.validate()
+                       self.update()
 
 class EntryParam(InputParam):
        """Provide an entry box for strings and numbers."""
@@ -155,9 +159,9 @@ class Param(Element):
                All others get a standard entry parameter.
                @return gtk input class
                """
-               if self.is_enum(): return EnumParam(*args, **kwargs)
-               if self.get_options(): return EnumEntryParam(*args, **kwargs)
-               return EntryParam(*args, **kwargs)
+               if self.is_enum(): return EnumParam(self, *args, **kwargs)
+               if self.get_options(): return EnumEntryParam(self, *args, **kwargs)
+               return EntryParam(self, *args, **kwargs)
 
        def get_layout(self):
                """
index aa86f7214bb8bb4cce1a826fcb1ad22a66574756..34fd7ec1790167680a1e56c305edc4616de8d087 100644 (file)
@@ -123,7 +123,7 @@ class PropsDialog(gtk.Dialog):
                                io_param.destroy()
                        #repopulate the params box
                        for param in self._block.get_params():
-                               io_param = param.get_input(param, callback=self._update)
+                               io_param = param.get_input(self._update)
                                self._input_object_params.append(io_param)
                                self._params_box.pack_start(io_param, False)
                #update the gui inputs
index c64659a080690583a9de36441af90485bdbfca50..387fab5481af81c27692cd20169023a7deba58c9 100644 (file)
@@ -154,7 +154,7 @@ class Param(_Param, _GUIParam):
                return dt_str
 
        def get_input(self, *args, **kwargs):
-               if self.get_type() in ('file_open', 'file_save'): return FileParam(*args, **kwargs)
+               if self.get_type() in ('file_open', 'file_save'): return FileParam(self, *args, **kwargs)
                return _GUIParam.get_input(self, *args, **kwargs)
 
        def get_color(self):
index 00d4366ddfc2c24fc3d9c0094077b96e6ac3d3e1..689d41ecbdf70c4bf82bca39b712bd61ce991e17 100755 (executable)
@@ -32,9 +32,6 @@ from gnuradio.grc.gui.Dialogs import TextDisplay
 from gnuradio.grc.python.Platform import Platform
 platform = Platform()
 
-from gnuradio.grc.gui.Platform import Platform
-platform = Platform(platform)
-
 flow_graph = platform.get_new_flow_graph()
 block = flow_graph.get_new_block('usrp2_probe')
 
@@ -42,6 +39,12 @@ block = flow_graph.get_new_block('usrp2_probe')
 usrp_interface_param = block.get_param('interface')
 usrp_type_param = block.get_param('type')
 
+def get_input(param):
+       param.validate()
+       input = param.get_input()
+       input.update()
+       return input
+
 class USRP2ProbeWindow(gtk.Window):
        """
        The main window for USRP Dignostics.
@@ -69,8 +72,8 @@ class USRP2ProbeWindow(gtk.Window):
                #create vbox for storage
                vbox = gtk.VBox()
                frame.add(vbox)
-               vbox.pack_start(usrp_interface_param.get_input_object(), False)
-               vbox.pack_start(usrp_type_param.get_input_object(), False)
+               vbox.pack_start(get_input(usrp_interface_param), False)
+               vbox.pack_start(get_input(usrp_type_param), False)
                #make the tree model for holding mac addrs
                self.treestore = gtk.TreeStore(gobject.TYPE_STRING)
                self.treeview = gtk.TreeView(self.treestore)
index 6565612c16e87980e5d4e64d2ec6597358827d4b..985d481cedc2bb29b40cce49b010cc5228fb2993 100755 (executable)
@@ -30,9 +30,6 @@ from gnuradio.grc.gui.Dialogs import TextDisplay
 from gnuradio.grc.python.Platform import Platform
 platform = Platform()
 
-from gnuradio.grc.gui.Platform import Platform
-platform = Platform(platform)
-
 flow_graph = platform.get_new_flow_graph()
 block = flow_graph.get_new_block('usrp_probe')
 
@@ -40,6 +37,12 @@ block = flow_graph.get_new_block('usrp_probe')
 usrp_which_param = block.get_param('which')
 usrp_dboard_param = block.get_param('dboard')
 
+def get_input(param):
+       param.validate()
+       input = param.get_input()
+       input.update()
+       return input
+
 class USRPProbeWindow(gtk.Window):
        """
        The main window for USRP Dignostics.
@@ -66,8 +69,8 @@ class USRPProbeWindow(gtk.Window):
                #create vbox for storage
                vbox = gtk.VBox()
                frame.add(vbox)
-               vbox.pack_start(usrp_which_param.get_input_object(), False)
-               vbox.pack_start(usrp_dboard_param.get_input_object(), False)
+               vbox.pack_start(get_input(usrp_which_param), False)
+               vbox.pack_start(get_input(usrp_dboard_param), False)
                self.probe_button = gtk.Button('Probe')
                self.probe_button.connect('clicked', self._probe_usrp)
                vbox.pack_start(self.probe_button, False)
index c675859d169f436835d56e5a6706db4bdcfe38b9..b4e3af39d671f9a98b17079a124277c21514a845 100644 (file)
@@ -69,7 +69,6 @@
 * threads dont die on exit in probe and variable sink
 * align param titles in properties dialog
 * weird grid params misbehaving
-* fix param input stuff for usrp probes
 
 ##################################################
 # Future