def _on_search_box_selection_changed(self, text): """ Called when text in the search box is changed by the user or script. :param text: New text in the search box. """ with block_signals(self.tree): self.tree.setCurrentIndex(QModelIndex()) with block_signals(self.search_box): i = self.search_box.findText(text) if i >= 0: self.search_box.setCurrentIndex(i)
def _on_search_box_selection_changed(self, text): """ Called when text in the search box is changed by the user or script. :param text: New text in the search box. """ # if the function is called without text, avoid doing anything if text == '': return with block_signals(self.tree): self.tree.setCurrentIndex(QModelIndex()) with block_signals(self.search_box): i = self.search_box.findText(text) if i >= 0: self.search_box.setCurrentIndex(i)
def remove_selected_curve_list_entry(self): """ Remove selected entry in 'select_curve_list'. If no curves remain on the axes remove the axes entry from the 'select_axes_combo_box'. If no axes with curves remain close the tab and return True """ with block_signals(self.view.select_curve_list), block_signals(self.view.select_axes_combo_box): self.view.remove_select_curve_list_selected_items() if self.view.select_curve_list.count() == 0: self.view.remove_select_axes_combo_box_selected_item() if self.view.select_axes_combo_box.count() == 0: self.close_tab() if self.legend_tab: self.legend_tab.close_tab() return True
def _on_tree_selection_changed(self): """ Called when selection in the tree widget changes by user clicking or a script. """ selected_algorithm = self._get_selected_tree_item() if selected_algorithm is not None: with block_signals(self.search_box): i = self.search_box.findText(selected_algorithm.name) self.search_box.setCurrentIndex(i)
def _populate_select_curve_combo_box(self): """ Add curves on selected axes to the 'select curves' combo box. Return False if there are no lines on the axes (this can occur when a user uses the "Remove Curve" button), else return True. """ with block_signals(self.view.select_curve_combo_box): self.view.select_curve_combo_box.clear() selected_ax = self.get_selected_ax() if not selected_ax: self.view.close() return False # Get the lines in the order that they are listed on the legend. active_lines = datafunctions.get_legend_handles(selected_ax) for line in active_lines: self._update_selected_curve_name(line) self.view.populate_select_curve_combo_box(list(self.curve_names_dict)) return True
def _populate_select_curve_combo_box(self): """ Add curves on selected axes to the 'select curves' combo box. Return False if there are no lines on the axes (this can occur when a user uses the "Remove Curve" button), else return True. """ with block_signals(self.view.select_curve_combo_box): self.view.select_curve_combo_box.clear() selected_ax = self.get_selected_ax() if not selected_ax: self.view.close() return False active_lines = self.get_curves_from_ax(selected_ax) for line in active_lines: self._update_selected_curve_name(line) self.view.populate_select_curve_combo_box( sorted(self.curve_names_dict.keys(), key=lambda s: s.lower())) return True
def populate_select_curve_list(self, curve_names): with block_signals(self.select_curve_list): self.select_curve_list.clear() self.select_curve_list.addItems(curve_names) self.select_curve_list.setCurrentRow(0)
def populate_select_axes_combo_box(self, axes_names): with block_signals(self.select_axes_combo_box): self.select_axes_combo_box.clear() self.select_axes_combo_box.addItems(axes_names)
def populate_select_image_combo_box_and_update_view(self): with block_signals(self.view.select_image_combo_box): self._populate_select_image_combo_box() self.update_view()