Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tautils.py
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2010-03-04 00:16:25 (GMT)
committer Walter Bender <walter@sugarlabs.org>2010-03-04 00:16:25 (GMT)
commitd77140caba2e5994b0adc1573767189bef123cfe (patch)
treeb2877eeeaee01d4e4f48785c1ceb68fd8fa3998b /tautils.py
parent088a1576c5a29248e409c24b7ca1ff13cc28e16d (diff)
cleaned up embedded image code
Diffstat (limited to 'tautils.py')
-rw-r--r--tautils.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/tautils.py b/tautils.py
index 81eeca6..ab2904f 100644
--- a/tautils.py
+++ b/tautils.py
@@ -136,13 +136,15 @@ def do_dialog(dialog, suffix, load_save_folder):
dialog.destroy()
return result, load_save_folder
-def save_picture(canvas, fname):
+def save_picture(canvas, fname=''):
pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, canvas.width,
canvas.height)
pixbuf.get_from_drawable(canvas.canvas.images[0],
canvas.canvas.images[0].get_colormap(),
0, 0, 0, 0, canvas.width, canvas.height)
- pixbuf.save(fname, 'png')
+ if fname != '':
+ pixbuf.save(fname, 'png')
+ return pixbuf
def save_svg(string, fname):
f = file(fname, "w")
@@ -175,7 +177,8 @@ def get_path(activity, subpath ):
def image_to_base64(pixbuf, activity):
filename = os.path.join(get_path(activity, 'instance'), 'imagetmp.png')
- pixbuf.save(filename, "png")
+ if pixbuf != None:
+ pixbuf.save(filename, "png")
base64 = os.path.join(get_path(activity, 'instance'), 'base64tmp')
cmd = "base64 <" + filename + " >" + base64
subprocess.check_call(cmd, shell=True)