Exemple #1
0
 def subLoad( self, client, urlFragment, i, overall ):
     from OpenGLContext.loaders.loader import Loader
     try:
         baseNode = protofunctions.root(client)
         if baseNode:
             baseURI = baseNode.baseURI
         else:
             baseURI = None
         result = Loader( urlFragment, baseURL = baseURI )
     except IOError:
         pass
     else:
         if result:
             baseURL, filename, file, headers = result
             overall[i] = file.read()
             return True
     # should set client.image to something here to indicate
     # failure to the user.
     log.warn( """Unable to load any shader from the url %s for the node %s""", urlFragment, str(client))
Exemple #2
0
    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 subLoad(self, client, urlFragment, i, overall):
     from OpenGLContext.loaders.loader import Loader
     try:
         baseNode = protofunctions.root(client)
         if baseNode:
             baseURI = baseNode.baseURI
         else:
             baseURI = None
         result = Loader(urlFragment, baseURL=baseURI)
     except IOError:
         pass
     else:
         if result:
             baseURL, filename, file, headers = result
             overall[i] = file.read()
             return True
     # should set client.image to something here to indicate
     # failure to the user.
     log.warn(
         """Unable to load any shader from the url %s for the node %s""",
         urlFragment, str(client))
Exemple #4
0
    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)))
        
Exemple #5
0
        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)
            """
            from OpenGLContext.loaders.loader import Loader
            try:
                baseNode = protofunctions.root(self)
                if baseNode:
                    baseURI = baseNode.baseURI
                else:
                    baseURI = None
                result = Loader( url, baseURL = baseURI )
            except IOError:
                pass
            else:
                if result:
                    
                    baseURL, filename, file, headers = result
                    image = Image.open( file )
                    image.info[ 'url' ] = baseURL
                    image.info[ 'filename' ] = filename
                        
                    if image:
                        return self.setImage( image, contexts )
            
            # should set client.image to something here to indicate
            # failure to the user.
            log.warn( """Unable to load any image from the url %s for the node %s""", url, str(self))
Exemple #6
0
        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)
            """
            from OpenGLContext.loaders.loader import Loader
            try:
                baseNode = protofunctions.root(self)
                if baseNode:
                    baseURI = baseNode.baseURI
                else:
                    baseURI = None
                result = Loader( url, baseURL = baseURI )
            except IOError:
                pass
            else:
                if result:
                    
                    baseURL, filename, file, headers = result
                    image = Image.open( file )
                    image.info[ 'url' ] = baseURL
                    image.info[ 'filename' ] = filename
                        
                    if image:
                        return self.setImage( image, contexts )
            
            # should set client.image to something here to indicate
            # failure to the user.
            log.warn( """Unable to load any image from the url %s for the node %s""", url, str(self))