diff options
author | manojgudi | 2014-03-02 13:31:48 +0530 |
---|---|---|
committer | manojgudi | 2014-03-02 13:31:48 +0530 |
commit | 6d931ce782f0b3229742268eb0d1d323937a052c (patch) | |
tree | a67457f58a1b1d7ddf9fa8df03ca8fc4fff81621 /grc/gui | |
parent | e3607a46082dae19ccf03b427f4bd8b65da13432 (diff) | |
download | gnuradio-6d931ce782f0b3229742268eb0d1d323937a052c.tar.gz gnuradio-6d931ce782f0b3229742268eb0d1d323937a052c.tar.bz2 gnuradio-6d931ce782f0b3229742268eb0d1d323937a052c.zip |
Jagdish's image_pixbuf implementation
Diffstat (limited to 'grc/gui')
-rw-r--r-- | grc/gui/Block.py | 36 | ||||
-rw-r--r-- | grc/gui/Element.py | 23 |
2 files changed, 57 insertions, 2 deletions
diff --git a/grc/gui/Block.py b/grc/gui/Block.py index 27143e070..019418d0b 100644 --- a/grc/gui/Block.py +++ b/grc/gui/Block.py @@ -64,6 +64,7 @@ class Block(Element): 'hide': 'all', }) )) + Element.__init__(self) def get_coordinate(self): @@ -120,15 +121,35 @@ class Block(Element): 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)) + + def get_key_parent(self, parent_string): + import re + return str(re.search(r"\((.*?)\)",parent_string).group(1)) + 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() + + + #### Hack Hack Hack + ''' + ## DEBUG + for i in dir(self.get_params()[0]): + print i," --> " , self.get_params()[0].__getattribute__(i) + ''' + + self.block_list = ['gr_serial'] + + #### End Hack + #create the main layout layout = gtk.DrawingArea().create_pango_layout('') layouts.append(layout) + layout.set_markup(Utils.parse_template(BLOCK_MARKUP_TMPL, block=self)) + self.label_width, self.label_height = layout.get_pixel_size() #display the params markups = [param.get_markup() for param in self.get_params() if param.get_hide() not in ('all', 'part')] @@ -148,6 +169,8 @@ class Block(Element): gc.set_foreground(self._bg_color) pixmap.draw_rectangle(gc, True, 0, 0, width, height) #draw the layouts + + h_off = 0 for i,layout in enumerate(layouts): w,h = layout.get_pixel_size() @@ -176,10 +199,19 @@ class Block(Element): """ x, y = self.get_coordinate() #draw main block - Element.draw( + + if self.block_list.__contains__(self.get_key_parent(str(self.get_params()[0]._parent))): + self.new_pixbuf = gtk.gdk.pixbuf_new_from_file("/home/manoj/Pictures/new.jpg") + Element.draw_image( + self, gc, window, bg_color=gtk.gdk.Color(red=65535, blue=0, green=0), + border_color=self.is_highlighted() and Colors.HIGHLIGHT_COLOR or Colors.BORDER_COLOR, pixbuf = self.new_pixbuf + ) + + else: + Element.draw( self, gc, window, bg_color=self._bg_color, border_color=self.is_highlighted() and Colors.HIGHLIGHT_COLOR or Colors.BORDER_COLOR, - ) + ) #draw label image if self.is_horizontal(): window.draw_drawable(gc, self.horizontal_label, 0, 0, x+BLOCK_LABEL_PADDING, y+(self.H-self.label_height)/2, -1, -1) diff --git a/grc/gui/Element.py b/grc/gui/Element.py index e020c5caa..43c7d15a8 100644 --- a/grc/gui/Element.py +++ b/grc/gui/Element.py @@ -90,6 +90,29 @@ class Element(object): for (x1, y1),(x2, y2) in self._lines_list: gc.set_foreground(border_color) window.draw_line(gc, X+x1, Y+y1, X+x2, Y+y2) + + def draw_image(self, gc, window, border_color, bg_color, pixbuf): + """ + Draw in the given window. + @param gc the graphics context + @param window the gtk window to draw on + @param border_color the color for lines and rectangle borders + @param bg_color the color for the inside of the rectangle + """ + X,Y = self.get_coordinate() + for (rX,rY),(W,H) in self._areas_list: + aX = X + rX + aY = Y + rY + + window.draw_pixbuf(None, pixbuf, 0,0, X,Y) + #window.draw_rectangle(gc, True, aX, aY, W, H) + #gc.set_foreground(border_color) + #window.draw_rectangle(gc, False, aX, aY, W, H) + + for (x1, y1),(x2, y2) in self._lines_list: + gc.set_foreground(border_color) + window.draw_line(gc, X+x1, Y+y1, X+x2, Y+y2) + def rotate(self, rotation): """ |