def __init__(self): super().__init__() self.data = None # type: Optional[Table] # Main area self.model = FeatureStatisticsTableModel(parent=self) self.table_view = FeatureStatisticsTableView(self.model, parent=self) self.table_view.selectionModel().selectionChanged.connect( self.on_select) self.table_view.horizontalHeader().sectionClicked.connect( self.on_header_click) self.controlArea.layout().addWidget(self.table_view) self.color_var_model = DomainModel( valid_types=(ContinuousVariable, DiscreteVariable), placeholder='None', ) self.cb_color_var = gui.comboBox(self.buttonsArea, master=self, value='color_var', model=self.color_var_model, label='Color:', orientation=Qt.Horizontal, contentsLength=13, searchable=True) self.cb_color_var.activated.connect(self.__color_var_changed) gui.rubber(self.buttonsArea) gui.auto_send(self.buttonsArea, self, "auto_commit")
def _add_controls(self): displaybox = gui.widgetBox(self.controlArea, "Display") gui.checkBox(displaybox, self, "show_profiles", "Lines", callback=self.__show_profiles_changed, tooltip="Plot lines") gui.checkBox(displaybox, self, "show_range", "Range", callback=self.__show_range_changed, tooltip="Plot range between 10th and 90th percentile") gui.checkBox(displaybox, self, "show_mean", "Mean", callback=self.__show_mean_changed, tooltip="Plot mean curve") gui.checkBox(displaybox, self, "show_error", "Error bars", callback=self.__show_error_changed, tooltip="Show standard deviation") self.group_vars = DomainModel( placeholder="None", separators=False, valid_types=DiscreteVariable) self.group_view = gui.listView( self.controlArea, self, "group_var", box="Group by", model=self.group_vars, callback=self.__group_var_changed, sizeHint=QSize(30, 100)) self.group_view.setEnabled(False) plot_gui = OWPlotGUI(self) plot_gui.box_zoom_select(self.controlArea) gui.rubber(self.controlArea) gui.auto_send(self.controlArea, self, "auto_commit") self.info.set_input_summary(self.info.NoInput) self.info.set_output_summary(self.info.NoOutput)
def __init__(self): super().__init__() # Diagram update is in progress self._updating = False # Input update is in progress self._inputUpdate = False # Input datasets in the order they were 'connected'. self.data = {} # Extracted input item sets in the order they were 'connected' self.itemsets = {} # A list with 2 ** len(self.data) elements that store item sets # belonging to each area self.disjoint = [] # A list with 2 ** len(self.data) elements that store keys of tables # intersected in each area self.area_keys = [] # Main area view self.scene = QGraphicsScene() self.view = QGraphicsView(self.scene) self.view.setRenderHint(QPainter.Antialiasing) self.view.setBackgroundRole(QPalette.Window) self.view.setFrameStyle(QGraphicsView.StyledPanel) self.mainArea.layout().addWidget(self.view) self.vennwidget = VennDiagram() self._resize() self.vennwidget.itemTextEdited.connect(self._on_itemTextEdited) self.scene.selectionChanged.connect(self._on_selectionChanged) self.scene.addItem(self.vennwidget) controls = gui.hBox(self.mainArea) box = gui.radioButtonsInBox(controls, self, 'rowwise', [ "Columns (features)", "Rows (instances), matched by", ], box="Elements", callback=self._on_matching_changed) gui.comboBox(gui.indentedBox(box), self, "selected_feature", model=itemmodels.VariableListModel( placeholder="Instance identity"), callback=self._on_inputAttrActivated) box.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) self.outputs_box = box = gui.vBox(controls, "Output") self.output_duplicates_cb = gui.checkBox( box, self, "output_duplicates", "Output duplicates", callback=lambda: self.commit()) # pylint: disable=unnecessary-lambda gui.auto_send(box, self, "autocommit", box=False) self.output_duplicates_cb.setEnabled(bool(self.rowwise)) self._queue = []
def __init__(self): super().__init__() self._inputs = OrderedDict() self.__pending_selected_rows = self.selected_rows self.selected_rows = None self.__pending_selected_cols = self.selected_cols self.selected_cols = None self.dist_color = QColor(*self.dist_color_RGB) info_box = gui.vBox(self.controlArea, "Info") self.info_text = gui.widgetLabel(info_box) self._set_input_summary(None) self._set_output_summary(None) gui.separator(self.controlArea) box = gui.vBox(self.controlArea, "Variables") self.c_show_attribute_labels = gui.checkBox( box, self, "show_attribute_labels", "Show variable labels (if present)", callback=self._on_show_variable_labels_changed) gui.checkBox(box, self, "show_distributions", 'Visualize numeric values', callback=self._on_distribution_color_changed) gui.checkBox(box, self, "color_by_class", 'Color by instance classes', callback=self._on_distribution_color_changed) box = gui.vBox(self.controlArea, "Selection") gui.checkBox(box, self, "select_rows", "Select full rows", callback=self._on_select_rows_changed) gui.rubber(self.controlArea) reset = gui.button(None, self, "Restore Original Order", callback=self.restore_order, tooltip="Show rows in the original order", autoDefault=False) self.buttonsArea.layout().insertWidget(0, reset) gui.auto_send(self.buttonsArea, self, "auto_commit") # GUI with tabs self.tabs = gui.tabWidget(self.mainArea) self.tabs.currentChanged.connect(self._on_current_tab_changed)
def _add_controls(self): options = dict( labelWidth=75, orientation=Qt.Horizontal, sendSelectedValue=True, contentsLength=14 ) lat_lon_box = gui.vBox(self.controlArea, True) self.lat_lon_model = DomainModel(DomainModel.MIXED, valid_types=(ContinuousVariable,)) gui.comboBox(lat_lon_box, self, 'attr_lon', label='Longitude:', callback=self.setup_plot, model=self.lat_lon_model, **options) gui.comboBox(lat_lon_box, self, 'attr_lat', label='Latitude:', callback=self.setup_plot, model=self.lat_lon_model, **options) agg_box = gui.vBox(self.controlArea, True) self.agg_attr_model = DomainModel(valid_types=(ContinuousVariable, DiscreteVariable)) gui.comboBox(agg_box, self, 'agg_attr', label='Attribute:', callback=self.update_agg, model=self.agg_attr_model, **options) self.agg_func_combo = gui.comboBox(agg_box, self, 'agg_func', label='Agg.:', items=[DEFAULT_AGG_FUNC], callback=self.graph.update_colors, **options) a_slider = gui.hSlider(agg_box, self, 'admin_level', minValue=0, maxValue=2, step=1, label='Detail:', createLabel=False, callback=self.setup_plot) a_slider.setFixedWidth(176) visualization_box = gui.vBox(self.controlArea, True) b_slider = gui.hSlider(visualization_box, self, "binning_index", label="Bin width:", minValue=0, maxValue=max(1, len(self.binnings) - 1), createLabel=False, callback=self.graph.update_colors) b_slider.setFixedWidth(176) av_slider = gui.hSlider(visualization_box, self, "graph.alpha_value", minValue=0, maxValue=255, step=10, label="Opacity:", createLabel=False, callback=self.graph.update_colors) av_slider.setFixedWidth(176) gui.checkBox(visualization_box, self, "graph.show_legend", "Show legend", callback=self.graph.update_legend_visibility) self.controlArea.layout().addStretch(100) plot_gui = OWPlotGUI(self) plot_gui.box_zoom_select(self.controlArea) gui.auto_send(self.controlArea, self, "auto_commit")
def __init__(self): super().__init__() self.data = None self.removedAttrs = "-" self.reducedAttrs = "-" self.resortedAttrs = "-" self.removedClasses = "-" self.reducedClasses = "-" self.resortedClasses = "-" self.removedMetas = "-" self.reducedMetas = "-" def add_line(parent): frame = QFrame() frame.setFrameShape(QFrame.HLine) frame.setFrameShadow(QFrame.Sunken) parent.layout().addWidget(frame) boxAt = gui.vBox(self.controlArea, "Features") for value, label in self.feature_options: gui.checkBox(boxAt, self, value, label, callback=self.optionsChanged) add_line(boxAt) gui.label( boxAt, self, "Sorted: %(resortedAttrs)s, " "reduced: %(reducedAttrs)s, removed: %(removedAttrs)s") boxAt = gui.vBox(self.controlArea, "Classes") for value, label in self.class_options: gui.checkBox(boxAt, self, value, label, callback=self.optionsChanged) add_line(boxAt) gui.label( boxAt, self, "Sorted: %(resortedClasses)s," "reduced: %(reducedClasses)s, removed: %(removedClasses)s") boxAt = gui.vBox(self.controlArea, "Meta attributes") for value, label in self.meta_options: gui.checkBox(boxAt, self, value, label, callback=self.optionsChanged) add_line(boxAt) gui.label(boxAt, self, "Reduced: %(reducedMetas)s, removed: %(removedMetas)s") gui.auto_send(self.buttonsArea, self, "autoSend") self.info.set_input_summary(self.info.NoInput) self.info.set_output_summary(self.info.NoOutput)
def _add_controls(self): self.gui = OWPlotGUI(self) area = self.controlArea self._point_box = self.gui.point_properties_box(area) self._effects_box = self.gui.effects_box(area) self._plot_box = self.gui.plot_properties_box(area) self.control_area_stretch = gui.widgetBox(area) self.control_area_stretch.layout().addStretch(100) self.gui.box_zoom_select(area) gui.auto_send(area, self, "auto_commit")
def __init__(self): super().__init__() self._inputs: List[TableSlot] = [] self.__pending_selected_rows = self.selected_rows self.selected_rows = None self.__pending_selected_cols = self.selected_cols self.selected_cols = None self.dist_color = QColor(*self.dist_color_RGB) info_box = gui.vBox(self.controlArea, "信息") self.info_text = gui.widgetLabel(info_box) self._set_input_summary(None) box = gui.vBox(self.controlArea, "变量") self.c_show_attribute_labels = gui.checkBox( box, self, "show_attribute_labels", "显示变量标签(如果存在)", callback=self._on_show_variable_labels_changed) gui.checkBox(box, self, "show_distributions", '可视化数值', callback=self._on_distribution_color_changed) gui.checkBox(box, self, "color_by_class", '按实例分类上色', callback=self._on_distribution_color_changed) box = gui.vBox(self.controlArea, "选择") gui.checkBox(box, self, "select_rows", "选择整行", callback=self._on_select_rows_changed) gui.rubber(self.controlArea) gui.button(self.buttonsArea, self, "恢复原始顺序", callback=self.restore_order, tooltip="Show rows in the original order", autoDefault=False, attribute=Qt.WA_LayoutUsesWidgetRect) gui.auto_send(self.buttonsArea, self, "auto_commit") # GUI with tabs self.tabs = gui.tabWidget(self.mainArea) self.tabs.currentChanged.connect(self._on_current_tab_changed)
def __init__(self): super().__init__() self.data = None self.removedAttrs = "-" self.reducedAttrs = "-" self.resortedAttrs = "-" self.removedClasses = "-" self.reducedClasses = "-" self.resortedClasses = "-" self.removedMetas = "-" self.reducedMetas = "-" boxAt = gui.vBox(self.controlArea, "Features") for not_first, (value, label) in enumerate(self.feature_options): if not_first: gui.separator(boxAt, 2) gui.checkBox(boxAt, self, value, label, callback=self.optionsChanged) boxAt = gui.vBox(self.controlArea, "Classes", addSpace=True) for not_first, (value, label) in enumerate(self.class_options): if not_first: gui.separator(boxAt, 2) gui.checkBox(boxAt, self, value, label, callback=self.optionsChanged) boxAt = gui.vBox(self.controlArea, "Meta attributes", addSpace=True) for not_first, (value, label) in enumerate(self.meta_options): if not_first: gui.separator(boxAt, 2) gui.checkBox(boxAt, self, value, label, callback=self.optionsChanged) box3 = gui.vBox(self.controlArea, 'Statistics', addSpace=True) for i, (label, value) in enumerate(self.stat_labels): # add a separator after each group of three if i != 0 and i % 3 == 0: gui.separator(box3, 2) gui.label(box3, self, "{}: %({})s".format(label, value)) gui.auto_send(self.buttonsArea, self, "autoSend") gui.rubber(self.controlArea) self.info.set_input_summary(self.info.NoInput) self.info.set_output_summary(self.info.NoOutput)
def _add_controls(self): displaybox = gui.widgetBox(self.controlArea, "显示") gui.checkBox( displaybox, self, "show_profiles", "线", callback=self.__show_profiles_changed, tooltip="Plot lines", ) gui.checkBox( displaybox, self, "show_range", "范围", callback=self.__show_range_changed, tooltip="Plot range between 10th and 90th percentile", ) gui.checkBox( displaybox, self, "show_mean", "平均值", callback=self.__show_mean_changed, tooltip="Plot mean curve", ) gui.checkBox( displaybox, self, "show_error", "误差线", callback=self.__show_error_changed, tooltip="Show standard deviation", ) self.group_vars = DomainModel(placeholder="None", separators=False, valid_types=DiscreteVariable) self.group_view = gui.listView( self.controlArea, self, "group_var", box="分组依据", model=self.group_vars, callback=self.__group_var_changed, sizeHint=QSize(30, 100), viewType=ListViewSearch, sizePolicy=(QSizePolicy.Minimum, QSizePolicy.Expanding), ) self.group_view.setEnabled(False) plot_gui = OWPlotGUI(self) plot_gui.box_zoom_select(self.buttonsArea) gui.auto_send(self.buttonsArea, self, "auto_commit")
def __init__(self): super().__init__() self.data = None self.removedAttrs = "-" self.reducedAttrs = "-" self.resortedAttrs = "-" self.removedClasses = "-" self.reducedClasses = "-" self.resortedClasses = "-" self.removedMetas = "-" self.reducedMetas = "-" def add_line(parent): frame = QFrame() frame.setFrameShape(QFrame.HLine) frame.setFrameShadow(QFrame.Sunken) parent.layout().addWidget(frame) boxAt = gui.vBox(self.controlArea, "特征") for value, label in self.feature_options: gui.checkBox(boxAt, self, value, label, callback=self.commit.deferred) add_line(boxAt) gui.label( boxAt, self, "已排序: %(resortedAttrs)s, " "已减少: %(reducedAttrs)s, 已删除: %(removedAttrs)s") boxAt = gui.vBox(self.controlArea, "类别") for value, label in self.class_options: gui.checkBox(boxAt, self, value, label, callback=self.commit.deferred) add_line(boxAt) gui.label( boxAt, self, "已排序: %(resortedClasses)s," "已减少: %(reducedClasses)s, 已删除: %(removedClasses)s") boxAt = gui.vBox(self.controlArea, "元属性") for value, label in self.meta_options: gui.checkBox(boxAt, self, value, label, callback=self.commit.deferred) add_line(boxAt) gui.label(boxAt, self, "已减少: %(reducedMetas)s, 已删除: %(removedMetas)s") gui.auto_send(self.buttonsArea, self, "autoSend")
def __init_control_area(self) -> None: """Init all controls in the control area""" box = gui.vBox(self.controlArea, "Group by") self.gb_attrs_view = AggregateListViewSearch( selectionMode=QListView.ExtendedSelection) self.gb_attrs_view.setModel(self.gb_attrs_model) self.gb_attrs_view.selectionModel().selectionChanged.connect( self.__gb_changed) box.layout().addWidget(self.gb_attrs_view) gui.auto_send(self.buttonsArea, self, "auto_commit")
def __init__(self): OWWidget.__init__(self) ConcurrentWidgetMixin.__init__(self) # Init data self.data = None self.selected_data = None # used for transforming the 'selected data' into the 'data' domain self.selected_data_transformed = None self.results = Result() # info box fbox = gui.widgetBox(self.controlArea, "Info") self.info_fil = gui.label(fbox, self, 'Words displayed: 0') # Filtering settings fbox = gui.widgetBox(self.controlArea, "Filter") hbox = gui.widgetBox(fbox, orientation=0) self.chb_p = gui.checkBox(hbox, self, "filter_by_p", "p-value", callback=self.filter_and_display, tooltip="Filter by word p-value") self.spin_p = gui.doubleSpin(hbox, self, 'filter_p_value', 1e-4, 1, step=1e-4, labelWidth=15, callback=self.filter_and_display, tooltip="Max p-value for word") self.spin_p.setEnabled(self.filter_by_p) hbox = gui.widgetBox(fbox, orientation=0) self.chb_fdr = gui.checkBox(hbox, self, "filter_by_fdr", "FDR", callback=self.filter_and_display, tooltip="Filter by word FDR") self.spin_fdr = gui.doubleSpin(hbox, self, 'filter_fdr_value', 1e-4, 1, step=1e-4, labelWidth=15, callback=self.filter_and_display, tooltip="Max p-value for word") self.spin_fdr.setEnabled(self.filter_by_fdr) gui.rubber(self.controlArea) gui.auto_send(self.buttonsArea, self, "auto_apply") # Word's list view self.cols = ['Word', 'p-value', 'FDR'] self.sig_words = QTreeWidget() self.sig_words.setColumnCount(len(self.cols)) self.sig_words.setHeaderLabels(self.cols) self.sig_words.setSortingEnabled(True) self.sig_words.setSelectionMode(QTreeView.NoSelection) self.sig_words.sortByColumn(1, 0) # 0 is ascending order for i in range(len(self.cols)): self.sig_words.resizeColumnToContents(i) self.mainArea.layout().addWidget(self.sig_words)
def init_gui(self): box = gui.vBox(self.controlArea, "Method") self.method_combo = gui.comboBox(box, self, "outlier_method", items=[m.name for m in self.METHODS], callback=self.__method_changed) self._init_editors() gui.auto_send(self.controlArea, self, "auto_commit") self.info.set_input_summary(self.info.NoInput) self.info.set_output_summary(self.info.NoOutput)
def __init__(self): super().__init__() self.data = None # type: Optional[Table] # Information panel info_box = gui.vBox(self.controlArea, 'Info') info_box.setMinimumWidth(200) self.info_summary = gui.widgetLabel(info_box, wordWrap=True) self.info_attr = gui.widgetLabel(info_box, wordWrap=True) self.info_class = gui.widgetLabel(info_box, wordWrap=True) self.info_meta = gui.widgetLabel(info_box, wordWrap=True) self.set_info() # TODO: Implement filtering on the model # filter_box = gui.vBox(self.controlArea, 'Filter') # self.filter_text = gui.lineEdit( # filter_box, self, value='filter_string', # placeholderText='Filter variables by name', # callback=self._filter_table_variables, callbackOnType=True, # ) # shortcut = QShortcut(QKeySequence('Ctrl+f'), self, self.filter_text.setFocus) # shortcut.setWhatsThis('Filter variables by name') self.color_var_model = DomainModel( valid_types=(ContinuousVariable, DiscreteVariable), placeholder='None', ) box = gui.vBox(self.controlArea, 'Histogram') self.cb_color_var = gui.comboBox( box, master=self, value='color_var', model=self.color_var_model, label='Color:', orientation=Qt.Horizontal, ) self.cb_color_var.activated.connect(self.__color_var_changed) gui.rubber(self.controlArea) gui.auto_send(self.buttonsArea, self, "auto_commit") # Main area self.model = FeatureStatisticsTableModel(parent=self) self.table_view = FeatureStatisticsTableView(self.model, parent=self) self.table_view.selectionModel().selectionChanged.connect( self.on_select) self.table_view.horizontalHeader().sectionClicked.connect( self.on_header_click) self.mainArea.layout().addWidget(self.table_view)
def __init__(self): super().__init__() self.old_purge_classes = True self.conditions = [] self.last_output_conditions = None self.data = None self.data_desc = self.match_desc = self.nonmatch_desc = None self.variable_model = DomainModel( [list(self.AllTypes), DomainModel.Separator, DomainModel.CLASSES, DomainModel.ATTRIBUTES, DomainModel.METAS]) box = gui.vBox(self.controlArea, 'Conditions', stretch=100) self.cond_list = QTableWidget( box, showGrid=False, selectionMode=QTableWidget.NoSelection) box.layout().addWidget(self.cond_list) self.cond_list.setColumnCount(4) self.cond_list.setRowCount(0) self.cond_list.verticalHeader().hide() self.cond_list.horizontalHeader().hide() for i in range(3): self.cond_list.horizontalHeader().setSectionResizeMode(i, QHeaderView.Stretch) self.cond_list.horizontalHeader().resizeSection(3, 30) self.cond_list.viewport().setBackgroundRole(QPalette.Window) box2 = gui.hBox(box) gui.rubber(box2) self.add_button = gui.button( box2, self, "Add Condition", callback=self.add_row) self.add_all_button = gui.button( box2, self, "Add All Variables", callback=self.add_all) self.remove_all_button = gui.button( box2, self, "Remove All", callback=self.remove_all) gui.rubber(box2) box_setting = gui.vBox(self.buttonsArea) self.cb_pa = gui.checkBox( box_setting, self, "purge_attributes", "Remove unused features", callback=self.conditions_changed) self.cb_pc = gui.checkBox( box_setting, self, "purge_classes", "Remove unused classes", callback=self.conditions_changed) self.report_button.setFixedWidth(120) gui.rubber(self.buttonsArea.layout()) gui.auto_send(self.buttonsArea, self, "auto_commit") self.set_data(None) self.resize(600, 400)
def _add_controls(self): box = gui.vBox(self.controlArea, True) gui.rubber(self.controlArea) self._selected_var_model = DomainModel(valid_types=ContinuousVariable) gui.comboBox( box, self, "selected_var", label="Values:", model=self._selected_var_model, contentsLength=12, searchable=True, orientation=Qt.Horizontal, callback=self.__parameter_changed, ) self._group_var_model = DomainModel( placeholder="None", valid_types=DiscreteVariable ) gui.comboBox( box, self, "group_var", label="Group by:", model=self._group_var_model, contentsLength=12, searchable=True, orientation=Qt.Horizontal, callback=self.__group_var_changed, ) self._annot_var_model = DomainModel( placeholder="None", valid_types=(DiscreteVariable, StringVariable) ) self._annot_var_model.order = self._annot_var_model.order[:1] + \ (self.enumeration,) + \ self._annot_var_model.order[1:] gui.comboBox( box, self, "annot_var", label="Annotations:", model=self._annot_var_model, contentsLength=12, searchable=True, orientation=Qt.Horizontal, callback=self.__parameter_changed, ) self._color_var_model = DomainModel( placeholder="(Same color)", valid_types=DiscreteVariable ) gui.comboBox( box, self, "color_var", label="Color:", model=self._color_var_model, contentsLength=12, searchable=True, orientation=Qt.Horizontal, callback=self.__parameter_changed, ) plot_gui = OWPlotGUI(self) plot_gui.box_zoom_select(self.buttonsArea) gui.auto_send(self.buttonsArea, self, "auto_commit") self._set_input_summary(None) self._set_output_summary(None)
def __init__(self): super().__init__() self.data = None # type: Optional[Table] # TODO: Implement filtering on the model # filter_box = gui.vBox(self.controlArea, 'Filter') # self.filter_text = gui.lineEdit( # filter_box, self, value='filter_string', # placeholderText='Filter variables by name', # callback=self._filter_table_variables, callbackOnType=True, # ) # shortcut = QShortcut(QKeySequence('Ctrl+f'), self, self.filter_text.setFocus) # shortcut.setWhatsThis('Filter variables by name') box = gui.hBox(None, box=False) box.setContentsMargins(0, 0, 0, 0) self.color_var_model = DomainModel( valid_types=(ContinuousVariable, DiscreteVariable), placeholder='None', ) self.cb_color_var = gui.comboBox(box, master=self, value='color_var', model=self.color_var_model, label='Color:', orientation=Qt.Horizontal, contentsLength=13, searchable=True) self.cb_color_var.activated.connect(self.__color_var_changed) gui.rubber(box) gui.auto_send(box, self, "auto_commit", box=None) self.mainArea.layout().addWidget(box) self.info.set_input_summary(self.info.NoInput) self.info.set_output_summary(self.info.NoOutput) # Main area self.model = FeatureStatisticsTableModel(parent=self) self.table_view = FeatureStatisticsTableView(self.model, parent=self) self.table_view.selectionModel().selectionChanged.connect( self.on_select) self.table_view.horizontalHeader().sectionClicked.connect( self.on_header_click) self.mainArea.layout().addWidget(self.table_view)
def __init__(self): super().__init__() self.distances = None self.items = None self.tablemodel = DistanceMatrixModel() view = self.tableview = QTableView() view.setEditTriggers(QTableView.NoEditTriggers) view.setItemDelegate(TableBorderItem()) view.setModel(self.tablemodel) view.setShowGrid(False) for header in (view.horizontalHeader(), view.verticalHeader()): header.setSectionResizeMode(QHeaderView.ResizeToContents) header.setHighlightSections(True) header.setSectionsClickable(False) view.verticalHeader().setDefaultAlignment( Qt.AlignRight | Qt.AlignVCenter) selmodel = SymmetricSelectionModel(view.model(), view) view.setSelectionModel(selmodel) view.setSelectionBehavior(QTableView.SelectItems) self.mainArea.layout().addWidget(view) settings_box = gui.hBox(self.mainArea) self.annot_combo = gui.comboBox( settings_box, self, "annotation_idx", label="Labels: ", orientation=Qt.Horizontal, callback=self._invalidate_annotations, contentsLength=12) self.annot_combo.setModel(VariableListModel()) self.annot_combo.model()[:] = ["None", "Enumeration"] gui.rubber(settings_box) acb = gui.auto_send(settings_box, self, "auto_commit", box=None) acb.setFixedWidth(200) # Signal must be connected after self.commit is redirected selmodel.selectionChanged.connect(self.commit)
def __init__(self): super().__init__() self.old_purge_classes = True self.conditions = [] self.last_output_conditions = None self.data = None self.data_desc = self.match_desc = self.nonmatch_desc = None box = gui.vBox(self.controlArea, 'Conditions', stretch=100) self.cond_list = QTableWidget( box, showGrid=False, selectionMode=QTableWidget.NoSelection) box.layout().addWidget(self.cond_list) self.cond_list.setColumnCount(4) self.cond_list.setRowCount(0) self.cond_list.verticalHeader().hide() self.cond_list.horizontalHeader().hide() for i in range(3): self.cond_list.horizontalHeader().setSectionResizeMode(i, QHeaderView.Stretch) self.cond_list.horizontalHeader().resizeSection(3, 30) self.cond_list.viewport().setBackgroundRole(QPalette.Window) box2 = gui.hBox(box) gui.rubber(box2) self.add_button = gui.button( box2, self, "Add Condition", callback=self.add_row) self.add_all_button = gui.button( box2, self, "Add All Variables", callback=self.add_all) self.remove_all_button = gui.button( box2, self, "Remove All", callback=self.remove_all) gui.rubber(box2) boxes = gui.widgetBox(self.controlArea, orientation=QHBoxLayout()) layout = boxes.layout() box_setting = gui.vBox(boxes, addToLayout=False, box=True) self.cb_pa = gui.checkBox( box_setting, self, "purge_attributes", "Remove unused features", callback=self.conditions_changed) gui.separator(box_setting, height=1) self.cb_pc = gui.checkBox( box_setting, self, "purge_classes", "Remove unused classes", callback=self.conditions_changed) layout.addWidget(box_setting, 1) self.report_button.setFixedWidth(120) gui.rubber(self.buttonsArea.layout()) layout.addWidget(self.buttonsArea) acbox = gui.auto_send(None, self, "auto_commit") layout.addWidget(acbox, 1) layout.setAlignment(acbox, Qt.AlignBottom) self.info.set_input_summary(self.info.NoInput) self.info.set_output_summary(self.info.NoOutput) self.set_data(None) self.resize(600, 400)
def _add_controls(self): infobox = gui.widgetBox(self.controlArea, "信息") self.infoLabel = gui.widgetLabel(infobox, "没有输入数据。") displaybox = gui.widgetBox(self.controlArea, "显示") gui.checkBox(displaybox, self, "show_profiles", "线", callback=self.__show_profiles_changed, tooltip="Plot lines") gui.checkBox(displaybox, self, "show_range", "范围", callback=self.__show_range_changed, tooltip="Plot range between 10th and 90th percentile") gui.checkBox(displaybox, self, "show_mean", "平均", callback=self.__show_mean_changed, tooltip="Plot mean curve") gui.checkBox(displaybox, self, "show_error", "误差线", callback=self.__show_error_changed, tooltip="Show standard deviation") self.group_vars = DomainModel(placeholder="无", separators=False, valid_types=DiscreteVariable) self.group_view = gui.listView(self.controlArea, self, "group_var", box="分组依据", model=self.group_vars, callback=self.__group_var_changed, sizeHint=QSize(30, 100)) self.group_view.setEnabled(False) plot_gui = OWPlotGUI(self) plot_gui.box_zoom_select(self.controlArea) gui.rubber(self.controlArea) gui.auto_send(self.controlArea, self, "auto_commit")
def __init__(self): super().__init__() self.data = None self.component_x = 0 self.component_y = 1 self._set_input_summary(None) self._set_output_summary(None) box = gui.vBox(self.controlArea, "Variables") self.varlist = itemmodels.VariableListModel() self.varview = view = ListViewSearch( selectionMode=QListView.MultiSelection, uniformItemSizes=True ) view.setModel(self.varlist) view.selectionModel().selectionChanged.connect(self._var_changed) box.layout().addWidget(view) axes_box = gui.vBox(self.controlArea, "Axes") self.axis_x_cb = gui.comboBox( axes_box, self, "component_x", label="X:", callback=self._component_changed, orientation=Qt.Horizontal, sizePolicy=(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred) ) self.axis_y_cb = gui.comboBox( axes_box, self, "component_y", label="Y:", callback=self._component_changed, orientation=Qt.Horizontal, sizePolicy=(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred) ) self.infotext = gui.widgetLabel( gui.vBox(self.controlArea, "Contribution to Inertia"), "\n" ) gui.auto_send(self.buttonsArea, self, "auto_commit") self.plot = pg.PlotWidget(background="w") self.plot.setMenuEnabled(False) self.mainArea.layout().addWidget(self.plot)
def _add_controls(self): box = gui.vBox(self.controlArea, "Target class") self._target_combo = gui.comboBox( box, self, "target_index", callback=self.__target_combo_changed, contentsLength=12) box = gui.hBox(self.controlArea, "Display features") gui.label(box, self, "Best ranked: ") gui.spin(box, self, "n_attributes", 1, ViolinPlot.MAX_N_ITEMS, controlWidth=80, callback=self.__n_spin_changed) box = gui.hBox(self.controlArea, True) gui.checkBox(box, self, "show_legend", "Show legend", callback=self.__show_check_changed) gui.rubber(self.controlArea) box = gui.vBox(self.controlArea, box=True) gui.auto_send(box, self, "auto_send", box=False)
def __init__(self): super().__init__() self.data = None self.component_x = 0 self.component_y = 1 self._set_input_summary(None) self._set_output_summary(None) box = gui.vBox(self.controlArea, "Variables") self.varlist = itemmodels.VariableListModel() self.varview = view = ListViewSearch( selectionMode=QListView.MultiSelection, uniformItemSizes=True) view.setModel(self.varlist) view.selectionModel().selectionChanged.connect(self._var_changed) box.layout().addWidget(view) axes_box = gui.vBox(self.controlArea, "Axes") box = gui.vBox(axes_box, "Axis X", margin=0) box.setFlat(True) self.axis_x_cb = gui.comboBox(box, self, "component_x", callback=self._component_changed) box = gui.vBox(axes_box, "Axis Y", margin=0) box.setFlat(True) self.axis_y_cb = gui.comboBox(box, self, "component_y", callback=self._component_changed) self.infotext = gui.widgetLabel( gui.vBox(self.controlArea, "Contribution to Inertia"), "\n") gui.auto_send(self.controlArea, self, "auto_commit") gui.rubber(self.controlArea) self.plot = pg.PlotWidget(background="w") self.plot.setMenuEnabled(False) self.mainArea.layout().addWidget(self.plot)
def __init__(self): super().__init__() options = {"labelWidth": 100, "controlWidth": 50} box = gui.vBox(self.controlArea, "Control") self.r_spin = gui.spin(box, self, "n_rows", 1, 20, 1, **options, label="Rows:", callback=self.rows_changed) self.c_spin = gui.spin(box, self, "n_columns", 1, 20, 1, **options, label="Columns:", callback=self.columns_changed) box.setMinimumWidth(200) gui.rubber(self.controlArea) gui.auto_send(self.buttonsArea, self, "auto_commit") box = gui.vBox(self.mainArea, True, margin=0) self.table = QTableView(box) self.table.setItemDelegate(EditableTableItemDelegate()) box.layout().addWidget(self.table) self.table_model = EditableTableModel() self.table.setModel(self.table_model) self.table_model.dataChanged.connect(self.data_changed) self.rows_changed() self.columns_changed() self.set_dataset(None) # to init the context
def __init__(self): super().__init__() self.distances = None self.items = None self.tablemodel = DistanceMatrixModel() view = self.tableview = TableView() view.setWordWrap(False) view.setTextElideMode(Qt.ElideNone) view.setEditTriggers(QTableView.NoEditTriggers) view.setItemDelegate( TableBorderItem(roles=(Qt.DisplayRole, Qt.BackgroundRole, Qt.ForegroundRole))) view.setModel(self.tablemodel) view.setShowGrid(False) for header in (view.horizontalHeader(), view.verticalHeader()): header.setResizeContentsPrecision(1) header.setSectionResizeMode(QHeaderView.ResizeToContents) header.setHighlightSections(True) header.setSectionsClickable(False) view.verticalHeader().setDefaultAlignment(Qt.AlignRight | Qt.AlignVCenter) selmodel = SymmetricSelectionModel(view.model(), view) selmodel.selectionChanged.connect(self.commit.deferred) view.setSelectionModel(selmodel) view.setSelectionBehavior(QTableView.SelectItems) self.controlArea.layout().addWidget(view) self.annot_combo = gui.comboBox(self.buttonsArea, self, "annotation_idx", label="标签: ", orientation=Qt.Horizontal, callback=self._invalidate_annotations, contentsLength=12) self.annot_combo.setModel(VariableListModel()) self.annot_combo.model()[:] = ["无", "枚举"] gui.rubber(self.buttonsArea) acb = gui.auto_send(self.buttonsArea, self, "auto_commit", box=False) acb.setFixedWidth(200)
def _add_buttons(self): gui.rubber(self.controlArea) self.gui.box_zoom_select(self.buttonsArea) gui.auto_send(self.buttonsArea, self, "auto_commit")
def _init_ui(self): namesBox = gui.vBox(self.controlArea, "Names") hbox = gui.hBox(namesBox, margin=0, spacing=0) gui.lineEdit(hbox, self, "attr1", "Variable X: ", controlWidth=80, orientation=Qt.Horizontal, callback=self._attr_name_changed) gui.separator(hbox, 21) hbox = gui.hBox(namesBox, margin=0, spacing=0) attr2 = gui.lineEdit(hbox, self, "attr2", "Variable Y: ", controlWidth=80, orientation=Qt.Horizontal, callback=self._attr_name_changed) gui.separator(hbox) gui.checkBox(hbox, self, "hasAttr2", '', disables=attr2, labelWidth=0, callback=self.set_dimensions) gui.widgetLabel(namesBox, "Labels") self.classValuesView = listView = gui.ListViewWithSizeHint( preferred_size=(-1, 30)) listView.setModel(self.class_model) itemmodels.select_row(listView, 0) namesBox.layout().addWidget(listView) self.addClassLabel = QAction("+", self, toolTip="Add new class label", triggered=self.add_new_class_label) self.removeClassLabel = QAction( unicodedata.lookup("MINUS SIGN"), self, toolTip="Remove selected class label", triggered=self.remove_selected_class_label) actionsWidget = itemmodels.ModelActionsWidget( [self.addClassLabel, self.removeClassLabel], self) actionsWidget.layout().addStretch(10) actionsWidget.layout().setSpacing(1) namesBox.layout().addWidget(actionsWidget) tBox = gui.vBox(self.buttonsArea, "Tools") toolsBox = gui.widgetBox(tBox, orientation=QGridLayout()) self.toolActions = QActionGroup(self) self.toolActions.setExclusive(True) self.toolButtons = [] for i, (name, tooltip, tool, icon) in enumerate(self.TOOLS): action = QAction( name, self, toolTip=tooltip, checkable=tool.checkable, icon=QIcon(icon), ) action.triggered.connect(partial(self.set_current_tool, tool)) button = QToolButton(iconSize=QSize(24, 24), toolButtonStyle=Qt.ToolButtonTextUnderIcon, sizePolicy=QSizePolicy( QSizePolicy.MinimumExpanding, QSizePolicy.Fixed)) button.setDefaultAction(action) self.toolButtons.append((button, tool)) toolsBox.layout().addWidget(button, i / 3, i % 3) self.toolActions.addAction(action) for column in range(3): toolsBox.layout().setColumnMinimumWidth(column, 10) toolsBox.layout().setColumnStretch(column, 1) undo = self.undo_stack.createUndoAction(self) redo = self.undo_stack.createRedoAction(self) undo.setShortcut(QKeySequence.Undo) redo.setShortcut(QKeySequence.Redo) self.addActions([undo, redo]) self.undo_stack.indexChanged.connect(self.invalidate) indBox = gui.indentedBox(tBox, sep=8) form = QFormLayout(formAlignment=Qt.AlignLeft, labelAlignment=Qt.AlignLeft, fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow) indBox.layout().addLayout(form) slider = gui.hSlider(indBox, self, "brushRadius", minValue=1, maxValue=100, createLabel=False, addToLayout=False) form.addRow("Radius:", slider) slider = gui.hSlider(indBox, self, "density", None, minValue=1, maxValue=100, createLabel=False, addToLayout=False) form.addRow("Intensity:", slider) slider = gui.hSlider(indBox, self, "symbol_size", None, minValue=1, maxValue=100, createLabel=False, callback=self.set_symbol_size, addToLayout=False) form.addRow("Symbol:", slider) self.btResetToInput = gui.button(tBox, self, "Reset to Input Data", self.reset_to_input) self.btResetToInput.setDisabled(True) gui.auto_send(self.buttonsArea, self, "autocommit") # main area GUI viewbox = PaintViewBox(enableMouse=False) self.plotview = pg.PlotWidget(background="w", viewBox=viewbox) self.plotview.sizeHint = lambda: QSize( 200, 100) # Minimum size for 1-d painting self.plot = self.plotview.getPlotItem() axis_color = self.palette().color(QPalette.Text) axis_pen = QPen(axis_color) tickfont = QFont(self.font()) tickfont.setPixelSize(max(int(tickfont.pixelSize() * 2 // 3), 11)) axis = self.plot.getAxis("bottom") axis.setLabel(self.attr1) axis.setPen(axis_pen) axis.setTickFont(tickfont) axis = self.plot.getAxis("left") axis.setLabel(self.attr2) axis.setPen(axis_pen) axis.setTickFont(tickfont) if not self.hasAttr2: self.plot.hideAxis('left') self.plot.hideButtons() self.plot.setXRange(0, 1, padding=0.01) self.mainArea.layout().addWidget(self.plotview) # enable brush tool self.toolActions.actions()[0].setChecked(True) self.set_current_tool(self.TOOLS[0][2]) self.set_dimensions()
def __init__(self): super().__init__() self.matrix = None self._tree = None self._ordered_tree = None self._sorted_matrix = None self._sort_indices = None self._selection = None self.sorting_cb = gui.comboBox( self.controlArea, self, "sorting", box="Element Sorting", items=["None", "Clustering", "Clustering with ordered leaves"], callback=self._invalidate_ordering) box = gui.vBox(self.controlArea, "Colors") self.color_box = gui.palette_combo_box(self.palette_name) self.color_box.currentIndexChanged.connect(self._update_color) box.layout().addWidget(self.color_box) form = QFormLayout( formAlignment=Qt.AlignLeft, labelAlignment=Qt.AlignLeft, fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow ) # form.addRow( # "Gamma", # gui.hSlider(box, self, "color_gamma", minValue=0.0, maxValue=1.0, # step=0.05, ticks=True, intOnly=False, # createLabel=False, callback=self._update_color) # ) form.addRow( "Low:", gui.hSlider(box, self, "color_low", minValue=0.0, maxValue=1.0, step=0.05, ticks=True, intOnly=False, createLabel=False, callback=self._update_color) ) form.addRow( "High:", gui.hSlider(box, self, "color_high", minValue=0.0, maxValue=1.0, step=0.05, ticks=True, intOnly=False, createLabel=False, callback=self._update_color) ) box.layout().addLayout(form) self.annot_combo = gui.comboBox( self.controlArea, self, "annotation_idx", box="Annotations", callback=self._invalidate_annotations, contentsLength=12) self.annot_combo.setModel(itemmodels.VariableListModel()) self.annot_combo.model()[:] = ["None", "Enumeration"] self.controlArea.layout().addStretch() gui.auto_send(self.controlArea, self, "autocommit") self.view = pg.GraphicsView(background="w") self.mainArea.layout().addWidget(self.view) self.grid_widget = pg.GraphicsWidget() self.grid = QGraphicsGridLayout() self.grid_widget.setLayout(self.grid) self.viewbox = pg.ViewBox(enableMouse=False, enableMenu=False) self.viewbox.setAcceptedMouseButtons(Qt.NoButton) self.viewbox.setAcceptHoverEvents(False) self.grid.addItem(self.viewbox, 1, 1) self.left_dendrogram = DendrogramWidget( self.grid_widget, orientation=DendrogramWidget.Left, selectionMode=DendrogramWidget.NoSelection, hoverHighlightEnabled=False ) self.left_dendrogram.setAcceptedMouseButtons(Qt.NoButton) self.left_dendrogram.setAcceptHoverEvents(False) self.top_dendrogram = DendrogramWidget( self.grid_widget, orientation=DendrogramWidget.Top, selectionMode=DendrogramWidget.NoSelection, hoverHighlightEnabled=False ) self.top_dendrogram.setAcceptedMouseButtons(Qt.NoButton) self.top_dendrogram.setAcceptHoverEvents(False) self.grid.addItem(self.left_dendrogram, 1, 0) self.grid.addItem(self.top_dendrogram, 0, 1) self.right_labels = TextList( alignment=Qt.AlignLeft | Qt.AlignVCenter, sizePolicy=QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) ) self.bottom_labels = TextList( orientation=Qt.Horizontal, alignment=Qt.AlignRight | Qt.AlignVCenter, sizePolicy=QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) ) self.grid.addItem(self.right_labels, 1, 2) self.grid.addItem(self.bottom_labels, 2, 1) self.view.setCentralItem(self.grid_widget) self.left_dendrogram.hide() self.top_dendrogram.hide() self.right_labels.hide() self.bottom_labels.hide() self.matrix_item = None self.dendrogram = None self.grid_widget.scene().installEventFilter(self) self.settingsAboutToBePacked.connect(self.pack_settings)
def __init__(self): super().__init__() self.matrix = None self._matrix_range = 0. self._tree = None self._ordered_tree = None self._sorted_matrix = None self._sort_indices = None self._selection = None self.sorting_cb = gui.comboBox( self.controlArea, self, "sorting", box="Element Sorting", items=["None", "Clustering", "Clustering with ordered leaves"], callback=self._invalidate_ordering) box = gui.vBox(self.controlArea, "Colors") self.color_map_widget = cmw = ColorGradientSelection( thresholds=(self.color_low, self.color_high), ) model = itemmodels.ContinuousPalettesModel(parent=self) cmw.setModel(model) idx = cmw.findData(self.palette_name, model.KeyRole) if idx != -1: cmw.setCurrentIndex(idx) cmw.activated.connect(self._update_color) def _set_thresholds(low, high): self.color_low, self.color_high = low, high self._update_color() cmw.thresholdsChanged.connect(_set_thresholds) box.layout().addWidget(self.color_map_widget) self.annot_combo = gui.comboBox(self.controlArea, self, "annotation_idx", box="Annotations", contentsLength=12, searchable=True, callback=self._invalidate_annotations) self.annot_combo.setModel(itemmodels.VariableListModel()) self.annot_combo.model()[:] = ["None", "Enumeration"] gui.rubber(self.controlArea) gui.auto_send(self.buttonsArea, self, "autocommit") self.view = GraphicsView(background=None) self.mainArea.layout().addWidget(self.view) self.grid_widget = pg.GraphicsWidget() self.grid = QGraphicsGridLayout() self.grid_widget.setLayout(self.grid) self.gradient_legend = GradientLegendWidget(0, 1, self._color_map()) self.gradient_legend.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) self.gradient_legend.setMaximumWidth(250) self.grid.addItem(self.gradient_legend, 0, 1) self.viewbox = pg.ViewBox(enableMouse=False, enableMenu=False) self.viewbox.setAcceptedMouseButtons(Qt.NoButton) self.viewbox.setAcceptHoverEvents(False) self.grid.addItem(self.viewbox, 2, 1) self.left_dendrogram = DendrogramWidget( self.grid_widget, orientation=DendrogramWidget.Left, selectionMode=DendrogramWidget.NoSelection, hoverHighlightEnabled=False) self.left_dendrogram.setAcceptedMouseButtons(Qt.NoButton) self.left_dendrogram.setAcceptHoverEvents(False) self.top_dendrogram = DendrogramWidget( self.grid_widget, orientation=DendrogramWidget.Top, selectionMode=DendrogramWidget.NoSelection, hoverHighlightEnabled=False) self.top_dendrogram.setAcceptedMouseButtons(Qt.NoButton) self.top_dendrogram.setAcceptHoverEvents(False) self.grid.addItem(self.left_dendrogram, 2, 0) self.grid.addItem(self.top_dendrogram, 1, 1) self.right_labels = TextList(alignment=Qt.AlignLeft | Qt.AlignVCenter, sizePolicy=QSizePolicy( QSizePolicy.Fixed, QSizePolicy.Expanding)) self.bottom_labels = TextList( orientation=Qt.Horizontal, alignment=Qt.AlignRight | Qt.AlignVCenter, sizePolicy=QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)) self.grid.addItem(self.right_labels, 2, 2) self.grid.addItem(self.bottom_labels, 3, 1) self.view.setCentralItem(self.grid_widget) self.gradient_legend.hide() self.left_dendrogram.hide() self.top_dendrogram.hide() self.right_labels.hide() self.bottom_labels.hide() self.matrix_item = None self.dendrogram = None self.settingsAboutToBePacked.connect(self.pack_settings)