summaryrefslogtreecommitdiff
path: root/grc/gui
diff options
context:
space:
mode:
authormanojgudi2014-03-02 14:40:58 +0530
committermanojgudi2014-03-02 14:40:58 +0530
commit760b0acda722de34e830dc9b02cf78a695d001c5 (patch)
tree1804250ace4c0e8eb317ab93ada6a52431b09289 /grc/gui
parent6d931ce782f0b3229742268eb0d1d323937a052c (diff)
downloadgnuradio-760b0acda722de34e830dc9b02cf78a695d001c5.tar.gz
gnuradio-760b0acda722de34e830dc9b02cf78a695d001c5.tar.bz2
gnuradio-760b0acda722de34e830dc9b02cf78a695d001c5.zip
Changed API to accomodate <image> tag in grc file of the block
Ex: <image>/home/manoj/Pictures/new.jpg</image>
Diffstat (limited to 'grc/gui')
-rw-r--r--grc/gui/Block.py31
-rw-r--r--grc/gui/Element.py8
2 files changed, 16 insertions, 23 deletions
diff --git a/grc/gui/Block.py b/grc/gui/Block.py
index 019418d0b..25c37505b 100644
--- a/grc/gui/Block.py
+++ b/grc/gui/Block.py
@@ -21,6 +21,7 @@ from Element import Element
import Utils
import Colors
from .. base import odict
+
from Constants import BORDER_PROXIMITY_SENSITIVITY
from Constants import \
BLOCK_LABEL_PADDING, \
@@ -37,8 +38,8 @@ BLOCK_MARKUP_TMPL="""\
class Block(Element):
"""The graphical signal block."""
-
- def __init__(self):
+ """ image_path from ../python/Block.py"""
+ def __init__(self, image_path):
"""
Block contructor.
Add graphics related params to the block.
@@ -65,8 +66,8 @@ class Block(Element):
})
))
- Element.__init__(self)
-
+ self.image_path= image_path
+
def get_coordinate(self):
"""
Get the coordinate from the position param.
@@ -131,18 +132,6 @@ class Block(Element):
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('')
@@ -163,6 +152,7 @@ class Block(Element):
self.label_height += h + LABEL_SEPARATION
width = self.label_width
height = self.label_height
+
#setup the pixmap
pixmap = self.get_parent().new_pixmap(width, height)
gc = pixmap.new_gc()
@@ -200,13 +190,14 @@ class Block(Element):
x, y = self.get_coordinate()
#draw main block
- 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")
+ # If the image path is NOT ''
+ if self.image_path != '':
+ self.new_pixbuf = gtk.gdk.pixbuf_new_from_file(self.image_path)
Element.draw_image(
- self, gc, window, bg_color=gtk.gdk.Color(red=65535, blue=0, green=0),
+ self, gc, window, bg_color=self._bg_color,
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,
diff --git a/grc/gui/Element.py b/grc/gui/Element.py
index 43c7d15a8..6e79fd9f6 100644
--- a/grc/gui/Element.py
+++ b/grc/gui/Element.py
@@ -91,6 +91,7 @@ class Element(object):
gc.set_foreground(border_color)
window.draw_line(gc, X+x1, Y+y1, X+x2, Y+y2)
+ # Function which draws the image
def draw_image(self, gc, window, border_color, bg_color, pixbuf):
"""
Draw in the given window.
@@ -103,10 +104,11 @@ class Element(object):
for (rX,rY),(W,H) in self._areas_list:
aX = X + rX
aY = Y + rY
-
- window.draw_pixbuf(None, pixbuf, 0,0, X,Y)
+
+ # Needs Tweaking
+ window.draw_pixbuf(None, pixbuf, 0,0, aX, aY, -1, -1) # (gc, pixbuf, src_x, src_y, dest_x, dest_y, W, H)
#window.draw_rectangle(gc, True, aX, aY, W, H)
- #gc.set_foreground(border_color)
+ gc.set_foreground(border_color)
#window.draw_rectangle(gc, False, aX, aY, W, H)
for (x1, y1),(x2, y2) in self._lines_list: