use show signal to perform initial gui update
authorJosh Blum <josh@joshknows.com>
Wed, 9 Sep 2009 06:04:38 +0000 (23:04 -0700)
committerJosh Blum <josh@joshknows.com>
Wed, 9 Sep 2009 06:04:38 +0000 (23:04 -0700)
grc/gui/Param.py
grc/gui/PropsDialog.py
grc/python/Port.py
grc/scripts/usrp2_probe
grc/scripts/usrp_probe

index 7fabb667131c3fe70504b51214e348207778da49..4464a57ab77505f006b06a3731d1120248d891bb 100644 (file)
@@ -35,9 +35,11 @@ class InputParam(gtk.HBox):
                self.pack_start(self.label, False)
                self.set_markup = lambda m: self.label.set_markup(m)
                self.tp = None
+               #connect events
+               self.connect('show', self._update_gui)
        def set_color(self, color): pass
 
-       def update(self):
+       def _update_gui(self, *args):
                """
                Set the markup, color, tooltip, show/hide.
                """
@@ -65,12 +67,10 @@ class InputParam(gtk.HBox):
                #set the new value
                self.param.set_value(self.get_text())
                #call the callback
-               if self._callback: self._callback()
-               else:
-                       #no callback mode (used in supporting gui scripts)
-                       #internally re-validate the param and update the gui
-                       self.param.validate()
-                       self.update()
+               if self._callback: self._callback(*args)
+               else: self.param.validate()
+               #gui update
+               self._update_gui()
 
 class EntryParam(InputParam):
        """Provide an entry box for strings and numbers."""
index 34fd7ec1790167680a1e56c305edc4616de8d087..49650041690554d9d2ddf099afa5b11c2cd53acb 100644 (file)
@@ -81,16 +81,16 @@ class PropsDialog(gtk.Dialog):
                vbox.pack_start(self._params_box, False)
                vbox.pack_start(self._error_box, False)
                vbox.pack_start(self._docs_box, False)
-               #connect key press event
+               #connect events
                self.connect('key_press_event', self._handle_key_press)
-               #initial update to populate the params
+               self.connect('show', self._update_gui)
+               #show all (performs initial gui update)
                self.show_all()
-               self._update()
 
        def _params_changed(self):
                """
                Have the params in this dialog changed?
-               Ex: Added, removed, type change...
+               Ex: Added, removed, type change, hide change...
                Make a hash that uniquely represents the params state.
                @return true if changed
                """
@@ -99,9 +99,20 @@ class PropsDialog(gtk.Dialog):
                for param in self._block.get_params():
                        self._hash ^= hash(param)
                        self._hash ^= hash(param.get_type())
+                       self._hash ^= hash(param.get_hide())
                return self._hash != old_hash
 
-       def _update(self):
+       def _handle_changed(self, *args):
+               """
+               A change occured within a param:
+               Rewrite/validate the block and update the gui.
+               """
+               #update for the block
+               self._block.rewrite()
+               self._block.validate()
+               self._update_gui()
+
+       def _update_gui(self, *args):
                """
                Repopulate the parameters box (if changed).
                Update all the input parameters.
@@ -110,24 +121,23 @@ class PropsDialog(gtk.Dialog):
                Update the documentation block.
                Hide the box if there are no docs.
                """
-               #update for the block
-               self._block.rewrite()
-               self._block.validate()
                #update the params box
                if self._params_changed():
+                       #hide params box before changing
+                       self._params_box.hide_all()
                        #empty the params box
                        for io_param in list(self._input_object_params):
-                               io_param.hide_all()
                                self._params_box.remove(io_param)
                                self._input_object_params.remove(io_param)
                                io_param.destroy()
                        #repopulate the params box
                        for param in self._block.get_params():
-                               io_param = param.get_input(self._update)
+                               if param.get_hide() == 'all': continue
+                               io_param = param.get_input(self._handle_changed)
                                self._input_object_params.append(io_param)
                                self._params_box.pack_start(io_param, False)
-               #update the gui inputs
-               for io_param in self._input_object_params: io_param.update()
+                       #show params box with new params
+                       self._params_box.show_all()
                #update the errors box
                if self._block.is_valid(): self._error_box.hide()
                else: self._error_box.show()
index 33426d905bda81866862d7d49614646d0c1a6af7..6965371df8a9e922dbeb808d78da53bf93c81a59 100644 (file)
@@ -45,7 +45,7 @@ def _get_source_from_virtual_source_port(vsp, traversed=[]):
                                        lambda b: b.is_virtual_sink(),
                                        vsp.get_parent().get_parent().get_enabled_blocks(),
                                ),
-                       )[0].get_sink(vsp.get_key())
+                       )[0].get_sinks()[0]
                ), traversed + [vsp],
        )
        except: raise Exception, 'Could not resolve source for virtual source port %s'%vsp
index 689d41ecbdf70c4bf82bca39b712bd61ce991e17..38c8f655ce854b350e4f0d3b693b91e325061f85 100755 (executable)
@@ -42,7 +42,6 @@ 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):
index 985d481cedc2bb29b40cce49b010cc5228fb2993..d2e92e7530ab10dff1b46062ac13840d7209b544 100755 (executable)
@@ -40,7 +40,6 @@ 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):