def loadBackground(self, client, url, contexts): overall = [None] * len(url) threads = [] for i, value in enumerate(url): import threading t = threading.Thread( name="Background load of %s" % (value), target=self.subLoad, args=(client, value, i, overall), ) t.start() threads.append(t) for t in threads: t.join() result = [x for x in overall if x is not None] if len(result) == len(overall): client.source = '\n'.join(result) # TODO: make this an observation that causes the # contexts to redraw, *not* something the node does # explicitly... for context in contexts: c = context() if c: c.triggerRedraw(1) return
def loadBackground( self, client, url, contexts ): overall = [None]* len(url) threads = [] for i,value in enumerate(url): import threading t = threading.Thread( name = "Background load of %s"%(value), target = self.subLoad, args = ( client, value, i, overall), ) t.start() threads.append( t ) for t in threads: t.join() result = [ x for x in overall if x is not None ] if len(result) == len(overall): client.source = '\n'.join( result ) # TODO: make this an observation that causes the # contexts to redraw, *not* something the node does # explicitly... for context in contexts: c = context() if c: c.triggerRedraw(1) return
def setImage( self, image, contexts=() ): """Set PIL image as our new image image -- open( ) PIL file with info['url'] and info['filename'] defined """ self.image = image self.components = -1 for context in contexts: c = context() if c: c.triggerRedraw(1) return
def loadBackground(self, url, contexts=()): """Load an image from the given url in the background url -- SF or MFString URL to load relative to the node's root's baseURL On success: Sets the resulting PIL image to the client's image property (triggering an un-caching and re-compile if there was a previous image). if contexts, iterate through the list calling context.triggerRedraw(1) """ try: from OpenGLContext.loaders.loader import Loader except ImportError: pass else: for u in url: try: baseNode = protofunctions.root(self) if baseNode: baseURI = baseNode.baseURI else: baseURI = None result = Loader.load(u, baseURL=baseURI) except IOError: pass else: print 'loaded', u self.scenegraph = result for context in contexts: c = context() if c: c.triggerRedraw(1) return warnings.warn( """Unable to load any scene from the url %s for the node %s""" % (url, str(self)))
def loadBackground( self, url, contexts=() ): """Load an image from the given url in the background url -- SF or MFString URL to load relative to the node's root's baseURL On success: Sets the resulting PIL image to the client's image property (triggering an un-caching and re-compile if there was a previous image). if contexts, iterate through the list calling context.triggerRedraw(1) """ try: from OpenGLContext.loaders.loader import Loader except ImportError: pass else: for u in url: try: baseNode = protofunctions.root(self) if baseNode: baseURI = baseNode.baseURI else: baseURI = None result = Loader.load( u, baseURL = baseURI ) except IOError: pass else: print 'loaded', u self.scenegraph = result for context in contexts: c = context() if c: c.triggerRedraw(1) return warnings.warn( """Unable to load any scene from the url %s for the node %s"""%( url, str(self)))