From 87decb3b420e88bfa0d57b328b2b7404de4a61ba Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 5 Dec 2009 11:06:08 -0500 Subject: [PATCH] combined param layouts --- grc/gui/Block.py | 8 ++++++-- grc/gui/Param.py | 10 ++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/grc/gui/Block.py b/grc/gui/Block.py index 8c65bf06..bed50de9 100644 --- a/grc/gui/Block.py +++ b/grc/gui/Block.py @@ -29,6 +29,7 @@ from Constants import \ import pygtk pygtk.require('2.0') import gtk +import pango BLOCK_MARKUP_TMPL="""\ #set $foreground = $block.is_valid() and 'black' or 'red' @@ -130,8 +131,11 @@ class Block(Element): layout.set_markup(Utils.parse_template(BLOCK_MARKUP_TMPL, block=self)) self.label_width, self.label_height = layout.get_pixel_size() #display the params - for param in filter(lambda p: p.get_hide() not in ('all', 'part'), self.get_params()): - layout = param.get_layout() + markups = [param.get_markup() for param in self.get_params() if param.get_hide() not in ('all', 'part')] + if markups: + layout = gtk.DrawingArea().create_pango_layout('') + layout.set_spacing(LABEL_SEPARATION*pango.SCALE) + layout.set_markup('\n'.join(markups)) layouts.append(layout) w,h = layout.get_pixel_size() self.label_width = max(w, self.label_width) diff --git a/grc/gui/Param.py b/grc/gui/Param.py index cb8bfdc5..b3018dab 100644 --- a/grc/gui/Param.py +++ b/grc/gui/Param.py @@ -165,11 +165,9 @@ class Param(Element): if self.get_options(): return EnumEntryParam(self, *args, **kwargs) return EntryParam(self, *args, **kwargs) - def get_layout(self): + def get_markup(self): """ - Create a layout based on the current markup. - @return the pango layout + Get the markup for this param. + @return a pango markup string """ - layout = gtk.DrawingArea().create_pango_layout('') - layout.set_markup(Utils.parse_template(PARAM_MARKUP_TMPL, param=self)) - return layout + return Utils.parse_template(PARAM_MARKUP_TMPL, param=self) -- 2.30.2