From 24ce1a087b8c33f8242baecc07866d416a167eee Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Wed, 19 Aug 2009 16:28:58 +0000 Subject: using png masks --- (limited to 'tasetup.py') diff --git a/tasetup.py b/tasetup.py index 99f63c4..81398dc 100644 --- a/tasetup.py +++ b/tasetup.py @@ -293,16 +293,17 @@ def setup_misc(tw): def setup_selector(tw,name,y,blockdescriptions): # selector tabs - offshape = load_image(tw.path,'palette',name+'off') - onshape = load_image(tw.path,'palette',name+'on') + offshape = load_image(tw.path, 'palette', name+'off') + onshape = load_image(tw.path, 'palette', name+'on') spr = sprNew(tw,143,y,offshape) setlayer(spr,800) spr.offshape = offshape spr.onshape = onshape # print 'setting up selector ' + name - spr.group = load_image(tw.path_lang, name,name+'group') - spr.mask = load_image(tw.path_lang, name,name+'mask') + spr.group = load_image(tw.path_lang, name, name+'group') + spr.mask = load_image(tw.path, '', name+'mask') spr.type = 'selbutton' + spr.name = name # block prototypes protos = [] for b in blockdescriptions: @@ -339,11 +340,18 @@ def load_image(path, dir, file): ".sugar/default/org.laptop.TurtleArtActivity/data") # first try to open the cached image + # then try to open .png file # if you fail, open the .svg file and cache the result as png try: return gtk.gdk.pixbuf_new_from_file(os.path.join(datapath, file+'.png')) except: - foo = gtk.gdk.pixbuf_new_from_file(os.path.join(path,dir,file \ - +'.svg')) - foo.save(os.path.join(datapath, file+'.png'), "png") - return foo + try: + print "trying ... " + os.path.join(path, dir, file+'.png') + return gtk.gdk.pixbuf_new_from_file(os.path.join(path, dir, \ + file+'.png')) + except: + foo = gtk.gdk.pixbuf_new_from_file(os.path.join(path, dir, \ + file +'.svg')) + foo.save(os.path.join(datapath, file+'.png'), "png") + return foo + -- cgit v0.9.1