def __init__(self): hbox = gui.hBox(self.controlArea) _properties = dict(alternatingRowColors=True, defaultDropAction=Qt.MoveAction, dragDropMode=QListView.DragDrop, dragEnabled=True, selectionMode=QListView.ExtendedSelection, selectionBehavior=QListView.SelectRows, showDropIndicator=True, acceptDrops=True) listview_avail = DnDListView(lambda: self.commit(), self, **_properties) self.model_avail = model = VariableListModel(parent=self, enable_dnd=True) listview_avail.setModel(model) listview_key = DnDListView(lambda: self.commit(), self, **_properties) self.model_key = model = VariableListModel(parent=self, enable_dnd=True) listview_key.setModel(model) box = gui.vBox(hbox, 'Available Variables') box.layout().addWidget(listview_avail) box = gui.vBox(hbox, 'Group-By Key') box.layout().addWidget(listview_key) gui.comboBox(self.controlArea, self, 'tiebreaker', label='Which instance to select in each group:', items=tuple(self.TIEBREAKERS.keys()), callback=lambda: self.commit(), sendSelectedValue=True) gui.auto_commit(self.controlArea, self, 'autocommit', 'Commit', orientation=Qt.Horizontal)
def __init__(self): super().__init__() self.net = None commit = lambda: self.commit() gui.spin(self.controlArea, self, "iterations", 1, 100000, 1, label="Max. iterations:", callback=commit) ribg = gui.radioButtonsInBox( self.controlArea, self, "method", btnLabels=[ "Label propagation clustering (Raghavan et al., 2007)", "Label propagation clustering (Leung et al., 2009)", ], box="Clustering method", callback=commit, ) gui.doubleSpin(gui.indentedBox(ribg), self, "hop_attenuation", 0, 1, 0.01, label="Hop attenuation (delta): ") self.info = gui.widgetLabel(self.controlArea, " ") gui.auto_commit(self.controlArea, self, "autoApply", "Commit", checkbox_label="Auto-commit") commit()
def __init__(self): super().__init__() self.corpus = None self.learning_thread = None # Commit button gui.auto_commit(self.buttonsArea, self, 'autocommit', 'Commit', box=False) button_group = QButtonGroup(self, exclusive=True) button_group.buttonClicked[int].connect(self.change_method) self.widgets = [] method_layout = QVBoxLayout() self.controlArea.layout().addLayout(method_layout) for i, (method, attr_name) in enumerate(self.methods): widget = method(self, title='Options') widget.setFixedWidth(self.control_area_width) widget.valueChanged.connect(self.commit) self.widgets.append(widget) setattr(self, attr_name, widget) rb = QRadioButton(text=widget.Model.name) button_group.addButton(rb, i) method_layout.addWidget(rb) method_layout.addWidget(widget) button_group.button(self.method_index).setChecked(True) self.toggle_widgets() method_layout.addStretch() # Topics description self.topic_desc = TopicViewer() self.topic_desc.topicSelected.connect(self.send_topic_by_id) self.mainArea.layout().addWidget(self.topic_desc) self.topic_desc.setFocus()
def _create_layout(self): info = gui.widgetBox(self.controlArea, 'Info') gui.label(info, self, '%(n_object_types)d object types') gui.label(info, self, '%(n_relations)d relations') # Table view of relation details info = gui.widgetBox(self.controlArea, 'Relations') def send_relation(item): data = item.data(QtCore.Qt.UserRole) self.send(Output.RELATION, Relation(data)) self.table = SimpleTableWidget(info, callback=send_relation) self.controlArea.layout().addStretch(1) gui.lineEdit(self.controlArea, self, 'pref_algo_name', 'Fuser name', callback=self.checkcommit, enterPlaceholder=True) gui.radioButtons(self.controlArea, self, 'pref_algorithm', [i[0] for i in DECOMPOSITION_ALGO], box='Decomposition algorithm', callback=self.checkcommit) gui.radioButtons(self.controlArea, self, 'pref_initialization', INITIALIZATION_ALGO, box='Initialization algorithm', callback=self.checkcommit) gui.hSlider(self.controlArea, self, 'pref_n_iterations', 'Maximum number of iterations', minValue=10, maxValue=500, createLabel=True, callback=self.checkcommit) self.slider_rank = gui.hSlider(self.controlArea, self, 'pref_rank', 'Factorization rank', minValue=1, maxValue=100, createLabel=True, labelFormat=" %d%%", callback=self.checkcommit) gui.auto_commit(self.controlArea, self, "autorun", "Run", checkbox_label="Run after any change ")
def __init__(self): super().__init__() self.data_points_interpolate = None dbox = gui.widgetBox(self.controlArea, "Interpolation") rbox = gui.radioButtons( dbox, self, "input_radio", callback=self._change_input) gui.appendRadioButton(rbox, "Enable automatic interpolation") gui.appendRadioButton(rbox, "Linear interval") ibox = gui.indentedBox(rbox) form = QWidget() formlayout = QFormLayout() form.setLayout(formlayout) ibox.layout().addWidget(form) self.xmin_edit = lineEditFloatOrNone(ibox, self, "xmin", callback=self.commit) formlayout.addRow("Min", self.xmin_edit) self.xmax_edit = lineEditFloatOrNone(ibox, self, "xmax", callback=self.commit) formlayout.addRow("Max", self.xmax_edit) self.dx_edit = lineEditFloatOrNone(ibox, self, "dx", callback=self.commit) formlayout.addRow("Δ", self.dx_edit) gui.appendRadioButton(rbox, "Reference data") self.data = None gui.auto_commit(self.controlArea, self, "autocommit", "Interpolate") self._change_input()
def __init__(self): self.data = None box = gui.vBox(self.controlArea, 'Differencing') self.order_spin = gui.spin( box, self, 'diff_order', 1, 2, label='Differencing order:', callback=self.on_changed, tooltip='The value corresponds to n-th order numerical ' 'derivative of the series. \nThe order is fixed to 1 ' 'if the shift period is other than 1.') gui.spin(box, self, 'shift_period', 1, 100, label='Shift:', callback=self.on_changed, tooltip='Set this to other than 1 if you don\'t want to ' 'compute differences for subsequent values but for ' 'values shifted number of spaces apart. \n' 'If this value is different from 1, differencing ' 'order is fixed to 1.') gui.checkBox(box, self, 'invert_direction', label='Invert differencing direction', callback=self.on_changed, tooltip='Influences where the series is padded with nan ' 'values — at the beginning or at the end.') self.view = view = QListView(self, selectionMode=QListView.ExtendedSelection) self.model = model = VariableListModel(parent=self) view.setModel(model) view.selectionModel().selectionChanged.connect(self.on_changed) box.layout().addWidget(view) gui.auto_commit(box, self, 'autocommit', '&Apply')
def __init__(self): super().__init__() self.data = None self.input_vars = () self._invalidated = False box = gui.vBox(self.controlArea, "Domain Features") self.domain_model = itemmodels.VariableListModel() self.domain_view = QListView( selectionMode=QListView.SingleSelection ) self.domain_view.setModel(self.domain_model) self.domain_view.selectionModel().selectionChanged.connect( self._on_selection_changed) box.layout().addWidget(self.domain_view) box = gui.hBox(self.controlArea) gui.button(box, self, "Reset Selected", callback=self.reset_selected) gui.button(box, self, "Reset All", callback=self.reset_all) gui.auto_commit(self.controlArea, self, "autocommit", "Apply") box = gui.vBox(self.mainArea, "Edit") self.editor_stack = QStackedWidget() self.editor_stack.addWidget(DiscreteVariableEditor()) self.editor_stack.addWidget(ContinuousVariableEditor()) self.editor_stack.addWidget(VariableEditor()) box.layout().addWidget(self.editor_stack)
def __init__(self): super().__init__() self.net = None self.method = 0 self.iterationHistory = 0 self.autoApply = 0 self.iterations = 1000 self.hop_attenuation = 0.1 commit = lambda: self.commit() gui.spin(self.controlArea, self, "iterations", 1, 100000, 1, label="Iterations: ", callback=commit) ribg = gui.radioButtonsInBox( self.controlArea, self, "method", btnLabels=["Label propagation clustering (Raghavan et al., 2007)", "Label propagation clustering (Leung et al., 2009)"], label="Method", callback=commit) gui.doubleSpin(gui.indentedBox(ribg), self, "hop_attenuation", 0, 1, 0.01, label="Hop attenuation (delta): ") self.info = gui.widgetLabel(self.controlArea, ' ') gui.checkBox(self.controlArea, self, "iterationHistory", "Append clustering data on each iteration", callback=commit) gui.auto_commit(self.controlArea, self, "autoApply", 'Commit', checkbox_label='Auto-commit') commit()
def __init__(self): super().__init__() self.data = None self.preprocessors = None box = gui.widgetBox(self.controlArea, "Learner/Predictor Name") gui.lineEdit(box, self, "learner_name") box = gui.widgetBox(self.controlArea, "Regularization") box = gui.radioButtons( box, self, "reg_type", btnLabels=["No regularization", "Ridge regression", "Lasso regression"], callback=self._reg_type_changed) gui.separator(box) self.alpha_box = box2 = gui.widgetBox(box, margin=0) gui.widgetLabel(box2, "Regularization strength") self.alpha_slider = gui.hSlider( box2, self, "alpha_index", minValue=0, maxValue=len(self.alphas) - 1, callback=self._alpha_changed, createLabel=False) box3 = gui.widgetBox(box, orientation="horizontal") box3.layout().setAlignment(Qt.AlignCenter) self.alpha_label = gui.widgetLabel(box3, "") self._set_alpha_label() gui.auto_commit(self.controlArea, self, "autosend", "Apply", checkbox_label="Apply on every change") self.layout().setSizeConstraint(QLayout.SetFixedSize) self.alpha_slider.setEnabled(self.reg_type != self.OLS) self.commit()
def __init__(self, parent=None): widget.OWWidget.__init__(self, parent) box = gui.widgetBox(self.controlArea, "Multinomial attributes") gui.radioButtonsInBox( box, self, "multinomial_treatment", btnLabels=[x[0] for x in self.multinomial_treats], callback=self.settings_changed) box = gui.widgetBox(self.controlArea, "Continuous attributes") gui.radioButtonsInBox( box, self, "continuous_treatment", btnLabels=[x[0] for x in self.continuous_treats], callback=self.settings_changed) box = gui.widgetBox(self.controlArea, "Discrete class attribute") gui.radioButtonsInBox( box, self, "class_treatment", btnLabels=[t[0] for t in self.class_treats], callback=self.settings_changed) zbbox = gui.widgetBox(self.controlArea, "Value range") gui.radioButtonsInBox( zbbox, self, "zero_based", btnLabels=self.value_ranges, callback=self.settings_changed) gui.auto_commit(self.controlArea, self, "autosend", "Apply") self.data = None self.resize(150, 300)
def _create_layout(self): self.mainArea.layout().addWidget(self.graphview) info = gui.widgetBox(self.controlArea, 'Info') gui.label(info, self, '%(n_object_types)d object types') gui.label(info, self, '%(n_relations)d relations') # Table view of relation details info = gui.widgetBox(self.controlArea, 'Relations') class TableView(gui.TableView): def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self._parent = parent self.bold_font = self.BoldFontDelegate(self) # member because PyQt sometimes unrefs too early self.setItemDelegateForColumn(2, self.bold_font) self.setItemDelegateForColumn(4, self.bold_font) self.horizontalHeader().setVisible(False) def selectionChanged(self, selected, deselected): super().selectionChanged(selected, deselected) if not selected: assert len(deselected) > 0 relation = None else: assert len(selected) == 1 data = self._parent.tablemodel[selected[0].top()][0] relation = Relation(data) self._parent.send(Output.RELATION, relation) model = self.tablemodel = PyTableModel(parent=self) table = self.table = TableView(self, selectionMode=TableView.SingleSelection) table.setModel(model) info.layout().addWidget(self.table) gui.lineEdit(self.controlArea, self, 'pref_algo_name', 'Fuser name:', orientation='horizontal', callback=self.checkcommit, enterPlaceholder=True) gui.radioButtons(self.controlArea, self, 'pref_algorithm', [i[0] for i in DECOMPOSITION_ALGO], box='Decomposition algorithm', callback=self.checkcommit) gui.radioButtons(self.controlArea, self, 'pref_initialization', INITIALIZATION_ALGO, box='Initialization algorithm', callback=self.checkcommit) slider = gui.hSlider( self.controlArea, self, 'pref_n_iterations', 'Maximum number of iterations', minValue=10, maxValue=500, createLabel=True, callback=self.checkcommit) slider.setTracking(False) self.slider_rank = gui.hSlider(self.controlArea, self, 'pref_rank', 'Factorization rank', minValue=1, maxValue=100, createLabel=True, labelFormat=" %d%%", callback=self.checkcommit) self.slider_rank.setTracking(False) gui.auto_commit(self.controlArea, self, "autorun", "Run", checkbox_label="Run after any change ")
def __init__(self): super().__init__() self.corpus = None # Info box. info_box = gui.widgetBox( self.controlArea, 'Info', ) bow_info = 'No info available.' self.info_label = gui.label(info_box, self, bow_info) # TF-IDF. tfidf_box = gui.widgetBox( self.controlArea, 'Settings', ) self.tfidf_checkbox = gui.checkBox( tfidf_box, self, 'use_tfidf', 'Use TF-IDF' ) self.tfidf_checkbox.stateChanged.connect(self.tfidf_changed) gui.auto_commit( self.controlArea, self, 'autocommit', 'Commit', box=False )
def _add_controls(self): infobox = gui.widgetBox(self.controlArea, "Info") self.infoLabel = gui.widgetLabel(infobox, "No data on input.") 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) self.group_view.setEnabled(False) self.group_view.setMinimumSize(QSize(30, 100)) self.group_view.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Ignored) plot_gui = OWPlotGUI(self) plot_gui.box_zoom_select(self.controlArea) gui.rubber(self.controlArea) gui.auto_commit(self.controlArea, self, "auto_commit", "Send Selection", "Send Automatically")
def __init__(self): super().__init__() self.data = None self.removedAttrs = "-" self.reducedAttrs = "-" self.resortedAttrs = "-" self.removedClasses = "-" self.reducedClasses = "-" self.resortedClasses = "-" 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) box3 = gui.vBox(self.controlArea, 'Statistics', addSpace=True) for label, value in self.stat_labels: gui.label(box3, self, "{}: %({})s".format(label, value)) gui.auto_commit(self.buttonsArea, self, "autoSend", "Send Data", checkbox_label="Send automatically", orientation=Qt.Horizontal) gui.rubber(self.controlArea)
def __init__(self): super().__init__() self.data = None self.db = None box = gui.widgetBox(self.controlArea, "Parameters") gui.spin(box, self, "min_samples", 1, 100, 1, callback=self._invalidate, label="Core point neighbors") gui.doubleSpin(box, self, "eps", 0.1, 0.9, 0.1, callback=self._invalidate, label="Neighborhood distance") box = gui.widgetBox(self.controlArea, self.tr("Distance Metric")) gui.comboBox(box, self, "metric_idx", items=list(zip(*self.METRICS))[0], callback=self._invalidate) box = gui.widgetBox(self.controlArea, "Output") gui.comboBox(box, self, "place_cluster_ids", label="Append cluster id as ", orientation="horizontal", callback=self.send_data, items=self.OUTPUT_METHODS) gui.lineEdit(box, self, "output_name", label="Name: ", orientation="horizontal", callback=self.send_data) gui.auto_commit(self.controlArea, self, "auto_run", "Run", checkbox_label="Run after any change ", orientation="horizontal") gui.rubber(self.controlArea) self.controlArea.setMinimumWidth(self.controlArea.sizeHint().width()) self.layout().setSizeConstraint(QtGui.QLayout.SetFixedSize)
def __init__(self): super().__init__() box = gui.vBox(self.controlArea, "Multinomial Attributes") gui.radioButtonsInBox( box, self, "multinomial_treatment", btnLabels=[x[0] for x in self.multinomial_treats], callback=self.settings_changed) box = gui.vBox(self.controlArea, "Continuous Attributes") gui.radioButtonsInBox( box, self, "continuous_treatment", btnLabels=[x[0] for x in self.continuous_treats], callback=self.settings_changed) box = gui.vBox(self.controlArea, "Discrete Class Attribute") gui.radioButtonsInBox( box, self, "class_treatment", btnLabels=[t[0] for t in self.class_treats], callback=self.settings_changed) zbbox = gui.vBox(self.controlArea, "Value Range") gui.radioButtonsInBox( zbbox, self, "zero_based", btnLabels=self.value_ranges, callback=self.settings_changed) gui.auto_commit(self.buttonsArea, self, "autosend", "Apply", box=False) self.data = None
def __init__(self): super().__init__() self.data = None self.set_data(self.data) # show warning gui.auto_commit(self.controlArea, self, "autocommit", "Apply")
def __init__(self): super().__init__() self.data = None self._effective_data = None self._matrix = None self._silhouette = None self._labels = None self._silplot = None gui.comboBox( self.controlArea, self, "distance_idx", box="Distance", items=[name for name, _ in OWSilhouettePlot.Distances], orientation=Qt.Horizontal, callback=self._invalidate_distances) box = gui.vBox(self.controlArea, "Cluster Label") self.cluster_var_cb = gui.comboBox( box, self, "cluster_var_idx", addSpace=4, callback=self._invalidate_scores) gui.checkBox( box, self, "group_by_cluster", "Group by cluster", callback=self._replot) self.cluster_var_model = itemmodels.VariableListModel(parent=self) self.cluster_var_cb.setModel(self.cluster_var_model) box = gui.vBox(self.controlArea, "Bars") gui.widgetLabel(box, "Bar width:") gui.hSlider( box, self, "bar_size", minValue=1, maxValue=10, step=1, callback=self._update_bar_size, addSpace=6) gui.widgetLabel(box, "Annotations:") self.annotation_cb = gui.comboBox( box, self, "annotation_var_idx", callback=self._update_annotations) self.annotation_var_model = itemmodels.VariableListModel(parent=self) self.annotation_var_model[:] = ["None"] self.annotation_cb.setModel(self.annotation_var_model) ibox = gui.indentedBox(box, 5) self.ann_hidden_warning = warning = gui.widgetLabel( ibox, "(increase the width to show)") ibox.setFixedWidth(ibox.sizeHint().width()) warning.setVisible(False) gui.rubber(self.controlArea) gui.separator(self.buttonsArea) box = gui.vBox(self.buttonsArea, "Output") # Thunk the call to commit to call conditional commit gui.checkBox(box, self, "add_scores", "Add silhouette scores", callback=lambda: self.commit()) gui.auto_commit( box, self, "auto_commit", "Commit", auto_label="Auto commit", box=False) # Ensure that the controlArea is not narrower than buttonsArea self.controlArea.layout().addWidget(self.buttonsArea) self.scene = QtGui.QGraphicsScene() self.view = QtGui.QGraphicsView(self.scene) self.view.setRenderHint(QtGui.QPainter.Antialiasing, True) self.view.setAlignment(Qt.AlignTop | Qt.AlignLeft) self.mainArea.layout().addWidget(self.view)
def __init__(self): super().__init__() self.data = None gui.radioButtons(self.controlArea, self, "axis", ["Rows", "Columns"], box="Distances between", callback=self._invalidate ) box = gui.widgetBox(self.controlArea, "Distance Metric") self.metrics_combo = gui.comboBox( box, self, "metric_idx", items=[m[0] for m in METRICS], callback=self._metric_changed ) self.normalization_check = gui.checkBox( box, self, "normalized_dist", "Normalized", callback=self._invalidate, tooltip=("All dimensions are (implicitly) scaled to a common" "scale to normalize the influence across the domain.") ) _, metric = METRICS[self.metric_idx] self.normalization_check.setEnabled(metric.supports_normalization) gui.auto_commit(self.controlArea, self, "autocommit", "Apply") self.layout().setSizeConstraint(self.layout().SetFixedSize)
def __init__(self, parent=None): super().__init__(parent) # GUI box = gui.widgetBox(self.controlArea, "Info", addSpace=True) self.infoBox = gui.widgetLabel(box, "No data on input.") box = gui.widgetBox(self.controlArea, "Split by", addSpace=True) self.groupCombo = gui.comboBox( box, self, "selectedGroup", callback=self.onGroupSelection) gui.comboBox(self.controlArea, self, "selectedCenterMethod", box="Center Fold-change Using", items=[name for name, _ in self.CENTER_METHODS], callback=self.onCenterMethodChange, addSpace=True) gui.comboBox(self.controlArea, self, "selectedMergeMethod", box="Merge Replicates", items=[name for name, _ in self.MERGE_METHODS], tooltip="Select the method for replicate merging", callback=self.onMergeMethodChange, addSpace=True) box = gui.doubleSpin(self.controlArea, self, "zCutoff", 0.0, 3.0, 0.01, box="Z-Score Cutoff", callback=[self.replotMA, self.commitIf]) gui.separator(self.controlArea) box = gui.widgetBox(self.controlArea, "Ouput") gui.checkBox(box, self, "appendZScore", "Append Z-Scores", tooltip="Append calculated Z-Scores to output", callback=self.commitIf) gui.checkBox(box, self, "appendRIValues", "Append Log Ratio and Intensity values", tooltip="Append calculated Log Ratio and Intensity " "values to output data", callback=self.commitIf) gui.rubber(self.controlArea) gui.auto_commit(self.controlArea, self, "autoCommit", "Commit") self.graph = pg.PlotWidget(background="w") self.graph.getAxis("bottom").setLabel("Intensity: log<sub>10</sub>(R*G)") self.graph.getAxis("left").setLabel("Log ratio: log<sub>2</sub>(R/G)") self.mainArea.layout().addWidget(self.graph) self.groups = [] self.split_data = None, None self.merged_splits = None, None self.centered = None, None self.changedFlag = False self.data = None self._executor = concurrent.ThreadExecutor( threadPool=QThreadPool(maxThreadCount=1))
def __init__(self, parent=None): super().__init__(parent) self.inputs = OrderedDict() self.dist_color = QtGui.QColor(*self.dist_color_RGB) info_box = gui.widgetBox(self.controlArea, "Info") self.info_ex = gui.widgetLabel(info_box, 'No data on input.', ) self.info_ex.setWordWrap(True) self.info_attr = gui.widgetLabel(info_box, ' ') self.info_attr.setWordWrap(True) self.info_class = gui.widgetLabel(info_box, ' ') self.info_class.setWordWrap(True) self.info_meta = gui.widgetLabel(info_box, ' ') self.info_meta.setWordWrap(True) gui.separator(info_box) gui.button(info_box, self, "Restore Original Order", callback=self.restore_order, tooltip="Show rows in the original order", autoDefault=False) info_box.setMinimumWidth(200) gui.separator(self.controlArea) box = gui.widgetBox(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 continuous values', callback=self._on_distribution_color_changed) gui.checkBox(box, self, "color_by_class", 'Color by instance classes', callback=self._on_distribution_color_changed) gui.button(box, self, "Set colors", self.set_colors, autoDefault=False, tooltip="Set the background color and color palette") box = gui.widgetBox(self.controlArea, "Selection") gui.checkBox(box, self, "select_rows", "Select full rows", callback=self._on_select_rows_changed) gui.rubber(self.controlArea) gui.auto_commit(self.controlArea, self, "auto_commit", "Send Selected Rows", "Auto send is on") dlg = self.create_color_dialog() self.discPalette = dlg.getDiscretePalette("discPalette") # GUI with tabs self.tabs = gui.tabWidget(self.mainArea) self.tabs.currentChanged.connect(self._on_current_tab_changed) copy = QtGui.QAction("Copy", self, shortcut=QtGui.QKeySequence.Copy, triggered=self.copy) self.addAction(copy)
def __init__(self, parent=None): super().__init__(parent) self.data = None self.preRemoveValues = 1 self.preRemoveClasses = 1 self.removedAttrs = "-" self.reducedAttrs = "-" self.resortedAttrs = "-" self.classAttr = "-" boxAt = gui.widgetBox(self.controlArea, "Attributes") gui.checkBox(boxAt, self, 'sortValues', 'Sort attribute values', callback=self.optionsChanged) gui.separator(boxAt, 2) rua = gui.checkBox( boxAt, self, "removeAttributes", "Remove attributes with less than two values", callback=self.removeAttributesChanged) ruv = gui.checkBox( gui.indentedBox(boxAt, sep=gui.checkButtonOffsetHint(rua)), self, "removeValues", "Remove unused attribute values", callback=self.optionsChanged ) rua.disables = [ruv] rua.makeConsistent() boxAt = gui.widgetBox(self.controlArea, "Classes", addSpace=True) gui.checkBox(boxAt, self, 'sortClasses', 'Sort classes', callback=self.optionsChanged) gui.separator(boxAt, 2) rua = gui.checkBox( boxAt, self, "removeClassAttribute", "Remove class attribute if there are less than two classes", callback=self.removeClassesChanged ) ruv = gui.checkBox( gui.indentedBox(boxAt, sep=gui.checkButtonOffsetHint(rua)), self, "removeClasses", "Remove unused class values", callback=self.optionsChanged ) rua.disables = [ruv] rua.makeConsistent() box3 = gui.widgetBox(self.controlArea, 'Statistics', addSpace=True) gui.label(box3, self, "Removed attributes: %(removedAttrs)s") gui.label(box3, self, "Reduced attributes: %(reducedAttrs)s") gui.label(box3, self, "Resorted attributes: %(resortedAttrs)s") gui.label(box3, self, "Class attribute: %(classAttr)s") gui.auto_commit(self.controlArea, self, "autoSend", "Send Data", checkbox_label="Send automatically", orientation="horizontal") gui.rubber(self.controlArea)
def __init__(self): super().__init__() self.data = None self.allAttrs = [] self.stringAttrs = [] self.selectedIndices = [] #: List of _ImageItems self.items = [] self._errcount = 0 self._successcount = 0 self.info = gui.widgetLabel( gui.vBox(self.controlArea, "Info"), "Waiting for input.\n" ) self.imageAttrCB = gui.comboBox( self.controlArea, self, "imageAttr", box="Image Filename Attribute", tooltip="Attribute with image filenames", callback=[self.clearScene, self.setupScene], contentsLength=12, addSpace=True, ) self.titleAttrCB = gui.comboBox( self.controlArea, self, "titleAttr", box="Title Attribute", tooltip="Attribute with image title", callback=self.updateTitles, contentsLength=12, addSpace=True ) self.titleAttrCB.setStyleSheet("combobox-popup: 0;") gui.hSlider( self.controlArea, self, "imageSize", box="Image Size", minValue=32, maxValue=1024, step=16, callback=self.updateSize, createLabel=False ) gui.rubber(self.controlArea) gui.auto_commit(self.buttonsArea, self, "autoCommit", "Send", box=False) self.thumbnailView = ThumbnailView( alignment=Qt.AlignTop | Qt.AlignLeft, # scene alignment, focusPolicy=Qt.StrongFocus, verticalScrollBarPolicy=Qt.ScrollBarAlwaysOn ) self.mainArea.layout().addWidget(self.thumbnailView) self.scene = self.thumbnailView.scene() self.scene.selectionChanged.connect(self.onSelectionChanged) self.loader = ImageLoader(self)
def _add_controls(self): self._point_box = self.graph.gui.point_properties_box(self.controlArea) self._effects_box = self.graph.gui.effects_box(self.controlArea) self._plot_box = self.graph.gui.plot_properties_box(self.controlArea) self.control_area_stretch = gui.widgetBox(self.controlArea) self.control_area_stretch.layout().addStretch(100) self.graph.box_zoom_select(self.controlArea) gui.auto_commit(self.controlArea, self, "auto_commit", "Send Selection", "Send Automatically")
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.widgetBox(self.controlArea, 'Conditions', stretch=100) self.cond_list = QtGui.QTableWidget(box) box.layout().addWidget(self.cond_list) self.cond_list.setShowGrid(False) self.cond_list.setSelectionMode(QtGui.QTableWidget.NoSelection) self.cond_list.setColumnCount(3) self.cond_list.setRowCount(0) self.cond_list.verticalHeader().hide() self.cond_list.horizontalHeader().hide() self.cond_list.resizeColumnToContents(0) self.cond_list.horizontalHeader().setResizeMode( QtGui.QHeaderView.Stretch) self.cond_list.viewport().setBackgroundRole(QtGui.QPalette.Window) box2 = gui.widgetBox(box, orientation="horizontal") 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) info = gui.widgetBox(self.controlArea, '', orientation="horizontal") box_data_in = gui.widgetBox(info, 'Data In') # self.data_in_rows = gui.widgetLabel(box_data_in, " ") self.data_in_variables = gui.widgetLabel(box_data_in, " ") gui.rubber(box_data_in) box_data_out = gui.widgetBox(info, 'Data Out') self.data_out_rows = gui.widgetLabel(box_data_out, " ") # self.dataOutAttributesLabel = gui.widgetLabel(box_data_out, " ") gui.rubber(box_data_out) box = gui.widgetBox(self.controlArea, orientation="horizontal") box_setting = gui.widgetBox(box, 'Purging') 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) gui.auto_commit(box, self, "auto_commit", label="Commit", checkbox_label="Commit on change") self.set_data(None) self.resize(600, 400)
def __init__(self): self.data = None self.indices = [] gui.comboBox(self.controlArea, self, 'agg_interval', label='Aggregate by:', items=tuple(self.AGG_TIME.keys()), sendSelectedValue=True, orientation=Qt.Horizontal, callback=self.on_changed,) self.model = model = PyTableModel(parent=self, editable=[False, True]) model.setHorizontalHeaderLabels(['Attribute', 'Aggregation function']) class TableView(gui.TableView): def __init__(self, parent): super().__init__(parent, editTriggers=(self.SelectedClicked | self.CurrentChanged | self.DoubleClicked | self.EditKeyPressed), ) self.horizontalHeader().setStretchLastSection(False) self.setItemDelegateForColumn(1, self.ComboDelegate(self)) class _ItemDelegate(QStyledItemDelegate): def updateEditorGeometry(self, widget, option, _index): widget.setGeometry(option.rect) class ComboDelegate(_ItemDelegate): def __init__(self, parent): super().__init__(parent) self._parent = parent self._combo_continuous_model = ListModel(AGG_FUNCTIONS, parent=self) self._combo_discrete_model = ListModel([Mode], parent=self) self._combo_string_model = ListModel([Concatenate], parent=self) def createEditor(self, parent, _QStyleOptionViewItem, index): combo = QComboBox(parent) attr = index.model()[index.row()][0] combo.setModel(self._combo_continuous_model if attr.is_continuous else self._combo_discrete_model if attr.is_discrete else self._combo_string_model) return combo def setEditorData(self, combo, index): var = index.model().data(index, Qt.EditRole) combo.setCurrentIndex(combo.model().indexOf(var)) def setModelData(self, combo, model, index): func = combo.model()[combo.currentIndex()] model.setData(index, func, Qt.EditRole) view = TableView(self) view.setModel(model) model.dataChanged.connect(self.on_changed) self.controlArea.layout().addWidget(view) gui.auto_commit(self.controlArea, self, 'autocommit', '&Apply')
def add_bottom_buttons(self): box = gui.vBox(self.controlArea, 'Forecast') gui.spin(box, self, 'forecast_steps', 1, 100, label='Forecast steps ahead:', callback=self.apply) gui.hSlider(box, self, 'forecast_confint', None, 1, 99, label='Confidence intervals:', callback=self.apply) gui.auto_commit(self.controlArea, self, 'autocommit', "&Apply")
def __init__(self): super().__init__() self.data = None self.results = None self.learners = [] self.headers = [] self.learners_box = gui.listBox( self.controlArea, self, "selected_learner", "learners", box=True, callback=self._learner_changed ) self.outputbox = gui.vBox(self.controlArea, "Output") box = gui.hBox(self.outputbox) gui.checkBox(box, self, "append_predictions", "Predictions", callback=self._invalidate) gui.checkBox(box, self, "append_probabilities", "Probabilities", callback=self._invalidate) gui.auto_commit(self.outputbox, self, "autocommit", "Send Selected", "Send Automatically", box=False) self.mainArea.layout().setContentsMargins(0, 0, 0, 0) box = gui.vBox(self.mainArea, box=True) sbox = gui.hBox(box) gui.rubber(sbox) gui.comboBox(sbox, self, "selected_quantity", items=self.quantities, label="Show: ", orientation=Qt.Horizontal, callback=self._update) self.tablemodel = QStandardItemModel(self) view = self.tableview = QTableView( editTriggers=QTableView.NoEditTriggers) view.setModel(self.tablemodel) view.horizontalHeader().hide() view.verticalHeader().hide() view.horizontalHeader().setMinimumSectionSize(60) view.selectionModel().selectionChanged.connect(self._invalidate) view.setShowGrid(False) view.setItemDelegate(BorderedItemDelegate(Qt.white)) view.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) view.clicked.connect(self.cell_clicked) box.layout().addWidget(view) selbox = gui.hBox(box) gui.button(selbox, self, "Select Correct", callback=self.select_correct, autoDefault=False) gui.button(selbox, self, "Select Misclassified", callback=self.select_wrong, autoDefault=False) gui.button(selbox, self, "Clear Selection", callback=self.select_none, autoDefault=False)
def __init__(self): super().__init__() if isinstance(self.selected_learner, list): self.selected_learner = (self.selected_learner + [0])[0] self.data = None self.results = None self.learners = [] self.headers = [] box = gui.vBox(self.controlArea, "Learners") self.learners_box = gui.listBox( box, self, "selected_learner", "learners", callback=self._learner_changed ) box = gui.vBox(self.controlArea, "Show") gui.comboBox(box, self, "selected_quantity", items=self.quantities, callback=self._update) box = gui.vBox(self.controlArea, "Select") gui.button(box, self, "Select Correct", callback=self.select_correct, autoDefault=False) gui.button(box, self, "Select Misclassified", callback=self.select_wrong, autoDefault=False) gui.button(box, self, "Clear Selection", callback=self.select_none, autoDefault=False) self.outputbox = box = gui.vBox(self.controlArea, "Output") gui.checkBox(box, self, "append_predictions", "Predictions", callback=self._invalidate) gui.checkBox(box, self, "append_probabilities", "Probabilities", callback=self._invalidate) gui.auto_commit(self.controlArea, self, "autocommit", "Send Selected", "Send Automatically") grid = QGridLayout() self.tablemodel = QStandardItemModel(self) view = self.tableview = QTableView( editTriggers=QTableView.NoEditTriggers) view.setModel(self.tablemodel) view.horizontalHeader().hide() view.verticalHeader().hide() view.horizontalHeader().setMinimumSectionSize(60) view.selectionModel().selectionChanged.connect(self._invalidate) view.setShowGrid(False) view.setItemDelegate(BorderedItemDelegate(Qt.white)) view.clicked.connect(self.cell_clicked) grid.addWidget(view, 0, 0) self.mainArea.layout().addLayout(grid)
def __init__(self): self.tree = QTreeWidget(self.mainArea, columnCount=2, allColumnsShowFocus=True, alternatingRowColors=True, selectionMode=QTreeWidget.ExtendedSelection, uniformRowHeights=True) self.tree.setHeaderLabels(["Itemsets", "Support", "%"]) self.tree.header().setStretchLastSection(True) self.tree.itemSelectionChanged.connect(self.selectionChanged) self.mainArea.layout().addWidget(self.tree) box = gui.widgetBox(self.controlArea, "Info") self.nItemsets = self.nSelectedExamples = self.nSelectedItemsets = '' gui.label(box, self, "Number of itemsets: %(nItemsets)s") gui.label(box, self, "Selected itemsets: %(nSelectedItemsets)s") gui.label(box, self, "Selected examples: %(nSelectedExamples)s") hbox = gui.widgetBox(box, orientation='horizontal') gui.button(hbox, self, "Expand all", callback=self.tree.expandAll) gui.button(hbox, self, "Collapse all", callback=self.tree.collapseAll) box = gui.widgetBox(self.controlArea, 'Find itemsets') gui.hSlider(box, self, 'minSupport', minValue=1, maxValue=100, label='Minimal support:', labelFormat="%d%%", callback=lambda: self.find_itemsets()) gui.hSlider(box, self, 'maxItemsets', minValue=10000, maxValue=100000, step=10000, label='Max. number of itemsets:', labelFormat="%d", callback=lambda: self.find_itemsets()) gui.checkBox(box, self, 'filterSearch', label='Apply below filters in search', tooltip='If checked, the itemsets are filtered according ' 'to below filter conditions already in the search ' 'phase. \nIf unchecked, the only filters applied ' 'during search are the ones above, ' 'and the itemsets are \nfiltered afterwards only for ' 'display, i.e. only the matching itemsets are shown.') self.button = gui.auto_commit( box, self, 'autoFind', 'Find itemsets', commit=self.find_itemsets) box = gui.widgetBox(self.controlArea, 'Filter itemsets') gui.lineEdit(box, self, 'filterKeywords', 'Contains:', callback=self.filter_change, orientation='horizontal', tooltip='A comma or space-separated list of regular ' 'expressions.') hbox = gui.widgetBox(box, orientation='horizontal') gui.spin(hbox, self, 'filterMinItems', 1, 998, label='Min. items:', callback=self.filter_change) gui.spin(hbox, self, 'filterMaxItems', 2, 999, label='Max. items:', callback=self.filter_change) gui.rubber(hbox) gui.rubber(self.controlArea) gui.auto_commit(self.controlArea, self, 'autoSend', 'Send selection') self.filter_change()