def showExample():
    """
    Run a simple example of the widget.

    :rtype: QtWidgets.QWidget
    """

    with studioqt.app():

        def triggered():
            print "Triggered"

        def triggered2():
            print "Triggered2"

        widget = studioqt.MenuBarWidget()

        icon = studioqt.icon("add")
        action = widget.addLeftAction("New Item")
        action.setIcon(icon)
        action.triggered.connect(triggered)

        lineedit = QtWidgets.QLineEdit()
        widget.layout().insertWidget(1, lineedit)
        widget.setExpandedHeight(50)

        icon = studioqt.icon("settings")
        action = widget.addRightAction("Settings")
        action.setIcon(icon)
        action.triggered.connect(triggered2)

        widget.show()

        return widget
def example():
    path = r'C:/Users/Hovel/Dropbox/libraries/animation'
    trashPath = path + r'/Trash'

    ignoreFilter = ['.', '.studiolibrary', '.pose', '.anim', '.set']

    with studioqt.app():

        def itemSelectionChanged():
            print w.selectedFolders()
            print w.settings()

        w = FoldersWidget()
        w.enableFolderSettings(True)

        w.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        w.customContextMenuRequested.connect(w.showContextMenu)

        theme = studioqt.Theme()
        w.setStyleSheet(theme.styleSheet())

        w.setRootPath(path)
        w.reload()

        w.show()
        w.setIgnoreFilter(ignoreFilter)
        w.setFolderOrderIndex(trashPath, 0)

        w.itemSelectionChanged.connect(itemSelectionChanged)

    return w
def showExample():
    """
    Run a simple example of the widget.
    
    :rtype: QtWidgets.QWidget
    """
    with studioqt.app():

        def triggered():
            print 'Triggered'

        def triggered2():
            print 'Triggered2'

        widget = studioqt.MenuBarWidget()
        icon = studioqt.icon('add')
        action = widget.addLeftAction('New Item')
        action.setIcon(icon)
        action.triggered.connect(triggered)
        lineedit = QtWidgets.QLineEdit()
        widget.layout().insertWidget(1, lineedit)
        widget.setExpandedHeight(35)
        icon = studioqt.icon('settings')
        action = widget.addRightAction('Settings')
        action.setIcon(icon)
        action.triggered.connect(triggered2)
        widget.show()
        return widget
Exemple #4
0
def showExample():
    """
    Run a simple example of the search widget.

    :rtype: SearchWidget
    """

    with studioqt.app():

        def searchFinished():
            print('-' * 25)
            print('Found: {}'.format(len(dataset.results())))

            for data in dataset.results():
                print('Match:', data)

        data = [
            {'text': 'This is a dog'},
            {'text': 'I love cats'},
            {'text': 'How man eggs can you eat?'},
        ]

        dataset = studiolibrary.Dataset()
        dataset.setData(data)
        dataset.searchFinished.connect(searchFinished)

        widget = SearchWidget()
        widget.setDataset(dataset)
        widget.show()

        return widget
Exemple #5
0
def showExample():
    with studioqt.app():
        title = 'Create a snapshot icon'
        message = 'Would you like to create a snapshot icon?'
        options = QtWidgets.QDialogButtonBox.Yes | QtWidgets.QDialogButtonBox.Ignore | QtWidgets.QDialogButtonBox.Cancel
        result = MessageBox.question(None, title, message, options)
        title = 'Create a snapshot icon'
        message = 'This is to test a very long message. This is to test a very long message. This is to test a very long message. This is to test a very long message. This is to test a very long message. '
        options = QtWidgets.QDialogButtonBox.Yes | QtWidgets.QDialogButtonBox.Ignore | QtWidgets.QDialogButtonBox.Cancel
        result = MessageBox.question(None, title, message, options)
        if result == QtWidgets.QDialogButtonBox.Yes:
            title = 'Error while saving!'
            message = 'There was an error while saving'
            result = MessageBox.critical(None, title, message)
def showExample():
    with studioqt.app():
        title = 'Create a snapshot icon'
        message = 'Would you like to create a snapshot icon?'
        options = QtWidgets.QDialogButtonBox.Yes | QtWidgets.QDialogButtonBox.Ignore | QtWidgets.QDialogButtonBox.Cancel
        result = MessageBox.question(None, title, message, options)
        title = 'Create a snapshot icon'
        message = 'This is to test a very long message. This is to test a very long message. This is to test a very long message. This is to test a very long message. This is to test a very long message. '
        options = QtWidgets.QDialogButtonBox.Yes | QtWidgets.QDialogButtonBox.Ignore | QtWidgets.QDialogButtonBox.Cancel
        result = MessageBox.question(None, title, message, options)
        if result == QtWidgets.QDialogButtonBox.Yes:
            title = 'Error while saving!'
            message = 'There was an error while saving'
            result = MessageBox.critical(None, title, message)
Exemple #7
0
def main(
    name=None,
    path=None,
    show=True,
    plugins=None,
    analytics=True,
    root=None,  # Legacy
    **kwargs
):
    """
    The main entry point for creating and loading a library.

    :type name: str
    :type path: str
    :type show: bool
    :type plugins: list[str]
    :type analytics: bool
    :type root: str
    :type kwargs: dict
    :rtype: studiolibrary.Library
    """
    studiolibrary.analytics().setEnabled(analytics)

    if not name:
        library = studiolibrary.Library.default()
    else:
        library = studiolibrary.Library.instance(name)

    if plugins is None:
        library.setPlugins(studiolibrary.Library.DEFAULT_PLUGINS)
    else:
        library.setPlugins(plugins)

    if root:  # Legacy
        path = root

    if path:
        library.setPath(path)

    studiolibrary.enableMayaClosedEvent()

    if show:
        with studioqt.app():
            library.show(**kwargs)

    return library
def showExample():
    """
    Run a simple example of the search widget.
    
    :rtype: SearchWidget
    """
    with studioqt.app():
        searchWidget = studioqt.SearchWidget()
        items = ['This is a dog', 'I love cats', 'how man eggs can you eat?']

        def searchChanged():
            print '--- Search changed! ---'
            searchFilter = searchWidget.searchFilter()
            for item in items:
                print 'Match:', searchFilter.match(item), searchFilter.matches(), item

        searchWidget.searchChanged.connect(searchChanged)
        searchWidget.show()
        return searchWidget
Exemple #9
0
def showExample():
    """
    Run a simple example of the search widget.
    
    :rtype: SearchWidget
    """
    with studioqt.app():
        searchWidget = studioqt.SearchWidget()
        items = ['This is a dog', 'I love cats', 'how man eggs can you eat?']

        def searchChanged():
            print '--- Search changed! ---'
            searchFilter = searchWidget.searchFilter()
            for item in items:
                print 'Match:', searchFilter.match(
                    item), searchFilter.matches(), item

        searchWidget.searchChanged.connect(searchChanged)
        searchWidget.show()
        return searchWidget
Exemple #10
0
def showExample():
    """
    Run a simple example of the widget.

    :rtype: QtWidgets.QWidget
    """

    with studioqt.app():

        menuBarWidget = MenuBarWidget(None)

        def setIconColor():
            menuBarWidget.setIconColor(QtGui.QColor(255, 255, 0))

        def collapse():
            menuBarWidget.collapse()

        menuBarWidget.show()

        action = menuBarWidget.addAction("Collapse")
        action.triggered.connect(collapse)

        w = QtWidgets.QLineEdit()
        menuBarWidget.addWidget(w)

        icon = studiolibrary.resource().icon("add")
        menuBarWidget.addAction(icon, "Plus")
        menuBarWidget.setStyleSheet("""
background-color: rgb(0,200,100);
spacing:5px;
        """)

        menuBarWidget.setChildrenHeight(50)

        action = QtWidgets.QAction("Yellow", None)
        action.triggered.connect(setIconColor)
        menuBarWidget.insertAction("Plus", action)
        menuBarWidget.setGeometry(400, 400, 400, 100)

        menuBarWidget.expand()
def showExample():
    """
    Run a simple example of the widget.

    :rtype: QtWidgets.QWidget
    """

    with studioqt.app():

        menuBarWidget = MenuBarWidget(None)

        def setIconColor():
            menuBarWidget.setIconColor(QtGui.QColor(255, 255, 0))

        def collapse():
            menuBarWidget.collapse()

        menuBarWidget.show()

        action = menuBarWidget.addAction("Collapse")
        action.triggered.connect(collapse)

        w = QtWidgets.QLineEdit()
        menuBarWidget.addWidget(w)

        icon = studiolibrary.resource().icon("add")
        menuBarWidget.addAction(icon, "Plus")
        menuBarWidget.setStyleSheet("""
background-color: rgb(0,200,100);
spacing:5px;
        """)

        menuBarWidget.setChildrenHeight(50)

        action = QtWidgets.QAction("Yellow", None)
        action.triggered.connect(setIconColor)
        menuBarWidget.insertAction("Plus", action)
        menuBarWidget.setGeometry(400, 400, 400, 100)

        menuBarWidget.expand()
        "rgb(80, 200, 140)",
        "rgb(50, 180, 240)",
        "rgb(110, 110, 240)",
    ]

    action = ColorPickerAction(menu)
    action.picker().setColors(colors)
    menu.addAction(action)

    colors = [
        "rgb(20, 20, 20)",
        "rgb(20, 30, 40)",
        "rgb(40, 40, 40)",
        "rgb(40, 50, 60)",
        "rgb(60, 60, 60)",
        "rgb(60, 70, 80)",
        "rgb(240, 240, 240)",
    ]

    action = ColorPickerAction(menu)
    action.picker().setColors(colors)
    menu.addAction(action)
    menu.addSeparator()

    menu.exec_()


if __name__ == "__main__":
    with studioqt.app():
        example()
Exemple #13
0
        }

        return options

    def styleSheet(self):
        """
        Return the style sheet for this theme.

        :rtype: str
        """
        options = self.options()
        path = studiolibrary.resource().get("css", "default.css")
        styleSheet = studioqt.StyleSheet.fromPath(path, options=options, dpi=self.dpi())
        return styleSheet.data()


def example():
    """
    Run a simple example of theme menu.

    :rtype: None
    """
    theme = showThemesMenu()
    print("Accent color:", theme.accentColor())
    print("Background color:", theme.backgroundColor())


if __name__ == "__main__":
    with studioqt.app():
        example()
def testMessageBox():

    with studioqt.app():

        title = "Test question dialog"
        text = "Would you like to create a snapshot icon?"

        buttons = QtWidgets.QDialogButtonBox.Yes | \
                  QtWidgets.QDialogButtonBox.Ignore | \
                  QtWidgets.QDialogButtonBox.Cancel

        result = MessageBox.question(None, title, text, buttons=buttons)
        print(result)

        title = "Test long text message"
        text = "This is to test a very long message. " \
               "This is to test a very long message. " \
               "This is to test a very long message. " \
               "This is to test a very long message. " \
               "This is to test a very long message. "

        buttons = QtWidgets.QDialogButtonBox.Yes | \
                  QtWidgets.QDialogButtonBox.Ignore | \
                  QtWidgets.QDialogButtonBox.Cancel

        result = MessageBox.question(None, title, text, buttons=buttons)
        print(result)

        title = "Test checkbox"
        text = "Testing the don't show check box. "

        buttons = QtWidgets.QDialogButtonBox.Ok | \
                  QtWidgets.QDialogButtonBox.Cancel

        print(
            studiolibrary.widgets.MessageBox.input(
                None,
                "Rename",
                "Rename the selected item?",
                inputText="face.anim",
            ))

        result = MessageBox.question(None,
                                     title,
                                     text,
                                     buttons=buttons,
                                     enableDontShowCheckBox=True)
        print(result)

        title = "Create a new thumbnail icon"
        text = "This will override the existing thumbnail. " \
               "Are you sure you would like to continue?"

        buttons = QtWidgets.QDialogButtonBox.Yes | \
                  QtWidgets.QDialogButtonBox.No

        result = MessageBox.warning(None,
                                    title,
                                    text,
                                    buttons=buttons,
                                    enableDontShowCheckBox=True)
        print(result)

        title = "Error saving item!"
        text = "An error has occurred while saving an item."
        result = MessageBox.critical(None, title, text)
        print(result)

        if result == QtWidgets.QDialogButtonBox.Yes:
            title = "Error while saving!"
            text = "There was an error while saving"
            MessageBox.critical(None, title, text)