Esempio n. 1
0
    def __init__(self, data, parent=None):
        super(CustomListModel, self).__init__(parent)
        self.items = data
        index = QtCore.QModelIndex()
        self.beginInsertRows(index, 0, len(data))
        for item in data:
            self.beginInsertRows(index, 0, 0)
            pass
        self.endInsertRows()

        self.icons = []
        app_path = os.path.dirname(os.path.realpath(__file__))
        self.icons.append(
            QtGui.QIcon(os.path.join(app_path, 'res/not_converted.png')))
        self.icons.append(QtGui.QIcon(os.path.join(app_path,
                                                   'res/source.png')))
        self.icons.append(QtGui.QIcon(os.path.join(app_path, 'res/exr.png')))
def main(launch_args):
    # Be sure server won't crash at any moment but just print traceback
    sys.excepthook = safe_excepthook

    # Create QtApplication for tools
    # - QApplicaiton is also main thread/event loop of the server
    qt_app = QtWidgets.QApplication([])

    # Execute pipeline installation
    api.install(tvpaint)

    # Create Communicator object and trigger launch
    # - this must be done before anything is processed
    communicator = CommunicationWrapper.create_communicator(qt_app)
    communicator.launch(launch_args)

    def process_in_main_thread():
        """Execution of `MainThreadItem`."""
        item = communicator.main_thread_listen()
        if item:
            item.execute()

    timer = QtCore.QTimer()
    timer.setInterval(100)
    timer.timeout.connect(process_in_main_thread)
    timer.start()

    # Register terminal signal handler
    def signal_handler(*_args):
        print("You pressed Ctrl+C. Process ended.")
        communicator.stop()

    signal.signal(signal.SIGINT, signal_handler)
    signal.signal(signal.SIGTERM, signal_handler)

    qt_app.setQuitOnLastWindowClosed(False)
    qt_app.setStyleSheet(style.load_stylesheet())

    # Load avalon icon
    icon_path = get_icon_path()
    if icon_path:
        icon = QtGui.QIcon(icon_path)
        qt_app.setWindowIcon(icon)

    # Set application name to be able show application icon in task bar
    if platform.system().lower() == "windows":
        ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(
            u"WebsocketServer")

    # Run Qt application event processing
    sys.exit(qt_app.exec_())
Esempio n. 3
0
File: lib.py Progetto: kalisp/pype
def _show_no_gui():
    """
    Popup with information about how to register a new GUI
    In the event of no GUI being registered or available,
    this information dialog will appear to guide the user
    through how to get set up with one.
    """

    messagebox = QtWidgets.QMessageBox()
    messagebox.setIcon(messagebox.Warning)
    messagebox.setWindowIcon(
        QtGui.QIcon(
            os.path.join(os.path.dirname(pyblish.__file__), "icons",
                         "logo-32x32.svg")))

    spacer = QtWidgets.QWidget()
    spacer.setMinimumSize(400, 0)
    spacer.setSizePolicy(QtWidgets.QSizePolicy.Minimum,
                         QtWidgets.QSizePolicy.Expanding)

    layout = messagebox.layout()
    layout.addWidget(spacer, layout.rowCount(), 0, 1, layout.columnCount())

    messagebox.setWindowTitle("Uh oh")
    messagebox.setText("No registered GUI found.")

    if not pyblish.api.registered_guis():
        messagebox.setInformativeText(
            "In order to show you a GUI, one must first be registered. "
            "Press \"Show details...\" below for information on how to "
            "do that.")

        messagebox.setDetailedText(
            "Pyblish supports one or more graphical user interfaces "
            "to be registered at once, the next acting as a fallback to "
            "the previous."
            "\n"
            "\n"
            "For example, to use Pyblish Lite, first install it:"
            "\n"
            "\n"
            "$ pip install pyblish-lite"
            "\n"
            "\n"
            "Then register it, like so:"
            "\n"
            "\n"
            ">>> import pyblish.api\n"
            ">>> pyblish.api.register_gui(\"pyblish_lite\")"
            "\n"
            "\n"
            "The next time you try running this, Lite will appear."
            "\n"
            "See http://api.pyblish.com/register_gui.html for "
            "more information.")

    else:
        messagebox.setInformativeText(
            "None of the registered graphical user interfaces "
            "could be found."
            "\n"
            "\n"
            "Press \"Show details\" for more information.")

        messagebox.setDetailedText("These interfaces are currently registered."
                                   "\n"
                                   "%s" %
                                   "\n".join(pyblish.api.registered_guis()))

    messagebox.setStandardButtons(messagebox.Ok)
    messagebox.exec_()
Esempio n. 4
0
def menu_install():
    """
    Installing menu into Hiero

    """
    from . import (publish, launch_workfiles_app, reload_config,
                   apply_colorspace_project, apply_colorspace_clips)
    # here is the best place to add menu
    from avalon.tools import cbloader, creator, sceneinventory
    from avalon.vendor.Qt import QtGui

    menu_name = os.environ['AVALON_LABEL']

    context_label = "{0}, {1}".format(Session["AVALON_ASSET"],
                                      Session["AVALON_TASK"])

    self._change_context_menu = context_label

    try:
        check_made_menu = findMenuAction(menu_name)
    except Exception:
        check_made_menu = None

    if not check_made_menu:
        # Grab Hiero's MenuBar
        menu = hiero.ui.menuBar().addMenu(menu_name)
    else:
        menu = check_made_menu.menu()

    context_label_action = menu.addAction(context_label)
    context_label_action.setEnabled(False)

    menu.addSeparator()

    workfiles_action = menu.addAction("Work Files...")
    workfiles_action.setIcon(QtGui.QIcon("icons:Position.png"))
    workfiles_action.triggered.connect(launch_workfiles_app)

    default_tags_action = menu.addAction("Create Default Tags...")
    default_tags_action.setIcon(QtGui.QIcon("icons:Position.png"))
    default_tags_action.triggered.connect(tags.add_tags_to_workfile)

    menu.addSeparator()

    publish_action = menu.addAction("Publish...")
    publish_action.setIcon(QtGui.QIcon("icons:Output.png"))
    publish_action.triggered.connect(
        lambda *args: publish(hiero.ui.mainWindow()))

    creator_action = menu.addAction("Create...")
    creator_action.setIcon(QtGui.QIcon("icons:CopyRectangle.png"))
    creator_action.triggered.connect(creator.show)

    loader_action = menu.addAction("Load...")
    loader_action.setIcon(QtGui.QIcon("icons:CopyRectangle.png"))
    loader_action.triggered.connect(cbloader.show)

    sceneinventory_action = menu.addAction("Manage...")
    sceneinventory_action.setIcon(QtGui.QIcon("icons:CopyRectangle.png"))
    sceneinventory_action.triggered.connect(sceneinventory.show)
    menu.addSeparator()

    reload_action = menu.addAction("Reload pipeline...")
    reload_action.setIcon(QtGui.QIcon("icons:ColorAdd.png"))
    reload_action.triggered.connect(reload_config)

    menu.addSeparator()
    apply_colorspace_p_action = menu.addAction("Apply Colorspace Project...")
    apply_colorspace_p_action.setIcon(QtGui.QIcon("icons:ColorAdd.png"))
    apply_colorspace_p_action.triggered.connect(apply_colorspace_project)

    apply_colorspace_c_action = menu.addAction("Apply Colorspace Clips...")
    apply_colorspace_c_action.setIcon(QtGui.QIcon("icons:ColorAdd.png"))
    apply_colorspace_c_action.triggered.connect(apply_colorspace_clips)

    self.context_label_action = context_label_action
    self.workfile_actions = workfiles_action
    self.default_tags_action = default_tags_action
    self.publish_action = publish_action
    self.reload_action = reload_action
Esempio n. 5
0
File: menu.py Progetto: kalisp/pype
def install():
    """
    Installing menu into Nukestudio

    """

    # here is the best place to add menu
    from avalon.tools import publish, cbloader
    from avalon.vendor.Qt import QtGui

    menu_name = os.environ['AVALON_LABEL']

    context_label = "{0}, {1}".format(Session["AVALON_ASSET"],
                                      Session["AVALON_TASK"])

    self._change_context_menu = context_label

    try:
        check_made_menu = findMenuAction(menu_name)
    except Exception:
        check_made_menu = None

    if not check_made_menu:
        # Grab Hiero's MenuBar
        menu = hiero.ui.menuBar().addMenu(menu_name)
    else:
        menu = check_made_menu.menu()

    context_label_action = menu.addAction(context_label)
    context_label_action.setEnabled(False)

    menu.addSeparator()

    workfiles_action = menu.addAction("Work Files...")
    workfiles_action.setIcon(QtGui.QIcon("icons:Position.png"))
    workfiles_action.triggered.connect(set_workfiles)

    default_tags_action = menu.addAction("Create Default Tags...")
    default_tags_action.setIcon(QtGui.QIcon("icons:Position.png"))
    default_tags_action.triggered.connect(add_tags_from_presets)

    menu.addSeparator()

    publish_action = menu.addAction("Publish...")
    publish_action.setIcon(QtGui.QIcon("icons:Output.png"))
    publish_action.triggered.connect(
        lambda *args: publish.show(hiero.ui.mainWindow()))

    loader_action = menu.addAction("Load...")
    loader_action.setIcon(QtGui.QIcon("icons:CopyRectangle.png"))
    loader_action.triggered.connect(cbloader.show)
    menu.addSeparator()

    reload_action = menu.addAction("Reload pipeline...")
    reload_action.setIcon(QtGui.QIcon("icons:ColorAdd.png"))
    reload_action.triggered.connect(reload_config)

    # Is this required?
    # hiero.ui.registerAction(context_label_action)
    # hiero.ui.registerAction(workfiles_action)
    # hiero.ui.registerAction(default_tags_action)
    # hiero.ui.registerAction(publish_action)
    # hiero.ui.registerAction(loader_action)
    # hiero.ui.registerAction(reload_action)

    self.context_label_action = context_label_action
    self.workfile_actions = workfiles_action
    self.default_tags_action = default_tags_action
    self.publish_action = publish_action
    self.reload_action = reload_action