Exemplo n.º 1
0
def main(name = None, show = True, **kwargs):
    """
    @type name: str
    @type show: bool
    @type kwargs: dict[]
    @rtype: @raise Exception:
    """
    import studiolibrary
    if not name:
        name = 'Default'
    add = kwargs.get('add', None)
    plugins = kwargs.get('plugins', list())
    root = kwargs.get('root', None)
    if root:
        if '\\' in root:
            raise Exception("Please use '/' instead of '\\'. Invalid token found in root path '%s'!" % root)
        if not os.path.exists(root):
            raise Exception("Cannot find the root folder path '%s'!" % root)
    if add or not plugins:
        _plugins = []
        _plugins.extend(DEFAULT_PLUGINS)
        if add:
            _plugins.extend(plugins)
    else:
        _plugins = plugins
    kwargs['plugins'] = _plugins
    if not isMaya():
        studiolibrary.__application = QtGui.QApplication(sys.argv)
    else:
        import maya.cmds
        if not studiolibrary.__scriptJob:
            studiolibrary.__scriptJob = maya.cmds.scriptJob(event=['quitApplication', 'import studiolibrary;\nfor window in studiolibrary.mainWindows().values():\n\twindow.saveSettings()'])
    if not root:
        root = LibrarySettings(name).get('kwargs', None).get('root', None)
        if not root and show:
            root = showWelcomeDialog()
            kwargs['root'] = root
    if name not in studiolibrary.mainWindows():
        w = studiolibrary.MainWindow(name=name, **kwargs)
        studiolibrary.mainWindows().setdefault(name, w)
    else:
        w = studiolibrary.mainWindows()[name]
        w.loadLibrary(name, kwargs)
        w.close()
    if show:
        w.showNormal()
        w.raiseWindow()
    if not studiolibrary.isMaya():
        sys.exit(studiolibrary.__application.exec_())
    return studiolibrary.mainWindows().get(name, None)
Exemplo n.º 2
0
def removeWindow(name):
    """
    @type name: str
    """
    import studiolibrary
    del studiolibrary.mainWindows()[name]