diff options
author | Walter Bender <walter.bender@gmail.com> | 2011-11-19 13:13:41 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2011-11-19 13:13:41 (GMT) |
commit | d6126386cf89c395451671c088ddf2cc9ada1417 (patch) | |
tree | ae782cd6984c8d2a71df76c1b58d6c30f453f949 /TurtleArt | |
parent | 9867b426868a54dca66db46a12f650ae4df9baf6 (diff) |
add insert_image flags used by Turtle Confusion in order to maintain common code base
Diffstat (limited to 'TurtleArt')
-rw-r--r-- | TurtleArt/talogo.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py index f3bb956..0e28cf0 100644 --- a/TurtleArt/talogo.py +++ b/TurtleArt/talogo.py @@ -561,7 +561,8 @@ class LogoCode: """ height as a percentage of screen coordinates """ return int((self.tw.canvas.height * self.scale) / 100.) - def insert_image(self, center=False, filepath=None): + def insert_image(self, center=False, filepath=None, resize=True, + offset=False): """ Image only (at current x, y) """ if filepath is not None: self.filepath = filepath @@ -579,8 +580,13 @@ class LogoCode: self.filepath is not None and \ self.filepath != '': try: - pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self.filepath, - w, h) + if not resize: + pixbuf = gtk.gdk.pixbuf_new_from_file(self.filepath) + w = pixbuf.get_width() + h = pixbuf.get_height() + else: + pixbuf = gtk.gdk.pixbuf_new_from_file_at_size( + self.filepath, w, h) except: self.tw.showlabel('nojournal', self.filepath) debug_output("Couldn't open filepath %s" % (self.filepath), @@ -595,6 +601,9 @@ class LogoCode: self.x2tx() - int(w / 2), self.y2ty() - int(h / 2), w, h, self.filepath) + elif offset: + self.tw.canvas.draw_pixbuf(pixbuf, 0, 0, self.x2tx(), + self.y2ty() - h, w, h, self.filepath) else: self.tw.canvas.draw_pixbuf(pixbuf, 0, 0, self.x2tx(), |