def allow_equation_change(self, response: QAbstractButton): """Allow Equation Change""" # selected: QItemSelection = self.state_data['selected'] deselected: QItemSelection = self.state_data['deselected'] dirty_data = self.state_data['dirty_data'] if response.text() == 'Discard': print('Ok') self.refresh_equation_details() elif response.text() == 'Save': d_rcd = deselected.indexes() ind = d_rcd[0].row() deselected_eqn = self.eq.selected_data_records[ind] new_dd: dict = dirty_data['new'] eq_id = deselected_eqn.Index self.eq.update(an_id=eq_id, data=new_dd, verbose=True) if 'name' in new_dd.keys(): item = self.equation_listbox.item(ind) item.setText(new_dd['name']) dirty_data = dict(new=None, old=None) self.state_data.update(dirty_data=dirty_data) # response.close() self.reset_selected_equation_data() self.refresh_equation_details()
def show_selection_menu( control: QAbstractButton, default: object, mode: type = object, ) -> object: """ Shows the selection menu. :param control: Button to drop the menu down from. :param default: Currently selected item :param mode: What we are capable of selecting (as a `type`). :return: The selection made. This will have already been committed to `actions` if `actions` is a `GuiActions` object. """ model = groot.global_view.current_model() selection = default alive = [] root = QMenu() root.setTitle( "Make selection" ) # Sequences _add_submenu( "Genes", mode, alive, model.genes, root, selection, resources.black_gene ) # Edges _add_submenu( "Edges", mode, alive, model.genes, root, selection, resources.black_edge, expand_functions = [groot.Gene.iter_edges] ) # Components _add_submenu( "Components", mode, alive, model.components, root, selection, resources.black_major ) # Components - FASTA (unaligned) _add_submenu( "Component FASTA (unaligned)", mode, alive, (x.named_unaligned_fasta for x in model.components), root, selection, resources.black_alignment ) # Domains _add_submenu( "Domains", mode, alive, model.genes, root, selection, resources.black_domain, expand_functions = [groot.Gene.iter_userdomains] ) # Components - FASTA (aligned) _add_submenu( "Component FASTA (aligned)", mode, alive, (x.named_aligned_fasta for x in model.components), root, selection, resources.black_alignment ) # Components - trees (rooted) _add_submenu( "Component trees (rooted)", mode, alive, (x.named_tree for x in model.components), root, selection, resources.black_tree ) # Components - trees (unrooted) _add_submenu( "Component trees (unrooted)", mode, alive, (x.named_tree_unrooted for x in model.components), root, selection, resources.black_tree ) # Fusions _add_submenu( "Fusion events", mode, alive, model.fusions, root, selection, resources.black_fusion ) # Fusion formations _add_submenu( "Fusion formations", mode, alive, model.fusions, root, selection, resources.black_fusion, expand_functions = [lambda x: x.formations] ) # Fusion points _add_submenu( "Fusion points", mode, alive, model.fusions, root, selection, resources.black_fusion, expand_functions = [lambda x: x.formations, lambda x: x.points] ) # Splits _add_submenu( "Splits", mode, alive, model.splits, root, selection, resources.black_split, create_index = True ) # Consensus _add_submenu( "Consensus", mode, alive, model.consensus, root, selection, resources.black_consensus, create_index = True ) # Subsets _add_submenu( "Subsets", mode, alive, model.subsets, root, selection, resources.black_subset ) # Pregraphs _add_submenu( "Pregraphs", mode, alive, model.iter_pregraphs(), root, selection, resources.black_pregraph ) # Subgraphs _add_submenu( "Supertrees", mode, alive, model.subgraphs, root, selection, resources.black_subgraph ) # NRFG - clean _add_submenu( "Fusion graphs", mode, alive, (model.fusion_graph_unclean, model.fusion_graph_clean), root, selection, resources.black_nrfg ) # NRFG - report _add_submenu( "Reports", mode, alive, (model.report,), root, selection, resources.black_check ) # Usergraphs _add_submenu( "User graphs", mode, alive, model.user_graphs, root, selection, resources.black_nrfg ) # Usergraphs _add_submenu( "User reports", mode, alive, model.user_reports, root, selection, resources.black_check ) # Special if len( root.actions() ) == 0: act = QAction() act.setText( "List is empty" ) act.setEnabled( False ) act.tag = None alive.append( act ) root.addAction( act ) elif len( root.actions() ) == 1: root = root.actions()[0].menu() # Show menu orig = control.text() control.setText( root.title() ) root.setStyleSheet( _MENU_CSS ) selected = root.exec_( control.mapToGlobal( QPoint( 0, control.height() ) ) ) control.setText( orig ) if selected is None: return None return selected.tag
def _btnclick(self, btn: QAbstractButton): self.out = btn.text().lstrip("&").replace(' ', '').lower()
def _(btn: W.QAbstractButton): return btn.text().replace("&", "")