diff options
author | Josh Blum | 2009-09-05 02:21:37 -0700 |
---|---|---|
committer | Josh Blum | 2009-09-05 02:21:37 -0700 |
commit | fa465d160b0c53fae3ad7876cf429263157dd60a (patch) | |
tree | 12c1b47840f0f4af32ab43d9878fa725d092decf /grc/gui/Block.py | |
parent | 5bb2a70a94be9c0f83712ee259b7125e3a582b08 (diff) | |
download | gnuradio-fa465d160b0c53fae3ad7876cf429263157dd60a.tar.gz gnuradio-fa465d160b0c53fae3ad7876cf429263157dd60a.tar.bz2 gnuradio-fa465d160b0c53fae3ad7876cf429263157dd60a.zip |
Created recursive create labels and shapes method for gui element.
Replaces update methods in the gui classes and simplifies calls.
The master update method in flow graph calls create labels and shapes.
Diffstat (limited to 'grc/gui/Block.py')
-rw-r--r-- | grc/gui/Block.py | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/grc/gui/Block.py b/grc/gui/Block.py index 68c4da9c3..fd8cfc226 100644 --- a/grc/gui/Block.py +++ b/grc/gui/Block.py @@ -113,23 +113,16 @@ class Block(Element): """ self.get_param('_rotation').set_value(str(rot)) - def update(self): + def create_shapes(self): """Update the block, parameters, and ports when a change occurs.""" - self._bg_color = self.get_enabled() and Colors.BLOCK_ENABLED_COLOR or Colors.BLOCK_DISABLED_COLOR - self.clear() - self._create_labels() - self.W = self.label_width + 2*BLOCK_LABEL_PADDING - self.H = max(*( - [self.label_height+2*BLOCK_LABEL_PADDING] + [2*PORT_BORDER_SEPARATION + \ - sum([port.H + PORT_SEPARATION for port in ports]) - PORT_SEPARATION - for ports in (self.get_sources(), self.get_sinks())] - )) + Element.create_shapes(self) if self.is_horizontal(): self.add_area((0, 0), (self.W, self.H)) elif self.is_vertical(): self.add_area((0, 0), (self.H, self.W)) - map(lambda p: p.update(), self.get_ports()) - def _create_labels(self): + def create_labels(self): """Create the labels for the signal block.""" + Element.create_labels(self) + self._bg_color = self.get_enabled() and Colors.BLOCK_ENABLED_COLOR or Colors.BLOCK_DISABLED_COLOR layouts = list() #create the main layout layout = gtk.DrawingArea().create_pango_layout('') @@ -164,7 +157,13 @@ class Block(Element): self.vertical_label = vimage = gtk.gdk.Image(gtk.gdk.IMAGE_NORMAL, pixmap.get_visual(), height, width) for i in range(width): for j in range(height): vimage.put_pixel(j, width-i-1, image.get_pixel(i, j)) - map(lambda p: p._create_labels(), self.get_ports()) + #calculate width and height needed + self.W = self.label_width + 2*BLOCK_LABEL_PADDING + self.H = max(*( + [self.label_height+2*BLOCK_LABEL_PADDING] + [2*PORT_BORDER_SEPARATION + \ + sum([port.H + PORT_SEPARATION for port in ports]) - PORT_SEPARATION + for ports in (self.get_sources(), self.get_sinks())] + )) def draw(self, gc, window): """ |