combined param layouts
authorJosh Blum <josh@joshknows.com>
Sat, 5 Dec 2009 16:06:08 +0000 (11:06 -0500)
committerJosh Blum <josh@joshknows.com>
Sat, 5 Dec 2009 16:06:08 +0000 (11:06 -0500)
grc/gui/Block.py
grc/gui/Param.py

index 8c65bf06f104a2dd347856460d347775c813ff9f..bed50de9fd3a29a6984589e88ff39c24400fca82 100644 (file)
@@ -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)
index cb8bfdc5291accc624977e4bbbaf27d8768bdfa3..b3018dab216a59b43b8539b72abb1a35172585bf 100644 (file)
@@ -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)