gui/resource.py
def load(controller=None, filename="", name=None, rsrc=None):
    "Create the GUI objects defined in the resource (filename or python struct)"
    # if no filename is given, search for the rsrc.py with the same module name:
    if not filename and not rsrc:
        if isinstance(controller, types.ClassType):
            # use the controller class module (to get __file__ for rsrc.py)
            mod_dict = util.get_class_module_dict(controller)
        elif isinstance(controller, types.ModuleType):
            # use the module provided as controller
            mod_dict = controller.__dict__
        elif isinstance(controller, Controller):
            # use the instance provided as controller
            mod_dict = util.get_class_module_dict(controller)
        else:
            # use the caller module (no controller explicitelly provided)
            mod_dict = util.get_caller_module_dict()
            # do not use as controller if it was explicitly False or empty
            if controller is None:
                controller = mod_dict
        if util.main_is_frozen():
            # running standalone
            if '__file__' in mod_dict:
                filename = os.path.split(mod_dict['__file__'])[1]
            else:
                # __main__ has not __file__ under py2exe!
                filename = os.path.split(sys.argv[0])[-1]
            filename = os.path.join(util.get_app_dir(), filename)
        else:
            # figure out the .rsrc.py filename based on the module name
            filename = mod_dict['__file__']
        # chop the .pyc or .pyo from the end
        base, ext = os.path.splitext(filename)
        filename = base + ".rsrc.py"
    # when rsrc is a file name, open, read and eval it:
    if isinstance(filename, basestring):
        rsrc = parse(filename)
    ret = []
    # search over the resource to create the requested object (or all)
    for win in rsrc:
        if not name or win['name'] == name:
            ret.append(build_window(win))
    # associate event handlers
    if ret and controller:
        connect(ret[0], controller)        
        # return the first instance created (if any):
        return ret[0]
    else:
        # return all the instances created -for the designer- (if any):
        return ret
def load(controller=None, filename="", name=None, rsrc=None):
    "Create the GUI objects defined in the resource (filename or python struct)"
    # if no filename is given, search for the rsrc.py with the same module name:
    if not filename and not rsrc:
        if isinstance(controller, types.ClassType):
            # use the controller class module (to get __file__ for rsrc.py)
            mod_dict = util.get_class_module_dict(controller)
        elif isinstance(controller, types.ModuleType):
            # use the module provided as controller
            mod_dict = controller.__dict__
        elif isinstance(controller, Controller):
            # use the instance provided as controller
            mod_dict = util.get_class_module_dict(controller)
        else:
            # use the caller module (no controller explicitelly provided)
            mod_dict = util.get_caller_module_dict()
            # do not use as controller if it was explicitly False or empty
            if controller is None:
                controller = mod_dict
        if util.main_is_frozen():
            # running standalone
            if '__file__' in mod_dict:
                filename = os.path.split(mod_dict['__file__'])[1]
            else:
                # __main__ has not __file__ under py2exe!
                filename = os.path.split(sys.argv[0])[-1]
            filename = os.path.join(util.get_app_dir(), filename)
        else:
            # figure out the .rsrc.py filename based on the module name
            filename = mod_dict['__file__']
        # chop the .pyc or .pyo from the end
        base, ext = os.path.splitext(filename)
        filename = base + ".rsrc.py"
    # when rsrc is a file name, open, read and eval it:
    if isinstance(filename, basestring):
        rsrc = parse(filename)
    ret = []
    # search over the resource to create the requested object (or all)
    for win in rsrc:
        if not name or win['name'] == name:
            ret.append(build_window(win))
    # associate event handlers
    if ret and controller:
        connect(ret[0], controller)        
        # return the first instance created (if any):
        return ret[0]
    else:
        # return all the instances created -for the designer- (if any):
        return ret
Create the GUI objects defined in the resource (filename or python struct)