Exemplo n.º 1
0
def run(project, install_path, paths_to_register=None, tag=None, dev=False):

    with contexts.application():
        win = ArtellaLauncher(project=project,
                              install_path=install_path,
                              paths_to_register=paths_to_register,
                              tag=tag,
                              dev=dev)
        win.show()

        return win
Exemplo n.º 2
0
def exec_dialog(widget, *args, **kwargs):
    with contexts.application():
        exec_fn = kwargs.pop('exec_fn', None)
        force_close_signal = kwargs.pop('force_close_signal', None)
        new_dialog = Dialog(*args, **kwargs)
        new_dialog.main_layout.addWidget(widget)

        if force_close_signal:
            force_close_signal.connect(new_dialog.close)

        new_dialog.exec_()

        if exec_fn and callable(exec_fn):
            exec_fn()

        yield new_dialog
Exemplo n.º 3
0
    def launch_tool_by_id(self,
                          tool_id,
                          package_name=None,
                          dev=False,
                          *args,
                          **kwargs):
        """
        Launches tool of a specific package by its ID
        :param tool_id: str, tool ID
        :param package_name: str
        :param dev: bool
        :param args: tuple, arguments to pass to the tool execute function
        :param kwargs: dict, keyword arguments to pas to the tool execute function
        :return: DccTool or None, executed tool instance
        """

        if not package_name:
            split_package = tool_id.replace('.', '-').split('-')[0]
            package_name = split_package if split_package != tool_id else 'tpDcc'

        tool_class = self.get_plugin_from_id(tool_id,
                                             package_name=package_name)
        if not tool_class:
            logger.warning(
                'Impossible to launch tool. Tool with ID "{}" not found in package "{}"'
                .format(tool_id, package_name))
            return

        settings = self.get_tool_settings_file(tool_id, package_name)
        tool_inst = tool_class(settings=settings, dev=dev, *args, **kwargs)

        self.close_tool(tool_id, package_name=package_name)

        with contexts.application():
            tool_inst._launch(*args, **kwargs)
            self._loaded_tools.setdefault(package_name, dict())
            self._loaded_tools[package_name].setdefault(tool_id, None)
            self._loaded_tools[package_name][tool_id] = tool_inst

        logger.debug('Execution time: {}'.format(
            tool_inst.stats.execution_time))

        return tool_inst
Exemplo n.º 4
0
    def launch_tool_by_id(self,
                          tool_id,
                          package_name=None,
                          dev=False,
                          *args,
                          **kwargs):
        """
        Launches tool of a specific package by its ID
        :param tool_id: str, tool ID
        :param package_name: str, str
        :param dev: bool
        :param args: tuple, arguments to pass to the tool execute function
        :param kwargs: dict, keyword arguments to pas to the tool execute function
        :return: DccTool or None, executed tool instance
        """

        tool_inst = self.get_tool_by_id(tool_id=tool_id,
                                        package_name=package_name,
                                        dev=dev,
                                        *args,
                                        **kwargs)
        if not tool_inst:
            return None

        hub = kwargs.pop('hub', False)
        if hub and tool_id != 'tpDcc-tools-hub':
            hub_ui = self.get_last_focused_hub_ui(include_minimized=False)
            if hub_ui:
                hub_ui.toggle_toolset(tool_id)
                return tool_inst
            else:
                LOGGER.warning(
                    'No HubUI tool opened. Opening tool using standard method ...'
                )

        self.close_tool(tool_id)
        with contexts.application():
            self._launch_tool(tool_inst, tool_id, *args, **kwargs)
            return tool_inst
Exemplo n.º 5
0
        tool_bar = toolbar.ToolBar(parent=self)
        tool_bar.set_children_height(50)
        toolbar_layout.addWidget(tool_bar)
        line_edit = lineedit.BaseLineEdit(parent=self)
        line_edit.setObjectName('hello')

        collapse_action = tool_bar.addAction('Collapse')
        tool_bar.addWidget(line_edit)
        tool_bar.addAction(resources.icon('add'), 'Plus')
        color_action = QAction('Yellow', None)
        tool_bar.insertAction('Plus', color_action)

        collapse_action.triggered.connect(_collapse)
        color_action.triggered.connect(_set_icon_color)

        self.main_layout.addWidget(buttons.BaseButton('Hello'))
        self.main_layout.addStretch()

        return toolbar_widget


if __name__ == '__main__':
    import tpDcc.loader
    tpDcc.loader.init()

    with contexts.application():
        widget = ToolbarExampleWidget()
        with contexts.show_window(widget):
            pass