diff options
author | Walter Bender <walter.bender@gmail.com> | 2011-06-12 14:35:03 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2011-06-12 14:35:03 (GMT) |
commit | 30c82cde7fab47ac0748621c4cf7ccb7fb3300d5 (patch) | |
tree | 445d5982de102f53293c03972dcff367d0da4461 /TurtleArt | |
parent | 9fbc6bdad4d5e7aeffa6971f1d0fa795cfd56aba (diff) |
clean up of challenge positioning
Diffstat (limited to 'TurtleArt')
-rw-r--r-- | TurtleArt/talogo.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py index 27acc99..de5ce02 100644 --- a/TurtleArt/talogo.py +++ b/TurtleArt/talogo.py @@ -560,16 +560,13 @@ 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, width=None, - height=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 pixbuf = None - if width is not None and height is not None: - w, h = width, height - else: - w, h = self.wpercent(), self.hpercent() + w, h = self.wpercent(), self.hpercent() if w < 1 or h < 1: return if self.dsobject is not None: @@ -582,8 +579,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), @@ -594,6 +596,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(), self.y2ty(), w, h, self.filepath) |