Пример #1
0
    def __add_workflow(self, stage: Stage):
        assert isinstance(stage, Stage), stage

        path = ["Workflow", stage.name]
        mnu = self.__add_menu(path, headline=stage.headline)

        self.__add_workflow_menu(path + ["Create"],
                                 handlers().list_avail(EIntent.CREATE, stage),
                                 icon=resources.create)
        self.__add_workflow_menu(path + ["Drop"],
                                 handlers().list_avail(EIntent.DROP, stage),
                                 icon=resources.remove)
        self.__add_workflow_menu(path + ["View"],
                                 handlers().list_avail(EIntent.VIEW, stage),
                                 icon=resources.view)

        self.stages[stage] = mnu

        exe = _ActStage(self.gui_actions, stage)
        self.keep_alive.append(exe)

        lay: QHBoxLayout = self.frm_main.ui.FRA_WORKFLOW.layout()
        btn = self.__make_button()
        btn.setText(stage.name)
        btn.setIcon(stage.icon.icon())
        btn.clicked[bool].connect(exe.execute)
        self.workflow_buttons.append((stage, btn, stage.icon.path))
        lay.addWidget(btn)
Пример #2
0
    def domain_fake_fn(self, model_view: ModelView,
                       algo: groot.domain_algorithms.Algorithm):
        """
        Wraps `groot.create_domains` into a method suitable for calling via `show_intent_menu`.
        """
        ignore(model_view)

        # Any extra args
        if len(FunctionInspector(algo.function).args
               ) > groot.domain_algorithms.num_expected_args:
            handlers().CREATE_DOMAINS.execute(self, EIntent.INSPECT, algo)
        else:
            self.actions.run(groot.create_domains, algorithm=algo)
Пример #3
0
    def inspect_elsewhere(self, tgt):
        if tgt is None:
            return

        if mh.array_helper.is_simple_iterable(tgt):
            if len(tgt) == 1:
                tgt = mhelper.array_helper.single(tgt)
            else:
                tgt = self.show_menu(*tgt)

                if tgt is None:
                    return

        handlers_ = handlers().list_avail(EIntent.INSPECT, type(tgt))
        menu = qt.QMenu()
        acm = {}

        qt.menu_helper.add_section(
            menu, "{}: {}".format(type(tgt).__name__, str(tgt)))

        for handler in handlers_:
            act = QAction()
            menu.addAction(act)
            acm[act] = handler
            act.setText(handler.name)
            if handler.icon:
                act.setIcon(handler.icon.icon())

        act = self.show_menu(menu)

        if act is None:
            return

        acm[act].execute(self, EIntent.INSPECT, tgt)
Пример #4
0
    def __init__(self, parent):
        """
        CONSTRUCTOR
        """
        super().__init__(parent)
        self.ui = frm_startup_designer.Ui_Dialog(self)
        self.setWindowTitle("Startup")

        txt = self.ui.LBL_FIRST_MESSAGE.text()

        txt = txt.replace("$(VERSION)", Controller.ACTIVE.app.version)
        r = []

        r.append("<h3>Recent files</h3><ul>")

        for file in reversed(groot.data.config.options().recent_files):
            assert isinstance(file, RecentFile)
            r.append('<li><a href="file_load:{}">{}</a></li>'.format(
                file.file_name,
                file_helper.get_filename_without_extension(file.file_name)))

        r.append('<li><a href="action:{}"><i>browse...</i></a></li>'.format(
            gui_workflow.handlers().ACT_FILE_OPEN))
        r.append("</ul>")

        r.append("<h3>Sample data</h3><ul>")

        for file in groot.data.sample_data.get_samples():
            r.append('<li><a href="file_sample:{}">{}</a><li/>'.format(
                file, file_helper.get_filename_without_extension(file)))

        r.append('<li><a href="action:{}"><i>browse...</i></a></li>'.format(
            gui_workflow.handlers().VIEW_OPEN_FILE))
        r.append("</ul>")

        txt = txt.replace("$(RECENT_FILES)", "\n".join(r))

        self.ui.LBL_FIRST_MESSAGE.setText(txt)
        self.bind_to_label(self.ui.LBL_FIRST_MESSAGE)
Пример #5
0
 def __init__( self ) -> None:
     """
     CONSTRUCTOR
     """
     # QT stuff
     FrmMain.INSTANCE = self
     QCoreApplication.setAttribute( Qt.AA_DontUseNativeMenuBar )
     QMainWindow.__init__( self )
     self.ui = frm_main_designer.Ui_MainWindow()
     self.ui.setupUi( self )
     self.setWindowTitle( "Lego Model Creator" )
     
     controller : intermake_qt.GuiController = cast(intermake_qt.GuiController, Controller.ACTIVE)
     
     self.mdi: Dict[str, FrmBase] = { }
     
     self.COLOUR_EMPTY = QColor( controller.style_sheet_parsed.get( 'QMdiArea[style="empty"].background', "#E0E0E0" ) )
     self.COLOUR_NOT_EMPTY = QColor( controller.style_sheet_parsed.get( 'QMdiArea.background', "#E0E0E0" ) )
     
     self.ui.MDI_AREA.setBackground( self.COLOUR_EMPTY )
     
     self.showMaximized()
     
     global_options = groot.data.config.options()
     self.mdi_mode = global_options.window_mode != EWindowMode.BASIC
     self.ui.FRA_FILE.setVisible( global_options.tool_file )
     self.ui.FRA_VISUALISERS.setVisible( global_options.tool_visualisers )
     self.ui.FRA_WORKFLOW.setVisible( global_options.tool_workflow )
     
     if global_options.window_mode == EWindowMode.TDI:
         self.ui.MDI_AREA.setViewMode( QMdiArea.TabbedView )
         self.ui.MDI_AREA.setDocumentMode( True )
     
     from groot_gui.utilities.gui_menu import GuiMenu
     self.menu_handler = GuiMenu( self )
     self.actions = self.menu_handler.gui_actions
     
     view = groot.data.config.options().startup_mode
     
     if global_view.current_model().get_status( constants.STAGES.SEQ_AND_SIM_ps ).is_none:
         if view == EStartupMode.STARTUP:
             handlers().VIEW_STARTUP.execute( self, EIntent.DIRECT, None )
         elif view == EStartupMode.WORKFLOW:
             handlers().VIEW_WORKFLOW.execute( self, EIntent.DIRECT, None )
         elif view == EStartupMode.SAMPLES:
             handlers().VIEW_OPEN_FILE.execute( self, EIntent.DIRECT, None )
         elif view == EStartupMode.NOTHING:
             pass
         else:
             raise mh.SwitchError( "view", view )
     
     self.completed_changes = None
     self.completed_plugin = None
     self.update_title()
     self.menu_handler.update_buttons()
Пример #6
0
    def by_url(self, link: str, validate=False) -> bool:
        if ":" in link:
            key, value = link.split(":", 1)
        else:
            key = link
            value = None

        if key == "action":
            try:
                visualiser = gui_workflow.handlers().find_by_key(value)
            except KeyError:
                if validate:
                    return False
                else:
                    raise

            if validate:
                return True

            visualiser.execute(self.window, EIntent.DIRECT, None)
        elif key == "file_save":
            if validate:
                return True

            self.run(groot.file_save, value)
        elif key == "file_load":
            if validate:
                return True

            self.run(groot.file_load, value)
        elif key == "file_sample":
            if validate:
                return True

            self.run(groot.file_sample, value)
        else:
            if validate:
                return False
            else:
                raise SwitchError("link", link)
Пример #7
0
 def on_BTN_CONTINUE_clicked( self ) -> None:
     """
     Signal handler:
     """
     handlers().ACT_WIZARD_NEXT.execute( self, EIntent.DIRECT, None )
Пример #8
0
    def __init__(self, frm_main: QMainWindow):
        """
        Creates the menu.
        """
        from groot_gui.forms.frm_main import FrmMain
        assert isinstance(frm_main, FrmMain)
        ui = frm_main.ui
        vis = gui_workflow.handlers()

        self.frm_main: FrmMain = frm_main
        self.menu_bar: QMenuBar = self.frm_main.menuBar()
        self.menus = {}
        self.keep_alive = []
        self.headlines = []
        self.stages = {}
        self.workflow_buttons = []
        self.gui_actions: GuiActions = GuiActions(self.frm_main, self.frm_main)

        self.mnu_file = self.__add_menu(
            ["File"], headline=lambda m: constants.STAGES._FILE_0.headline(m))
        self.__add_action(["File", "New"],
                          handler=vis.ACT_FILE_NEW,
                          toolbar=ui.FRA_FILE)
        self.__add_action(["File", "Open..."],
                          handler=vis.VIEW_OPEN_FILE,
                          toolbar=ui.FRA_FILE)
        self.__add_action(["File", "Recent", "r"])
        self.__add_action(["File", "-"])
        self.__add_action(["File", "Save"],
                          handler=vis.ACT_FILE_SAVE,
                          toolbar=ui.FRA_FILE)
        self.__add_action(["File", "Save &as..."], handler=vis.VIEW_SAVE_FILE)
        self.__add_action(["File", "-"])
        self.__add_action(["File", "E&xit"], handler=vis.ACT_EXIT)

        for stage in STAGES:
            self.__add_workflow(stage)

        self.mnu_windows = self.__add_menu(["Windows"])
        self.__add_action(["Windows", "&Workflow..."],
                          handler=vis.VIEW_WORKFLOW,
                          toolbar=ui.FRA_VISUALISERS)
        self.__add_action(["Windows", "&Wizard..."],
                          handler=vis.VIEW_WIZARD,
                          toolbar=ui.FRA_VISUALISERS)
        self.__add_action(["Windows", "&Preferences..."],
                          handler=vis.VIEW_PREFERENCES,
                          toolbar=ui.FRA_VISUALISERS)
        self.__add_action(["Windows", "-"], toolbar=ui.FRA_VISUALISERS)
        self.__add_action(["Windows", "Visualisers", "Reports..."],
                          handler=vis.VIEW_TEXT,
                          toolbar=ui.FRA_VISUALISERS)
        self.__add_action(["Windows", "Visualisers", "Lego..."],
                          handler=vis.VIEW_LEGO,
                          toolbar=ui.FRA_VISUALISERS)
        self.__add_action(["Windows", "Visualisers", "Alignments..."],
                          handler=vis.VIEW_ALIGNMENT,
                          toolbar=ui.FRA_VISUALISERS)
        self.__add_action(["Windows", "Visualisers", "Fusions..."],
                          handler=vis.VIEW_FUSIONS,
                          toolbar=ui.FRA_VISUALISERS)
        self.__add_action(["Windows", "Visualisers", "Splits..."],
                          handler=vis.VIEW_SPLITS,
                          toolbar=ui.FRA_VISUALISERS)
        self.__add_action(["Windows", "Visualisers", "Genes..."],
                          handler=vis.VIEW_GENES,
                          toolbar=ui.FRA_VISUALISERS)
        self.__add_action(["Windows", "Editors", "Trees..."],
                          handler=vis.CREATE_TREES)
        self.__add_action(["Windows", "Editors", "Alignment..."],
                          handler=vis.CREATE_ALIGNMENTS)
        self.__add_action(["Windows", "Editors", "Domains..."],
                          handler=vis.CREATE_DOMAINS)
        self.__add_action(["Windows", "Editors", "Subgraphs..."],
                          handler=vis.CREATE_SUBGRAPHS)
        self.__add_action(["Windows", "Others", "File open..."],
                          handler=vis.VIEW_OPEN_FILE)
        self.__add_action(["Windows", "Others", "File save..."],
                          handler=vis.VIEW_SAVE_FILE)
        self.__add_action(["Windows", "Others", "Startup..."],
                          handler=vis.VIEW_STARTUP)
        self.__add_action(["Windows", "Others", "Version..."],
                          handler=vis.VIEW_ABOUT)
        self.__add_action(["Windows", "Others", "Intermake..."],
                          handler=vis.VIEW_INTERMAKE,
                          shortcut=Qt.Key_F12)

        self.mnu_help = self.__add_menu(["Help"])
        self.__add_action(["Help", "&Usage..."], handler=vis.VIEW_MY_HELP)
        self.__add_action(["Help", "&Readme (online)..."],
                          handler=vis.VIEW_HELP)
        self.__add_action(["Help", "&About..."], handler=vis.VIEW_ABOUT)
Пример #9
0
 def get_visualiser(self, name) -> IntentHandler:
     return getattr(gui_workflow.handlers(), name.upper())
Пример #10
0
 def save_model(self) -> None:
     if self.get_model().file_name:
         self.run(groot.file_save, self.get_model().file_name)
     else:
         handlers().VIEW_SAVE_FILE.execute(self, EIntent.DIRECT, None)
Пример #11
0
 def on_BTN_DELETE_GENE_clicked(self) -> None:
     """
     Signal handler:
     """
     genes = self.__get_selected_genes()
     handlers().DROP_GENES.execute(self, EIntent.INSPECT, list(genes))
Пример #12
0
 def on_BTN_OPTIONS_clicked(self) -> None:
     """
     Signal handler:
     """
     handlers().VIEW_PREFERENCES.execute(self, EIntent.DIRECT, None)