def _add_controls_start_box(self): box = gui.vBox(self.controlArea, True) form = QFormLayout( labelAlignment=Qt.AlignLeft, formAlignment=Qt.AlignLeft, fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow, verticalSpacing=10 ) form.addRow( "Max iterations:", gui.spin(box, self, "max_iter", 1, 2000, step=50)) form.addRow( "Perplexity:", gui.spin(box, self, "perplexity", 1, 100, step=1)) box.layout().addLayout(form) gui.separator(box, 10) self.runbutton = gui.button(box, self, "Run", callback=self._toggle_run) gui.separator(box, 10) gui.hSlider(box, self, "pca_components", label="PCA components:", minValue=2, maxValue=50, step=1)
def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) layout = QFormLayout() self.controlArea.setLayout(layout) minf, maxf = -sys.float_info.max, sys.float_info.max self.__values = {} self.__editors = {} self.__lines = {} for name, longname in self.integrator.parameters(): v = 0. self.__values[name] = v e = SetXDoubleSpinBox(decimals=4, minimum=minf, maximum=maxf, singleStep=0.5, value=v) e.focusIn = self.activateOptions e.editingFinished.connect(self.edited) def cf(x, name=name): return self.set_value(name, x) e.valueChanged[float].connect(cf) self.__editors[name] = e layout.addRow(name, e) l = MovableVline(position=v, label=name) l.sigMoved.connect(cf) l.sigMoveFinished.connect(self.edited) self.__lines[name] = l self.focusIn = self.activateOptions self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred) self.user_changed = False
def add_form(box): gui.separator(box) box2 = gui.hBox(box) gui.rubber(box2) form = QFormLayout() form.setContentsMargins(0, 0, 0, 0) box2.layout().addLayout(form) return form
def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self.setLayout(QVBoxLayout()) self.__scoreidx = 0 self.__strategy = UnivariateFeatureSelect.Fixed self.__k = 10 self.__p = 75.0 box = QGroupBox(title="Score", flat=True) box.setLayout(QVBoxLayout()) self.__cb = cb = QComboBox(self, ) self.__cb.currentIndexChanged.connect(self.setScoreIndex) self.__cb.activated.connect(self.edited) box.layout().addWidget(cb) self.layout().addWidget(box) box = QGroupBox(title="Strategy", flat=True) self.__group = group = QButtonGroup(self, exclusive=True) self.__spins = {} form = QFormLayout() fixedrb = QRadioButton("Fixed:", checked=True) group.addButton(fixedrb, UnivariateFeatureSelect.Fixed) kspin = QSpinBox( minimum=1, value=self.__k, enabled=self.__strategy == UnivariateFeatureSelect.Fixed ) kspin.valueChanged[int].connect(self.setK) kspin.editingFinished.connect(self.edited) self.__spins[UnivariateFeatureSelect.Fixed] = kspin form.addRow(fixedrb, kspin) percrb = QRadioButton("Percentile:") group.addButton(percrb, UnivariateFeatureSelect.Percentile) pspin = QDoubleSpinBox( minimum=0.0, maximum=100.0, singleStep=0.5, value=self.__p, suffix="%", enabled=self.__strategy == UnivariateFeatureSelect.Percentile ) pspin.valueChanged[float].connect(self.setP) pspin.editingFinished.connect(self.edited) self.__spins[UnivariateFeatureSelect.Percentile] = pspin # Percentile controls disabled for now. pspin.setEnabled(False) percrb.setEnabled(False) form.addRow(percrb, pspin) # form.addRow(QRadioButton("FDR"), QDoubleSpinBox()) # form.addRow(QRadioButton("FPR"), QDoubleSpinBox()) # form.addRow(QRadioButton("FWE"), QDoubleSpinBox()) self.__group.buttonClicked.connect(self.__on_buttonClicked) box.setLayout(form) self.layout().addWidget(box)
def create_configuration_layout(self): layout = QFormLayout() spin = gui.spin(self, self, 'f', minv=1, maxv=SimhashVectorizer.max_f) spin.editingFinished.connect(self.on_change) layout.addRow('Simhash size:', spin) spin = gui.spin(self, self, 'shingle_len', minv=1, maxv=100) spin.editingFinished.connect(self.on_change) layout.addRow('Shingle length:', spin) return layout
def __run_add_package_dialog(self): self.__add_package_by_name_dialog = dlg = QDialog( self, windowTitle="Add add-on by name", ) dlg.setAttribute(Qt.WA_DeleteOnClose) vlayout = QVBoxLayout() form = QFormLayout() form.setContentsMargins(0, 0, 0, 0) nameentry = QLineEdit( placeholderText="Package name", toolTip="Enter a package name as displayed on " "PyPI (capitalization is not important)") nameentry.setMinimumWidth(250) form.addRow("Name:", nameentry) vlayout.addLayout(form) buttons = QDialogButtonBox( standardButtons=QDialogButtonBox.Ok | QDialogButtonBox.Cancel ) okb = buttons.button(QDialogButtonBox.Ok) okb.setEnabled(False) okb.setText("Add") def changed(name): okb.setEnabled(bool(name)) nameentry.textChanged.connect(changed) vlayout.addWidget(buttons) vlayout.setSizeConstraint(QVBoxLayout.SetFixedSize) dlg.setLayout(vlayout) f = None def query(): nonlocal f name = nameentry.text() def query_pypi(name): # type: (str) -> _QueryResult res = pypi_json_query_project_meta([name]) assert len(res) == 1 r = res[0] if r is not None: r = installable_from_json_response(r) return _QueryResult(queryname=name, installable=r) f = self.__executor.submit(query_pypi, name) okb.setDisabled(True) f.add_done_callback( method_queued(self.__on_add_single_query_finish, (object,)) ) buttons.accepted.connect(query) buttons.rejected.connect(dlg.reject) dlg.exec_()
def __init__(self): super().__init__() self.data = None self.filename = "" self.basename = "" self.type_ext = "" self.compress_ext = "" self.writer = None form = QFormLayout( labelAlignment=Qt.AlignLeft, formAlignment=Qt.AlignLeft, rowWrapPolicy=QFormLayout.WrapLongRows, verticalSpacing=10, ) box = gui.vBox(self.controlArea, "Format") gui.comboBox( box, self, "filetype", callback=self._update_text, items=[item for item, _, _ in FILE_TYPES], sendSelectedValue=True, ) form.addRow("File type", self.controls.filetype, ) gui.comboBox( box, self, "compression", callback=self._update_text, items=[item for item, _ in COMPRESSIONS], sendSelectedValue=True, ) gui.checkBox( box, self, "compress", label="Use compression", callback=self._update_text, ) form.addRow(self.controls.compress, self.controls.compression) box.layout().addLayout(form) self.save = gui.auto_commit( self.controlArea, self, "auto_save", "Save", box=False, commit=self.save_file, callback=self.adjust_label, disabled=True, addSpace=True ) self.save_as = gui.button( self.controlArea, self, "Save As...", callback=self.save_file_as, disabled=True ) self.save_as.setMinimumWidth(220) self.adjustSize()
def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self.setLayout(QVBoxLayout()) self.n_components = 10 form = QFormLayout() self.cspin = QSpinBox(minimum=1, value=self.n_components) self.cspin.valueChanged[int].connect(self.setC) self.cspin.editingFinished.connect(self.edited) form.addRow("Components:", self.cspin) self.layout().addLayout(form)
def __init__(self, parent): super().__init__() self.parent = parent self.api = None form = QFormLayout() form.setContentsMargins(5, 5, 5, 5) self.key_edit = gui.lineEdit(self, self, 'key_input', controlWidth=400) form.addRow('Key:', self.key_edit) self.controlArea.layout().addLayout(form) self.submit_button = gui.button(self.controlArea, self, "OK", self.accept) self.load_credentials()
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): super().__init__() box = gui.widgetBox(self.controlArea, "Map grid") form = QWidget() formlayout = QFormLayout() form.setLayout(formlayout) box.layout().addWidget(form) self.le1 = lineEditIntOrNone(box, self, "xpoints", callback=self.le1_changed) formlayout.addRow("X dimension", self.le1) self.le3 = lineEditIntOrNone(box, self, "ypoints", callback=self.le3_changed) formlayout.addRow("Y dimension", self.le3) self.data = None self.set_data(self.data) # show warning gui.auto_commit(self.controlArea, self, "autocommit", "Send Data")
def setup_gui(self): layout = QVBoxLayout() self.setLayout(layout) self.main_form = QFormLayout() self.main_form.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow) layout.addLayout(self.main_form) self._setup_gui_name() self._setup_gui_labels()
def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self.setLayout(QVBoxLayout()) form = QFormLayout() self.__rand_type_cb = QComboBox() self.__rand_type_cb.addItems(["Classes", "Features", "Meta data"]) self.__rand_type_cb.currentIndexChanged.connect(self.changed) self.__rand_type_cb.activated.connect(self.edited) self.__rand_seed_ch = QCheckBox() self.__rand_seed_ch.clicked.connect(self.edited) form.addRow("Randomize:", self.__rand_type_cb) form.addRow("Replicable shuffling:", self.__rand_seed_ch) self.layout().addLayout(form)
def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self.setLayout(QVBoxLayout()) form = QFormLayout() self.__centercb = QComboBox() self.__centercb.addItems(["No Centering", "Center by Mean", "Center by Median"]) self.__scalecb = QComboBox() self.__scalecb.addItems(["No scaling", "Scale by SD", "Scale by span"]) form.addRow("Center:", self.__centercb) form.addRow("Scale:", self.__scalecb) self.layout().addLayout(form) self.__centercb.currentIndexChanged.connect(self.changed) self.__scalecb.currentIndexChanged.connect(self.changed) self.__centercb.activated.connect(self.edited) self.__scalecb.activated.connect(self.edited)
def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self.setLayout(QVBoxLayout()) self.rank = 10 self.max_error = 1 form = QFormLayout() self.rspin = QSpinBox(minimum=2, value=self.rank) self.rspin.valueChanged[int].connect(self.setR) self.rspin.editingFinished.connect(self.edited) self.espin = QDoubleSpinBox( minimum=0.1, maximum=100.0, singleStep=0.1, value=self.max_error) self.espin.valueChanged[float].connect(self.setE) self.espin.editingFinished.connect(self.edited) form.addRow("Rank:", self.rspin) form.addRow("Relative error:", self.espin) self.layout().addLayout(form)
def color_settings_box(self): box = gui.vBox(self) self.color_cb = gui.comboBox(box, self, "palette_index", label="Color:", labelWidth=50, orientation=Qt.Horizontal) self.color_cb.setIconSize(QSize(64, 16)) palettes = _color_palettes self.palette_index = min(self.palette_index, len(palettes) - 1) model = color_palette_model(palettes, self.color_cb.iconSize()) model.setParent(self) self.color_cb.setModel(model) self.color_cb.activated.connect(self.update_color_schema) self.color_cb.setCurrentIndex(self.palette_index) form = QFormLayout( formAlignment=Qt.AlignLeft, labelAlignment=Qt.AlignLeft, fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow ) def limit_changed(): self.update_levels() self.reset_thresholds() self._level_low_le = lineEditDecimalOrNone(self, self, "level_low", callback=limit_changed) self._level_low_le.validator().setDefault(0) form.addRow("Low limit:", self._level_low_le) self._level_high_le = lineEditDecimalOrNone(self, self, "level_high", callback=limit_changed) self._level_high_le.validator().setDefault(1) form.addRow("High limit:", self._level_high_le) lowslider = gui.hSlider( box, self, "threshold_low", minValue=0.0, maxValue=1.0, step=0.05, ticks=True, intOnly=False, createLabel=False, callback=self.update_levels) highslider = gui.hSlider( box, self, "threshold_high", minValue=0.0, maxValue=1.0, step=0.05, ticks=True, intOnly=False, createLabel=False, callback=self.update_levels) form.addRow("Low:", lowslider) form.addRow("High:", highslider) box.layout().addLayout(form) return box
def __setupUi(self): layout = QFormLayout() layout.setRowWrapPolicy(QFormLayout.WrapAllRows) layout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow) self.name_edit = LineEdit(self) self.name_edit.setPlaceholderText(self.tr("untitled")) self.name_edit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.desc_edit = QTextEdit(self) self.desc_edit.setTabChangesFocus(True) layout.addRow(self.tr("Title"), self.name_edit) layout.addRow(self.tr("Description"), self.desc_edit) self.__schemeIsUntitled = True self.setLayout(layout)
def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self.setLayout(QVBoxLayout()) self.__strategy = RandomFeatureSelectEditor.Fixed self.__k = 10 self.__p = 75.0 box = QGroupBox(title="Strategy", flat=True) self.__group = group = QButtonGroup(self, exclusive=True) self.__spins = {} form = QFormLayout() fixedrb = QRadioButton("Fixed", checked=True) group.addButton(fixedrb, RandomFeatureSelectEditor.Fixed) kspin = QSpinBox( minimum=1, value=self.__k, enabled=self.__strategy == RandomFeatureSelectEditor.Fixed ) kspin.valueChanged[int].connect(self.setK) kspin.editingFinished.connect(self.edited) self.__spins[RandomFeatureSelectEditor.Fixed] = kspin form.addRow(fixedrb, kspin) percrb = QRadioButton("Percentage") group.addButton(percrb, RandomFeatureSelectEditor.Percentage) pspin = QDoubleSpinBox( minimum=0.0, maximum=100.0, singleStep=0.5, value=self.__p, suffix="%", enabled=self.__strategy == RandomFeatureSelectEditor.Percentage ) pspin.valueChanged[float].connect(self.setP) pspin.editingFinished.connect(self.edited) self.__spins[RandomFeatureSelectEditor.Percentage] = pspin form.addRow(percrb, pspin) self.__group.buttonClicked.connect(self.__on_buttonClicked) box.setLayout(form) self.layout().addWidget(box)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) layout = QFormLayout( fieldGrowthPolicy=QFormLayout.ExpandingFieldsGrow ) layout.setContentsMargins(0, 0, 0, 0) self.nameedit = QLineEdit( placeholderText="Name...", sizePolicy=QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) ) self.expressionedit = QLineEdit( placeholderText="Expression..." ) self.attrs_model = itemmodels.VariableListModel( ["Select Feature"], parent=self) self.attributescb = QComboBox( minimumContentsLength=16, sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLengthWithIcon, sizePolicy=QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) ) self.attributescb.setModel(self.attrs_model) sorted_funcs = sorted(self.FUNCTIONS) self.funcs_model = itemmodels.PyListModelTooltip() self.funcs_model.setParent(self) self.funcs_model[:] = chain(["Select Function"], sorted_funcs) self.funcs_model.tooltips[:] = chain( [''], [self.FUNCTIONS[func].__doc__ for func in sorted_funcs]) self.functionscb = QComboBox( minimumContentsLength=16, sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLengthWithIcon, sizePolicy=QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)) self.functionscb.setModel(self.funcs_model) hbox = QHBoxLayout() hbox.addWidget(self.attributescb) hbox.addWidget(self.functionscb) layout.addRow(self.nameedit, self.expressionedit) layout.addRow(self.tr(""), hbox) self.setLayout(layout) self.nameedit.editingFinished.connect(self._invalidate) self.expressionedit.textChanged.connect(self._invalidate) self.attributescb.currentIndexChanged.connect(self.on_attrs_changed) self.functionscb.currentIndexChanged.connect(self.on_funcs_changed) self._modified = False
def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self.setLayout(QVBoxLayout()) self.__strategy = RandomFeatureSelectEditor.Fixed self.__k = 10 self.__p = 75.0 box = QGroupBox(title="Strategy", flat=True) self.__group = group = QButtonGroup(self, exclusive=True) self.__spins = {} form = QFormLayout() fixedrb = QRadioButton("Fixed", checked=True) group.addButton(fixedrb, RandomFeatureSelectEditor.Fixed) kspin = QSpinBox( minimum=1, value=self.__k, enabled=self.__strategy == RandomFeatureSelectEditor.Fixed) kspin.valueChanged[int].connect(self.setK) kspin.editingFinished.connect(self.edited) self.__spins[RandomFeatureSelectEditor.Fixed] = kspin form.addRow(fixedrb, kspin) percrb = QRadioButton("Percentage") group.addButton(percrb, RandomFeatureSelectEditor.Percentage) pspin = QDoubleSpinBox( minimum=0.0, maximum=100.0, singleStep=0.5, value=self.__p, suffix="%", enabled=self.__strategy == RandomFeatureSelectEditor.Percentage) pspin.valueChanged[float].connect(self.setP) pspin.editingFinished.connect(self.edited) self.__spins[RandomFeatureSelectEditor.Percentage] = pspin form.addRow(percrb, pspin) self.__group.buttonClicked.connect(self.__on_buttonClicked) box.setLayout(form) self.layout().addWidget(box)
def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self._threshold = self.DEFAULT_THRESHOLD self.setLayout(QVBoxLayout()) form = QFormLayout() self.cond_cb = QComboBox() self.cond_cb.addItems(["Greater or Equal", "Greater"]) self.cond_cb.currentIndexChanged.connect(self.changed) self.cond_cb.activated.connect(self.edited) self.thr_spin = QDoubleSpinBox(minimum=0, singleStep=0.5, decimals=1, value=self._threshold) self.thr_spin.valueChanged[float].connect(self._set_threshold) self.thr_spin.editingFinished.connect(self.edited) form.addRow("Condition:", self.cond_cb) form.addRow("Threshold:", self.thr_spin) self.layout().addLayout(form)
def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self.setLayout(QVBoxLayout()) self.rank = 10 self.max_error = 1 form = QFormLayout() self.rspin = QSpinBox(minimum=2, maximum=1000000, value=self.rank) self.rspin.valueChanged[int].connect(self.setR) self.rspin.editingFinished.connect(self.edited) self.espin = QDoubleSpinBox(minimum=0.1, maximum=100.0, singleStep=0.1, value=self.max_error) self.espin.valueChanged[float].connect(self.setE) self.espin.editingFinished.connect(self.edited) form.addRow("Rank:", self.rspin) form.addRow("Relative error:", self.espin) self.layout().addLayout(form)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.data: Optional[Table] = None self._output_desc: Optional[Dict[str, str]] = None box = gui.widgetBox(self.controlArea, "唯一行标识符") self.idvar_model = itemmodels.VariableListModel( [None], placeholder="行号") self.var_cb = gui.comboBox( box, self, "idvar", model=self.idvar_model, callback=self._invalidate, minimumContentsLength=16, tooltip="包含标识符(如客户的 ID)的列") box = gui.widgetBox(self.controlArea, "筛选") gui.checkBox( box, self, "only_numeric", "忽略非数值特征", callback=self._invalidate) gui.checkBox( box, self, "exclude_zeros", "排除0值", callback=self._invalidate, tooltip="除了缺失值之外,还要省略值为0的行") form = QFormLayout() gui.widgetBox( self.controlArea, "生成特征的名称", orientation=form) form.addRow("项目:", gui.lineEdit( None, self, "item_var_name", callback=self._invalidate, placeholderText=DEFAULT_ITEM_NAME, styleSheet="padding-left: 3px")) form.addRow("值:", gui.lineEdit( None, self, "value_var_name", callback=self._invalidate, placeholderText=DEFAULT_VALUE_NAME, styleSheet="padding-left: 3px")) gui.auto_apply(self.controlArea, self)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.data: Optional[Table] = None self._output_desc: Optional[Dict[str, str]] = None box = gui.widgetBox(self.controlArea, "Unique Row Identifier") self.idvar_model = itemmodels.VariableListModel( [None], placeholder="Row number") self.var_cb = gui.comboBox( box, self, "idvar", model=self.idvar_model, callback=self._invalidate, minimumContentsLength=16, tooltip="A column with identifier, like customer's id") box = gui.widgetBox(self.controlArea, "Filter") gui.checkBox( box, self, "only_numeric", "Ignore non-numeric features", callback=self._invalidate) gui.checkBox( box, self, "exclude_zeros", "Exclude zero values", callback=self._invalidate, tooltip="Besides missing values, also omit items with zero values") form = QFormLayout() gui.widgetBox( self.controlArea, "Names for generated features", orientation=form) form.addRow("Item:", gui.lineEdit( None, self, "item_var_name", callback=self._invalidate, placeholderText=DEFAULT_ITEM_NAME, styleSheet="padding-left: 3px")) form.addRow("Value:", gui.lineEdit( None, self, "value_var_name", callback=self._invalidate, placeholderText=DEFAULT_VALUE_NAME, styleSheet="padding-left: 3px")) gui.auto_apply(self.controlArea, self)
def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self.setLayout(QVBoxLayout()) self._n_genes = self.DEFAULT_N_GENS self._n_groups = self.DEFAULT_N_GROUPS form = QFormLayout() self.n_genes_spin = QSpinBox(minimum=1, maximum=10**6, value=self._n_genes) self.n_genes_spin.valueChanged[int].connect(self._set_n_genes) self.n_genes_spin.editingFinished.connect(self.edited) form.addRow("Number of genes:", self.n_genes_spin) self.layout().addLayout(form) disp_b = QRadioButton("Dispersion", checked=True) vari_b = QRadioButton("Variance") mean_b = QRadioButton("Mean") self.group = QButtonGroup() self.group.buttonClicked.connect(self._on_button_clicked) for i, button in enumerate([disp_b, vari_b, mean_b]): index = index_to_enum(SelectMostVariableGenes.Method, i).value self.group.addButton(button, index - 1) form.addRow(button) self.stats_check = QCheckBox("Compute statistics for", checked=self.DEFAULT_COMPUTE_STATS) self.stats_check.clicked.connect(self.edited) self.n_groups_spin = QSpinBox(minimum=1, value=self._n_groups) self.n_groups_spin.valueChanged[int].connect(self._set_n_groups) self.n_groups_spin.editingFinished.connect(self.edited) box = QHBoxLayout() box.addWidget(self.stats_check) box.addWidget(self.n_groups_spin) box.addWidget(QLabel("gene groups.")) box.addStretch() self.layout().addLayout(box)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) w = self.widget(0) # 'General' tab layout = w.layout() assert isinstance(layout, QFormLayout) cb = QCheckBox(self.tr("Automatically check for updates")) cb.setAttribute(Qt.WA_LayoutUsesWidgetRect) layout.addRow("Updates", cb) self.bind(cb, "checked", "startup/check-updates") # Error Reporting Tab tab = QWidget() self.addTab(tab, self.tr("Error Reporting"), toolTip="Settings related to error reporting") form = QFormLayout() line_edit_mid = QLineEdit() self.bind(line_edit_mid, "text", "error-reporting/machine-id") form.addRow("Machine ID:", line_edit_mid) box = QWidget() layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) cb1 = QCheckBox( self.tr(""), toolTip=self.tr( "Share anonymous usage statistics to improve Orange") ) self.bind(cb1, "checked", "error-reporting/send-statistics") cb1.clicked.connect(UsageStatistics.set_enabled) layout.addWidget(cb1) box.setLayout(layout) form.addRow(self.tr("Share Anonymous Statistics"), box) tab.setLayout(form)
def __init__(self): super().__init__() box = gui.widgetBox(self.controlArea, "Map grid") form = QWidget() formlayout = QFormLayout() form.setLayout(formlayout) box.layout().addWidget(form) self.le1 = lineEditIntOrNone(box, self, "xpoints", callback=self.le1_changed) formlayout.addRow("X dimension", self.le1) self.le3 = lineEditIntOrNone(box, self, "ypoints", callback=self.le3_changed) formlayout.addRow("Y dimension", self.le3) gui.checkBox(box, self, "invert_x", "Invert X axis", callback=lambda: self.commit()) gui.checkBox(box, self, "invert_y", "Invert Y axis", callback=lambda: self.commit()) self.data = None self.set_data(self.data) # show warning gui.auto_commit(self.controlArea, self, "autocommit", "Send Data")
def __setupUi(self): """Set up the UI. """ if self.__macUnified: self.tab = QToolBar( floatable=False, movable=False, allowedAreas=Qt.TopToolBarArea, ) self.addToolBar(Qt.TopToolBarArea, self.tab) self.setUnifiedTitleAndToolBarOnMac(True) # This does not seem to work self.setWindowFlags(self.windowFlags() & \ ~Qt.MacWindowToolBarButtonHint) self.tab.actionTriggered[QAction].connect( self.__macOnToolBarAction) central = QStackedWidget() central.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) else: self.tab = central = QTabWidget(self) # Add a close button to the bottom of the dialog # (to satisfy GNOME 3 which shows the dialog without a title bar). container = container_widget_helper() container.layout().addWidget(central) buttonbox = QDialogButtonBox(QDialogButtonBox.Close) buttonbox.rejected.connect(self.close) container.layout().addWidget(buttonbox) self.setCentralWidget(container) self.stack = central # General Tab tab = QWidget() self.addTab(tab, self.tr("General"), toolTip=self.tr("General Options")) form = QFormLayout() tab.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) nodes = QWidget(self, objectName="nodes") nodes.setLayout(QVBoxLayout()) nodes.layout().setContentsMargins(0, 0, 0, 0) cb_anim = QCheckBox(self.tr("Enable node animations"), objectName="enable-node-animations", toolTip=self.tr( "Enable shadow and ping animations for nodes " "in the workflow.")) self.bind(cb_anim, "checked", "schemeedit/enable-node-animations") nodes.layout().addWidget(cb_anim) form.addRow(self.tr("Nodes"), nodes) links = QWidget(self, objectName="links") links.setLayout(QVBoxLayout()) links.layout().setContentsMargins(0, 0, 0, 0) cb_show = QCheckBox(self.tr("Show channel names between widgets"), objectName="show-channel-names", toolTip=self.tr( "Show source and sink channel names " "over the links.")) self.bind(cb_show, "checked", "schemeedit/show-channel-names") links.layout().addWidget(cb_show) form.addRow(self.tr("Links"), links) quickmenu = QWidget(self, objectName="quickmenu-options") quickmenu.setLayout(QVBoxLayout()) quickmenu.layout().setContentsMargins(0, 0, 0, 0) cb1 = QCheckBox(self.tr("Open on double click"), toolTip=self.tr("Open quick menu on a double click " "on an empty spot in the canvas")) cb2 = QCheckBox(self.tr("Open on right click"), toolTip=self.tr("Open quick menu on a right click " "on an empty spot in the canvas")) cb3 = QCheckBox(self.tr("Open on space key press"), toolTip=self.tr( "Open quick menu on Space key press " "while the mouse is hovering over the canvas.")) cb4 = QCheckBox(self.tr("Open on any key press"), toolTip=self.tr( "Open quick menu on any key press " "while the mouse is hovering over the canvas.")) cb5 = QCheckBox(self.tr("Show categories"), toolTip=self.tr( "In addition to searching, allow filtering " "by categories.")) self.bind(cb1, "checked", "quickmenu/trigger-on-double-click") self.bind(cb2, "checked", "quickmenu/trigger-on-right-click") self.bind(cb3, "checked", "quickmenu/trigger-on-space-key") self.bind(cb4, "checked", "quickmenu/trigger-on-any-key") self.bind(cb5, "checked", "quickmenu/show-categories") quickmenu.layout().addWidget(cb1) quickmenu.layout().addWidget(cb2) quickmenu.layout().addWidget(cb3) quickmenu.layout().addWidget(cb4) quickmenu.layout().addWidget(cb5) form.addRow(self.tr("Quick menu"), quickmenu) startup = QWidget(self, objectName="startup-group") startup.setLayout(QVBoxLayout()) startup.layout().setContentsMargins(0, 0, 0, 0) cb_splash = QCheckBox(self.tr("Show splash screen"), self, objectName="show-splash-screen") cb_welcome = QCheckBox(self.tr("Show welcome screen"), self, objectName="show-welcome-screen") self.bind(cb_splash, "checked", "startup/show-splash-screen") self.bind(cb_welcome, "checked", "startup/show-welcome-screen") startup.layout().addWidget(cb_splash) startup.layout().addWidget(cb_welcome) form.addRow(self.tr("On startup"), startup) toolbox = QWidget(self, objectName="toolbox-group") toolbox.setLayout(QVBoxLayout()) toolbox.layout().setContentsMargins(0, 0, 0, 0) exclusive = QCheckBox(self.tr("Only one tab can be open at a time")) self.bind(exclusive, "checked", "mainwindow/toolbox-dock-exclusive") toolbox.layout().addWidget(exclusive) form.addRow(self.tr("Tool box"), toolbox) tab.setLayout(form) # Output Tab tab = QWidget() self.addTab(tab, self.tr("Output"), toolTip="Output Redirection") form = QFormLayout() box = QWidget() layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) combo = QComboBox() combo.addItems([ self.tr("Critical"), self.tr("Error"), self.tr("Warn"), self.tr("Info"), self.tr("Debug") ]) self.bind(combo, "currentIndex", "logging/level") layout.addWidget(combo) box.setLayout(layout) form.addRow(self.tr("Logging"), box) box = QWidget() layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) cb1 = QCheckBox(self.tr("Open in external browser"), objectName="open-in-external-browser") self.bind(cb1, "checked", "help/open-in-external-browser") layout.addWidget(cb1) box.setLayout(layout) form.addRow(self.tr("Help window"), box) tab.setLayout(form) # Categories Tab tab = QWidget() layout = QVBoxLayout() view = QListView(editTriggers=QListView.NoEditTriggers) from .. import registry reg = registry.global_registry() model = QStandardItemModel() settings = QSettings() for cat in reg.categories(): item = QStandardItem() item.setText(cat.name) item.setCheckable(True) visible, _ = category_state(cat, settings) item.setCheckState(Qt.Checked if visible else Qt.Unchecked) model.appendRow([item]) view.setModel(model) layout.addWidget(view) tab.setLayout(layout) model.itemChanged.connect(lambda item: save_category_state( reg.category(str(item.text())), _State(item.checkState() == Qt.Checked, -1), settings)) self.addTab(tab, "Categories") # Add-ons Tab tab = QWidget() self.addTab(tab, self.tr("Add-ons"), toolTip="Settings related to add-on installation") form = QFormLayout() conda = QWidget(self, objectName="conda-group") conda.setLayout(QVBoxLayout()) conda.layout().setContentsMargins(0, 0, 0, 0) cb_conda_install = QCheckBox(self.tr("Install add-ons with conda"), self, objectName="allow-conda-experimental") self.bind(cb_conda_install, "checked", "add-ons/allow-conda-experimental") conda.layout().addWidget(cb_conda_install) form.addRow(self.tr("Conda"), conda) form.addRow(self.tr("Pip"), QLabel("Pip install arguments:")) line_edit_pip = QLineEdit() self.bind(line_edit_pip, "text", "add-ons/pip-install-arguments") form.addRow("", line_edit_pip) tab.setLayout(form) # Network Tab tab = QWidget() self.addTab(tab, self.tr("Network"), toolTip="Settings related to networking") form = QFormLayout() line_edit_http_proxy = QLineEdit() self.bind(line_edit_http_proxy, "text", "network/http-proxy") form.addRow("HTTP proxy:", line_edit_http_proxy) line_edit_https_proxy = QLineEdit() self.bind(line_edit_https_proxy, "text", "network/https-proxy") form.addRow("HTTPS proxy:", line_edit_https_proxy) tab.setLayout(form) if self.__macUnified: # Need some sensible size otherwise mac unified toolbar 'takes' # the space that should be used for layout of the contents self.adjustSize()
def __init__(self): super().__init__() if self.compatibility_mode: self.Information.compatibility_mode() self.data = None self.indices = None self.sampled_instances = self.remaining_instances = None self.info.set_input_summary(self.info.NoInput) self.info.set_output_summary(self.info.NoInput) self.sampling_box = gui.vBox(self.controlArea, "Sampling Type") sampling = gui.radioButtons(self.sampling_box, self, "sampling_type", callback=self.sampling_type_changed) def set_sampling_type(i): def set_sampling_type_i(): self.sampling_type = i self.sampling_type_changed() return set_sampling_type_i gui.appendRadioButton(sampling, "Fixed proportion of data:") self.sampleSizePercentageSlider = gui.hSlider( gui.indentedBox(sampling), self, "sampleSizePercentage", minValue=0, maxValue=100, ticks=10, labelFormat="%d %%", callback=set_sampling_type(self.FixedProportion), addSpace=12) gui.appendRadioButton(sampling, "Fixed sample size") ibox = gui.indentedBox(sampling) self.sampleSizeSpin = gui.spin(ibox, self, "sampleSizeNumber", label="Instances: ", minv=1, maxv=self._MAX_SAMPLE_SIZE, callback=set_sampling_type( self.FixedSize), controlWidth=90) gui.checkBox(ibox, self, "replacement", "Sample with replacement", callback=set_sampling_type(self.FixedSize), addSpace=12) gui.appendRadioButton(sampling, "Cross validation") form = QFormLayout(formAlignment=Qt.AlignLeft | Qt.AlignTop, labelAlignment=Qt.AlignLeft, fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow) ibox = gui.indentedBox(sampling, addSpace=True, orientation=form) form.addRow( "Number of subsets:", gui.spin(ibox, self, "number_of_folds", 2, 100, addToLayout=False, callback=self.number_of_folds_changed)) self.selected_fold_spin = gui.spin(ibox, self, "selectedFold", 1, self.number_of_folds, addToLayout=False, callback=self.fold_changed) form.addRow( "Unused subset:" if not self.compatibility_mode else "Selected subset:", self.selected_fold_spin) gui.appendRadioButton(sampling, "Bootstrap") self.sql_box = gui.vBox(self.controlArea, "Sampling Type") sampling = gui.radioButtons(self.sql_box, self, "sampling_type", callback=self.sampling_type_changed) gui.appendRadioButton(sampling, "Time:") ibox = gui.indentedBox(sampling) spin = gui.spin(ibox, self, "sampleSizeSqlTime", minv=1, maxv=3600, callback=set_sampling_type(self.SqlTime)) spin.setSuffix(" sec") gui.appendRadioButton(sampling, "Percentage") ibox = gui.indentedBox(sampling) spin = gui.spin(ibox, self, "sampleSizeSqlPercentage", spinType=float, minv=0.0001, maxv=100, step=0.1, decimals=4, callback=set_sampling_type(self.SqlProportion)) spin.setSuffix(" %") self.sql_box.setVisible(False) self.options_box = gui.vBox(self.controlArea, "Options") self.cb_seed = gui.checkBox(self.options_box, self, "use_seed", "Replicable (deterministic) sampling", callback=self.settings_changed) self.cb_stratify = gui.checkBox(self.options_box, self, "stratify", "Stratify sample (when possible)", callback=self.settings_changed) self.cb_sql_dl = gui.checkBox(self.options_box, self, "sql_dl", "Download data to local memory", callback=self.settings_changed) self.cb_sql_dl.setVisible(False) gui.button(self.buttonsArea, self, "Sample Data", callback=self.commit)
def __init__(self): super().__init__() self.data = None # type: Optional[Orange.data.Table] self._state = None # type: Optional[_FilterData] box = gui.widgetBox(self.controlArea, "Info") self._info = QLabel(box, wordWrap=True) self._info.setText("No data in input\n") box.layout().addWidget(self._info) box = gui.widgetBox(self.controlArea, "Filter Type", spacing=-1) rbg = QButtonGroup(box, exclusive=True) layout = QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) for id_ in [Cells, Genes, Data]: name, _, tip = FilterInfo[id_] b = QRadioButton(name, toolTip=tip, checked=id_ == self.selected_filter_type) rbg.addButton(b, id_) layout.addWidget(b, stretch=10, alignment=Qt.AlignCenter) box.layout().addLayout(layout) rbg.buttonClicked[int].connect(self.set_filter_type) self.filter_metric_cb = gui.comboBox( box, self, "selected_filter_metric", callback=self._update_metric, enabled=self.selected_filter_type != Data) for id_ in [DetectionCount, TotalCounts]: text, ttip = MeasureInfo[id_] self.filter_metric_cb.addItem(text) idx = self.filter_metric_cb.count() - 1 self.filter_metric_cb.setItemData(idx, ttip, Qt.ToolTipRole) self.filter_metric_cb.setCurrentIndex(self.selected_filter_metric) form = QFormLayout(labelAlignment=Qt.AlignLeft, formAlignment=Qt.AlignLeft, fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow) self._filter_box = box = gui.widgetBox( self.controlArea, "Filter", orientation=form) # type: QGroupBox self.threshold_stacks = ( QStackedWidget(enabled=self.limit_lower_enabled), QStackedWidget(enabled=self.limit_upper_enabled), ) finfo = np.finfo(np.float64) for filter_ in [Cells, Genes, Data]: if filter_ in {Cells, Genes}: minimum = 0.0 ndecimals = 1 metric = self.selected_filter_metric else: minimum = finfo.min ndecimals = 3 metric = -1 spinlower = QDoubleSpinBox( self, minimum=minimum, maximum=finfo.max, decimals=ndecimals, keyboardTracking=False, ) spinupper = QDoubleSpinBox( self, minimum=minimum, maximum=finfo.max, decimals=ndecimals, keyboardTracking=False, ) lower, upper = self.thresholds.get((filter_, metric), (0, 0)) spinlower.setValue(lower) spinupper.setValue(upper) self.threshold_stacks[0].addWidget(spinlower) self.threshold_stacks[1].addWidget(spinupper) spinlower.valueChanged.connect(self._limitchanged) spinupper.valueChanged.connect(self._limitchanged) self.threshold_stacks[0].setCurrentIndex(self.selected_filter_type) self.threshold_stacks[1].setCurrentIndex(self.selected_filter_type) self.limit_lower_enabled_cb = cb = QCheckBox( "Min", checked=self.limit_lower_enabled) cb.toggled.connect(self.set_lower_limit_enabled) cb.setAttribute(Qt.WA_LayoutUsesWidgetRect, True) form.addRow(cb, self.threshold_stacks[0]) self.limit_upper_enabled_cb = cb = QCheckBox( "Max", checked=self.limit_upper_enabled) cb.toggled.connect(self.set_upper_limit_enabled) cb.setAttribute(Qt.WA_LayoutUsesWidgetRect, True) form.addRow(cb, self.threshold_stacks[1]) box = gui.widgetBox(self.controlArea, "Plot Options") self._showpoints = gui.checkBox(box, self, "display_dotplot", "Show data points", callback=self._update_dotplot) self.log_scale_cb = QCheckBox("Log scale", checked=self.scale == Scale.Log1p.name) self.log_scale_cb.toggled[bool].connect( lambda state: self.set_filter_scale(Scale.Log1p if state else Scale.Linear)) box.layout().addWidget(self.log_scale_cb) self.controlArea.layout().addStretch(10) gui.auto_commit(self.controlArea, self, "auto_commit", "Commit") self._view = pg.GraphicsView() self._view.enableMouse(False) self._view.setAntialiasing(True) self._plot = plot = ViolinPlot() self._plot.setDataPointsVisible(self.display_dotplot) self._plot.setSelectionMode( (ViolinPlot.Low if self.limit_lower_enabled else 0) | (ViolinPlot.High if self.limit_upper_enabled else 0)) self._plot.setRange(QRectF(-1., 0., 2., 1.)) self._plot.selectionEdited.connect(self._limitchanged_plot) self._view.setCentralWidget(self._plot) bottom = self._plot.getAxis("bottom") # type: pg.AxisItem bottom.hide() plot.setMouseEnabled(False, False) plot.hideButtons() self.mainArea.layout().addWidget(self._view) # Coalescing commit timer self._committimer = QTimer(self, singleShot=True) self._committimer.timeout.connect(self.commit) self.addAction( QAction("Select All", self, shortcut=QKeySequence.SelectAll, triggered=self._select_all)) self._setup_axes()
def _add_controls_start_box(self): box = gui.vBox(self.controlArea, box="Optimize") form = QFormLayout( labelAlignment=Qt.AlignLeft, formAlignment=Qt.AlignLeft, fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow, ) self.perplexity_spin = gui.spin( box, self, "perplexity", 1, 500, step=1, alignment=Qt.AlignRight, callback=self._invalidate_affinities, addToLayout=False ) self.controls.perplexity.setDisabled(self.multiscale) form.addRow("Perplexity:", self.perplexity_spin) form.addRow(gui.checkBox( box, self, "multiscale", label="Preserve global structure", callback=self._multiscale_changed, addToLayout=False )) sbe = gui.hBox(self.controlArea, False, addToLayout=False) gui.hSlider( sbe, self, "exaggeration", minValue=1, maxValue=4, step=1, callback=self._invalidate_tsne_embedding, ) form.addRow("Exaggeration:", sbe) sbp = gui.hBox(self.controlArea, False, addToLayout=False) gui.hSlider( sbp, self, "pca_components", minValue=2, maxValue=_MAX_PCA_COMPONENTS, step=1, callback=self._invalidate_pca_projection, ) form.addRow("PCA components:", sbp) self.normalize_cbx = gui.checkBox( box, self, "normalize", "Normalize data", callback=self._invalidate_pca_projection, addToLayout=False ) form.addRow(self.normalize_cbx) box.layout().addLayout(form) self.run_button = gui.button(box, self, "Start", callback=self._toggle_run)
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.selected_node = None self.root_node = None self.model = None box = gui.vBox( self.controlArea, '树', addSpace=20, sizePolicy=QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)) self.infolabel = gui.widgetLabel(box, '没有树。') layout = QFormLayout() layout.setVerticalSpacing(20) layout.setFieldGrowthPolicy(layout.ExpandingFieldsGrow) box = self.display_box = \ gui.widgetBox(self.controlArea, "显示", addSpace=True, orientation=layout) layout.addRow( "缩放: ", gui.hSlider(box, self, 'zoom', minValue=1, maxValue=10, step=1, ticks=False, callback=self.toggle_zoom_slider, createLabel=False, addToLayout=False, addSpace=False)) layout.addRow( "宽度: ", gui.hSlider(box, self, 'max_node_width', minValue=50, maxValue=200, step=1, ticks=False, callback=self.toggle_node_size, createLabel=False, addToLayout=False, addSpace=False)) policy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) layout.addRow( "深度: ", gui.comboBox(box, self, 'max_tree_depth', items=["无限制"] + [ "{} 层".format(x) for x in range(2, 10)], addToLayout=False, sendSelectedValue=False, callback=self.toggle_tree_depth, sizePolicy=policy)) layout.addRow( "边缘宽度: ", gui.comboBox(box, self, 'line_width_method', items=['固定', '相对于根', '相对于父级'], addToLayout=False, callback=self.toggle_line_width, sizePolicy=policy)) gui.rubber(self.controlArea) self.resize(800, 500) self.scene = TreeGraphicsScene(self) self.scene_view = TreeGraphicsView(self.scene) self.scene_view.setViewportUpdateMode(QGraphicsView.FullViewportUpdate) self.mainArea.layout().addWidget(self.scene_view) self.toggle_zoom_slider() self.scene.selectionChanged.connect(self.update_selection)
def __init__(self): super().__init__() self.data = None self._pca = None self._transformed = None self._variance_ratio = None self._cumulative = None self._line = False self._init_projector() # Components Selection box = gui.vBox(self.controlArea, "Components Selection") form = QFormLayout() box.layout().addLayout(form) self.components_spin = gui.spin( box, self, "ncomponents", 1, MAX_COMPONENTS, callback=self._update_selection_component_spin, keyboardTracking=False ) self.components_spin.setSpecialValueText("All") self.variance_spin = gui.spin( box, self, "variance_covered", 1, 100, callback=self._update_selection_variance_spin, keyboardTracking=False ) self.variance_spin.setSuffix("%") form.addRow("Components:", self.components_spin) form.addRow("Variance covered:", self.variance_spin) # Incremental learning self.sampling_box = gui.vBox(self.controlArea, "Incremental learning") self.addresstext = QLineEdit(box) self.addresstext.setPlaceholderText('Remote server') if self.address: self.addresstext.setText(self.address) self.sampling_box.layout().addWidget(self.addresstext) form = QFormLayout() self.sampling_box.layout().addLayout(form) self.batch_spin = gui.spin( self.sampling_box, self, "batch_size", 50, 100000, step=50, keyboardTracking=False) form.addRow("Batch size ~ ", self.batch_spin) self.start_button = gui.button( self.sampling_box, self, "Start remote computation", callback=self.start, autoDefault=False, tooltip="Start/abort computation on the server") self.start_button.setEnabled(False) gui.checkBox(self.sampling_box, self, "auto_update", "Periodically fetch model", callback=self.update_model) self.__timer = QTimer(self, interval=2000) self.__timer.timeout.connect(self.get_model) self.sampling_box.setVisible(remotely) # Decomposition self.decomposition_box = gui.radioButtons( self.controlArea, self, "decomposition_idx", [d.name for d in DECOMPOSITIONS], box="Decomposition", callback=self._update_decomposition ) # Options self.options_box = gui.vBox(self.controlArea, "Options") self.normalize_box = gui.checkBox( self.options_box, self, "normalize", "Normalize data", callback=self._update_normalize ) self.maxp_spin = gui.spin( self.options_box, self, "maxp", 1, MAX_COMPONENTS, label="Show only first", callback=self._setup_plot, keyboardTracking=False ) self.controlArea.layout().addStretch() gui.auto_commit(self.controlArea, self, "auto_commit", "Apply", checkbox_label="Apply automatically") self.plot = pg.PlotWidget(background="w") axis = self.plot.getAxis("bottom") axis.setLabel("Principal Components") axis = self.plot.getAxis("left") axis.setLabel("Proportion of variance") self.plot_horlabels = [] self.plot_horlines = [] self.plot.getViewBox().setMenuEnabled(False) self.plot.getViewBox().setMouseEnabled(False, False) self.plot.showGrid(True, True, alpha=0.5) self.plot.setRange(xRange=(0.0, 1.0), yRange=(0.0, 1.0)) self.mainArea.layout().addWidget(self.plot) self._update_normalize()
class VariableEditor(QWidget): """An editor widget for a variable. Can edit the variable name, and its attributes dictionary. """ variable_changed = Signal() def __init__(self, parent=None): QWidget.__init__(self, parent) self.var = None self.setup_gui() def setup_gui(self): layout = QVBoxLayout() self.setLayout(layout) self.main_form = QFormLayout() self.main_form.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow) layout.addLayout(self.main_form) self._setup_gui_name() self._setup_gui_labels() def _setup_gui_name(self): self.name_edit = QLineEdit() self.main_form.addRow("Name:", self.name_edit) self.name_edit.editingFinished.connect(self.on_name_changed) def _setup_gui_labels(self): vlayout = QVBoxLayout() vlayout.setContentsMargins(0, 0, 0, 0) vlayout.setSpacing(1) self.labels_edit = QTreeView() self.labels_edit.setEditTriggers(QTreeView.CurrentChanged) self.labels_edit.setRootIsDecorated(False) self.labels_model = DictItemsModel() self.labels_edit.setModel(self.labels_model) self.labels_edit.selectionModel().selectionChanged.connect( self.on_label_selection_changed) # Necessary signals to know when the labels change self.labels_model.dataChanged.connect(self.on_labels_changed) self.labels_model.rowsInserted.connect(self.on_labels_changed) self.labels_model.rowsRemoved.connect(self.on_labels_changed) vlayout.addWidget(self.labels_edit) hlayout = QHBoxLayout() hlayout.setContentsMargins(0, 0, 0, 0) hlayout.setSpacing(1) self.add_label_action = QAction( "+", self, toolTip="Add a new label.", triggered=self.on_add_label, enabled=False, shortcut=QKeySequence(QKeySequence.New)) self.remove_label_action = QAction( unicodedata.lookup("MINUS SIGN"), self, toolTip="Remove selected label.", triggered=self.on_remove_label, enabled=False, shortcut=QKeySequence(QKeySequence.Delete)) button_size = gui.toolButtonSizeHint() button_size = QSize(button_size, button_size) button = QToolButton(self) button.setFixedSize(button_size) button.setDefaultAction(self.add_label_action) hlayout.addWidget(button) button = QToolButton(self) button.setFixedSize(button_size) button.setDefaultAction(self.remove_label_action) hlayout.addWidget(button) hlayout.addStretch(10) vlayout.addLayout(hlayout) self.main_form.addRow("Labels:", vlayout) def set_data(self, var): """Set the variable to edit. """ self.clear() self.var = var if var is not None: self.name_edit.setText(var.name) self.labels_model.set_dict(dict(var.attributes)) self.add_label_action.setEnabled(True) else: self.add_label_action.setEnabled(False) self.remove_label_action.setEnabled(False) def get_data(self): """Retrieve the modified variable. """ name = str(self.name_edit.text()) labels = self.labels_model.get_dict() # Is the variable actually changed. if self.var is not None and not self.is_same(): var = type(self.var)(name) var.attributes.update(labels) self.var = var else: var = self.var return var def is_same(self): """Is the current model state the same as the input. """ name = str(self.name_edit.text()) labels = self.labels_model.get_dict() return (self.var is not None and name == self.var.name and labels == self.var.attributes) def clear(self): """Clear the editor state. """ self.var = None self.name_edit.setText("") self.labels_model.set_dict({}) def maybe_commit(self): if not self.is_same(): self.commit() def commit(self): """Emit a ``variable_changed()`` signal. """ self.variable_changed.emit() @Slot() def on_name_changed(self): self.maybe_commit() @Slot() def on_labels_changed(self, *args): self.maybe_commit() @Slot() def on_add_label(self): self.labels_model.appendRow([QStandardItem(""), QStandardItem("")]) row = self.labels_model.rowCount() - 1 index = self.labels_model.index(row, 0) self.labels_edit.edit(index) @Slot() def on_remove_label(self): rows = self.labels_edit.selectionModel().selectedRows() if rows: row = rows[0] self.labels_model.removeRow(row.row()) @Slot() def on_label_selection_changed(self): selected = self.labels_edit.selectionModel().selectedRows() self.remove_label_action.setEnabled(bool(len(selected)))
def __init__(self): super().__init__() self.primary_data = None self._more_data_input: List[Optional[Orange.data.Table]] = [] self.mergebox = gui.vBox(self.controlArea, "Variable Merging") box = gui.radioButtons(self.mergebox, self, "merge_type", callback=self._merge_type_changed) gui.widgetLabel( box, self.tr("When there is no primary table, " + "the output should contain:")) for opts in self.domain_opts: gui.appendRadioButton(box, self.tr(opts)) gui.separator(box) label = gui.widgetLabel( box, self.tr("The resulting table will have a class only if there " + "is no conflict between input classes.")) label.setWordWrap(True) gui.separator(box) gui.checkBox( box, self, "ignore_compute_value", "Treat variables with the same name as the same variable,\n" "even if they are computed using different formulae.", callback=self.commit.deferred, stateWhenDisabled=False) ### box = gui.vBox( self.controlArea, self.tr("Source Identification"), ) cb = gui.checkBox(box, self, "append_source_column", self.tr("Append data source IDs"), callback=self._source_changed) ibox = gui.indentedBox(box, sep=gui.checkButtonOffsetHint(cb)) form = QFormLayout(spacing=8, labelAlignment=Qt.AlignLeft, formAlignment=Qt.AlignLeft, fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow) form.addRow( self.tr("Feature name:"), gui.lineEdit(ibox, self, "source_attr_name", valueType=str, callback=self._source_changed)) form.addRow( self.tr("Place:"), gui.comboBox(ibox, self, "source_column_role", items=self.id_roles, callback=self._source_changed)) ibox.layout().addLayout(form) mleft, mtop, mright, _ = ibox.layout().getContentsMargins() ibox.layout().setContentsMargins(mleft, mtop, mright, 4) cb.disables.append(ibox) cb.makeConsistent() gui.auto_apply(self.buttonsArea, self, "auto_commit")
def __init__(self): super().__init__() self.data = None self.subset_data = None self._subset_mask = None self._validmask = None self._X = None self._Y = None self._selection = None self.__replot_requested = False self.variable_x = ContinuousVariable("freeviz-x") self.variable_y = ContinuousVariable("freeviz-y") box0 = gui.vBox(self.mainArea, True, margin=0) self.graph = OWFreeVizGraph(self, box0, "Plot", view_box=FreeVizInteractiveViewBox) box0.layout().addWidget(self.graph.plot_widget) plot = self.graph.plot_widget box = gui.widgetBox(self.controlArea, "Optimization", spacing=10) form = QFormLayout( labelAlignment=Qt.AlignLeft, formAlignment=Qt.AlignLeft, fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow, verticalSpacing=10 ) form.addRow( "Initialization", gui.comboBox(box, self, "initialization", items=["Circular", "Random"], callback=self.reset_initialization) ) box.layout().addLayout(form) self.btn_start = gui.button(widget=box, master=self, label="Optimize", callback=self.toogle_start, enabled=False) self.viewbox = plot.getViewBox() self.replot = None g = self.graph.gui g.point_properties_box(self.controlArea) self.models = g.points_models box = gui.widgetBox(self.controlArea, "Show anchors") self.rslider = gui.hSlider( box, self, "radius", minValue=0, maxValue=100, step=5, label="Radius", createLabel=False, ticks=True, callback=self.update_radius) self.rslider.setTickInterval(0) self.rslider.setPageStep(10) box = gui.vBox(self.controlArea, "Plot Properties") g.add_widgets([g.JitterSizeSlider], box) g.add_widgets([g.ShowLegend, g.ClassDensity, g.LabelOnlySelected], box) self.graph.box_zoom_select(self.controlArea) self.controlArea.layout().addStretch(100) self.icons = gui.attributeIconDict p = self.graph.plot_widget.palette() self.graph.set_palette(p) gui.auto_commit(self.controlArea, self, "auto_commit", "Send Selection", "Send Automatically") self.graph.zoom_actions(self) # FreeViz self._loop = AsyncUpdateLoop(parent=self) self._loop.yielded.connect(self.__set_projection) self._loop.finished.connect(self.__freeviz_finished) self._loop.raised.connect(self.__on_error) self._new_plotdata()
def __init__(self): super().__init__() self.data = None self._pca = None self._transformed = None self._variance_ratio = None self._cumulative = None self._line = False self._init_projector() # Components Selection box = gui.vBox(self.controlArea, "Components Selection") form = QFormLayout() box.layout().addLayout(form) self.components_spin = gui.spin( box, self, "ncomponents", 1, MAX_COMPONENTS, callback=self._update_selection_component_spin, keyboardTracking=False ) self.components_spin.setSpecialValueText("All") self.variance_spin = gui.spin( box, self, "variance_covered", 1, 100, callback=self._update_selection_variance_spin, keyboardTracking=False ) self.variance_spin.setSuffix("%") form.addRow("Components:", self.components_spin) form.addRow("Variance covered:", self.variance_spin) # Options self.options_box = gui.vBox(self.controlArea, "Options") self.normalize_box = gui.checkBox( self.options_box, self, "normalize", "Normalize data", callback=self._update_normalize ) self.maxp_spin = gui.spin( self.options_box, self, "maxp", 1, MAX_COMPONENTS, label="Show only first", callback=self._setup_plot, keyboardTracking=False ) self.controlArea.layout().addStretch() gui.auto_commit(self.controlArea, self, "auto_commit", "Apply", checkbox_label="Apply automatically") self.plot = pg.PlotWidget(background="w") axis = self.plot.getAxis("bottom") axis.setLabel("Principal Components") axis = self.plot.getAxis("left") axis.setLabel("Proportion of variance") self.plot_horlabels = [] self.plot_horlines = [] self.plot.getViewBox().setMenuEnabled(False) self.plot.getViewBox().setMouseEnabled(False, False) self.plot.showGrid(True, True, alpha=0.5) self.plot.setRange(xRange=(0.0, 1.0), yRange=(0.0, 1.0)) self.mainArea.layout().addWidget(self.plot) self._update_normalize()
class DiscreteVariableEditor(VariableEditor): """An editor widget for editing a discrete variable. Extends the :class:`VariableEditor` to enable editing of variables values. """ def setup_gui(self): layout = QVBoxLayout() self.setLayout(layout) self.main_form = QFormLayout() self.main_form.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow) layout.addLayout(self.main_form) self._setup_gui_name() self._setup_gui_values() self._setup_gui_labels() def _setup_gui_values(self): self.values_edit = QListView() self.values_edit.setEditTriggers(QTreeView.CurrentChanged) self.values_model = itemmodels.PyListModel(flags=Qt.ItemIsSelectable | \ Qt.ItemIsEnabled | Qt.ItemIsEditable) self.values_edit.setModel(self.values_model) self.values_model.dataChanged.connect(self.on_values_changed) self.main_form.addRow("Values:", self.values_edit) def set_data(self, var): """Set the variable to edit """ VariableEditor.set_data(self, var) self.values_model[:] = list(var.values) if var is not None else [] def get_data(self): """Retrieve the modified variable """ name = str(self.name_edit.text()) labels = self.labels_model.get_dict() values = map(str, self.values_model) if self.var is not None and not self.is_same(): var = type(self.var)(name, values=values) var.attributes.update(labels) self.var = var else: var = self.var return var def is_same(self): """Is the current model state the same as the input. """ values = list(map(str, self.values_model)) return (VariableEditor.is_same(self) and self.var is not None and self.var.values == values) def clear(self): """Clear the model state. """ VariableEditor.clear(self) self.values_model.wrap([]) @Slot() def on_values_changed(self): self.maybe_commit()
def __init__(self): super().__init__() self._current_path = "" icon_open_dir = self.style().standardIcon(QStyle.SP_DirOpenIcon) # Top grid with file selection combo box grid = QGridLayout() lb = QLabel("File:") lb.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.recent_combo = cb = QComboBox( sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLengthWithIcon, minimumContentsLength=20, toolTip="Select a recent file") self.recent_model = cb.model() # type: QStandardItemModel self.recent_combo.activated[int].connect(self._select_recent) browse = QPushButton("...", autoDefault=False, icon=icon_open_dir, clicked=self.browse) # reload = QPushButton("Reload", autoDefault=False, icon=icon_reload) grid.addWidget(lb, 0, 0, Qt.AlignVCenter) grid.addWidget(cb, 0, 1) grid.addWidget(browse, 0, 2) # grid.addWidget(reload, 0, 3) self.summary_label = label = QLabel("", self) label.ensurePolished() f = label.font() if f.pointSizeF() != -1: f.setPointSizeF(f.pointSizeF() * 5 / 6) else: f.setPixelSize(f.pixelSize() * 5 / 6) label.setFont(f) grid.addWidget(label, 1, 1, 1, 3) self.controlArea.layout().addLayout(grid) box = gui.widgetBox(self.controlArea, "Headers and Row Labels", spacing=-1) hl = QHBoxLayout() hl.setContentsMargins(0, 0, 0, 0) self.header_rows_spin = spin = QSpinBox(box, minimum=0, maximum=3, value=self._header_rows_count, keyboardTracking=False) spin.valueChanged.connect(self.set_header_rows_count) hl.addWidget(QLabel("Data starts with", box)) hl.addWidget(self.header_rows_spin) hl.addWidget(QLabel("header row(s)", box)) hl.addStretch(10) box.layout().addLayout(hl) hl = QHBoxLayout() hl.setContentsMargins(0, 0, 0, 0) self.header_cols_spin = spin = QSpinBox(box, minimum=0, maximum=3, value=self._header_cols_count, keyboardTracking=False) spin.valueChanged.connect(self.set_header_cols_count) hl.addWidget(QLabel("First", box)) hl.addWidget(self.header_cols_spin) hl.addWidget(QLabel("column(s) are row labels", box)) hl.addStretch(10) box.layout().addLayout(hl) self.data_struct_box = box = gui.widgetBox(self.controlArea, "Input Data Structure") gui.radioButtons(box, self, "_cells_in_rows", [ "Genes in rows, samples in columns", "Samples in rows, genes in columns" ], callback=self._invalidate) box = gui.widgetBox(self.controlArea, "Sample Data", spacing=-1) grid = QGridLayout() grid.setContentsMargins(0, 0, 0, 0) box.layout().addLayout(grid) self.sample_rows_cb = cb = QCheckBox(checked=self._sample_rows_enabled) spin = QSpinBox(minimum=0, maximum=100, value=self._sample_rows_p, enabled=self._sample_rows_enabled) spin.valueChanged.connect(self.set_sample_rows_p) suffix = QLabel("% of Samples", enabled=self._sample_rows_enabled) cb.toggled.connect(self.set_sample_rows_enabled) cb.toggled.connect(spin.setEnabled) cb.toggled.connect(suffix.setEnabled) grid.addWidget(cb, 0, 0) grid.addWidget(spin, 0, 1) grid.addWidget(suffix, 0, 2) self.sample_cols_cb = cb = QCheckBox(checked=self._sample_cols_enabled) spin = QSpinBox(minimum=0, maximum=100, value=self._sample_cols_p, enabled=self._sample_cols_enabled) spin.valueChanged.connect(self.set_sample_cols_p) suffix = QLabel("% of genes", enabled=self._sample_cols_enabled) cb.toggled.connect(self.set_sample_cols_enabled) cb.toggled.connect(spin.setEnabled) cb.toggled.connect(suffix.setEnabled) grid.addWidget(cb, 1, 0) grid.addWidget(spin, 1, 1) grid.addWidget(suffix, 1, 2) grid.setColumnStretch(3, 10) self.annotation_files_box = box = gui.widgetBox( self.controlArea, "Cell && Gene Annotation Files") form = QFormLayout( formAlignment=Qt.AlignLeft, rowWrapPolicy=QFormLayout.WrapAllRows, ) box.layout().addLayout(form) self.row_annotations_cb = cb = QCheckBox( "Cell annotations", checked=self._row_annotations_enabled) self._row_annotations_w = w = QWidget( enabled=self._row_annotations_enabled) cb.toggled.connect(self.set_row_annotations_enabled) cb.toggled.connect(w.setEnabled) hl = QHBoxLayout() hl.setContentsMargins(0, 0, 0, 0) w.setLayout(hl) self.row_annotations_combo = QComboBox( sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLengthWithIcon, minimumContentsLength=18) self.row_annotations_combo.activated.connect(self._invalidate) hl.addWidget(self.row_annotations_combo) hl.addWidget( QPushButton("...", box, autoDefault=False, icon=icon_open_dir, clicked=self.browse_row_annotations)) # hl.addWidget(QPushButton("Reload", box, autoDefault=False, # icon=icon_reload)) form.addRow(cb, w) self.col_annotations_cb = cb = QCheckBox( "Gene annotations", checked=self._col_annotations_enabled) self._col_annotations_w = w = QWidget( enabled=self._col_annotations_enabled) cb.toggled.connect(self.set_col_annotations_enabled) cb.toggled.connect(w.setEnabled) hl = QHBoxLayout() hl.setContentsMargins(0, 0, 0, 0) w.setLayout(hl) self.col_annotations_combo = QComboBox( sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLengthWithIcon, minimumContentsLength=18) self.col_annotations_combo.activated.connect(self._invalidate) hl.addWidget(self.col_annotations_combo) hl.addWidget( QPushButton("...", box, autoDefault=False, icon=icon_open_dir, clicked=self.browse_col_annotations)) # hl.addWidget(QPushButton("Reload", box, autoDefault=False, # icon=icon_reload)) form.addRow(cb, w) self.controlArea.layout().addStretch(10) self.load_data_button = button = VariableTextPushButton( "Load data", autoDefault=True, textChoiceList=["Load data", "Reload"]) self.load_data_button.setAutoDefault(True) button.clicked.connect(self.commit, Qt.QueuedConnection) self.controlArea.layout().addWidget(button, alignment=Qt.AlignRight) init_recent_paths_model( self.recent_model, [RecentPath.create(p, []) for p in self._recent], ) init_recent_paths_model( self.row_annotations_combo.model(), [RecentPath.create(p, []) for p in self._recent_row_annotations]) init_recent_paths_model( self.col_annotations_combo.model(), [RecentPath.create(p, []) for p in self._recent_col_annotations]) self._update_summary() self._update_warning() if self._last_path != "" and os.path.exists(self._last_path): self.set_current_path(self._last_path) else: self.recent_combo.setCurrentIndex(-1)
def __init__(self): super().__init__() #: Input dissimilarity matrix self.matrix = None # type: Optional[Orange.misc.DistMatrix] #: Effective data used for plot styling/annotations. Can be from the #: input signal (`self.signal_data`) or the input matrix #: (`self.matrix.data`) self.data = None # type: Optional[Orange.data.Table] #: Input subset data table self.subset_data = None # type: Optional[Orange.data.Table] #: Data table from the `self.matrix.row_items` (if present) self.matrix_data = None # type: Optional[Orange.data.Table] #: Input data table self.signal_data = None self._similar_pairs = None self._subset_mask = None # type: Optional[np.ndarray] self._invalidated = False self.effective_matrix = None self._curve = None self.variable_x = ContinuousVariable("mds-x") self.variable_y = ContinuousVariable("mds-y") self.__update_loop = None # timer for scheduling updates self.__timer = QTimer(self, singleShot=True, interval=0) self.__timer.timeout.connect(self.__next_step) self.__state = OWMDS.Waiting self.__in_next_step = False self.__draw_similar_pairs = False box = gui.vBox(self.controlArea, "MDS Optimization") form = QFormLayout( labelAlignment=Qt.AlignLeft, formAlignment=Qt.AlignLeft, fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow, verticalSpacing=10 ) form.addRow( "Max iterations:", gui.spin(box, self, "max_iter", 10, 10 ** 4, step=1)) form.addRow( "Initialization:", gui.radioButtons(box, self, "initialization", btnLabels=("PCA (Torgerson)", "Random"), callback=self.__invalidate_embedding)) box.layout().addLayout(form) form.addRow( "Refresh:", gui.comboBox(box, self, "refresh_rate", items=[t for t, _ in OWMDS.RefreshRate], callback=self.__invalidate_refresh)) gui.separator(box, 10) self.runbutton = gui.button(box, self, "Run", callback=self._toggle_run) box = gui.vBox(self.mainArea, True, margin=0) self.graph = OWMDSGraph(self, box, "MDSGraph", view_box=MDSInteractiveViewBox) box.layout().addWidget(self.graph.plot_widget) self.plot = self.graph.plot_widget g = self.graph.gui box = g.point_properties_box(self.controlArea) self.models = g.points_models self.size_model = self.models[2] self.label_model = self.models[3] self.size_model.order = \ self.size_model.order[:1] + ("Stress", ) + self.models[2].order[1:] gui.hSlider(box, self, "connected_pairs", label="Show similar pairs:", minValue=0, maxValue=20, createLabel=False, callback=self._on_connected_changed) g.add_widgets(ids=[g.JitterSizeSlider], widget=box) box = gui.vBox(self.controlArea, "Plot Properties") g.add_widgets([g.ShowLegend, g.ToolTipShowsAll, g.ClassDensity, g.LabelOnlySelected], box) self.controlArea.layout().addStretch(100) self.icons = gui.attributeIconDict palette = self.graph.plot_widget.palette() self.graph.set_palette(palette) gui.rubber(self.controlArea) self.graph.box_zoom_select(self.controlArea) gui.auto_commit(box, self, "auto_commit", "Send Selected", checkbox_label="Send selected automatically", box=None) self.plot.getPlotItem().hideButtons() self.plot.setRenderHint(QPainter.Antialiasing) self.graph.jitter_continuous = True self._initialize()
def add_main_layout(self): form = QFormLayout() form.setFieldGrowthPolicy(form.AllNonFixedFieldsGrow) form.setVerticalSpacing(25) gui.widgetBox(self.controlArea, True, orientation=form) form.addRow( "Neurons in hidden layers:", gui.lineEdit( None, self, "hidden_layers_input", orientation=Qt.Horizontal, callback=self.settings_changed, tooltip="A list of integers defining neurons. Length of list " "defines the number of layers. E.g. 4, 2, 2, 3.", placeholderText="e.g. 100,")) form.addRow( "Activation:", gui.comboBox(None, self, "activation_index", orientation=Qt.Horizontal, label="Activation:", items=[i for i in self.act_lbl], callback=self.settings_changed)) form.addRow(" ", gui.separator(None, 16)) form.addRow( "Solver:", gui.comboBox(None, self, "solver_index", orientation=Qt.Horizontal, label="Solver:", items=[i for i in self.solv_lbl], callback=self.settings_changed)) self.reg_label = QLabel() slider = gui.hSlider(None, self, "alpha_index", minValue=0, maxValue=len(self.alphas) - 1, callback=lambda: (self.set_alpha(), self.settings_changed()), createLabel=False) form.addRow(self.reg_label, slider) self.set_alpha() form.addRow( "Maximal number of iterations:", gui.spin(None, self, "max_iterations", 10, 10000, step=10, label="Max iterations:", orientation=Qt.Horizontal, alignment=Qt.AlignRight, callback=self.settings_changed))
class VariableEditor(QWidget): """An editor widget for a variable. Can edit the variable name, and its attributes dictionary. """ variable_changed = Signal() def __init__(self, parent=None): QWidget.__init__(self, parent) self.var = None self.setup_gui() def setup_gui(self): layout = QVBoxLayout() self.setLayout(layout) self.main_form = QFormLayout() self.main_form.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow) layout.addLayout(self.main_form) self._setup_gui_name() self._setup_gui_labels() def _setup_gui_name(self): class OrangeLineEdit(QLineEdit): def keyPressEvent(self, event): if event.key() in [Qt.Key_Return, Qt.Key_Enter]: self.parent().on_name_changed() else: super().keyPressEvent(event) self.name_edit = OrangeLineEdit() self.main_form.addRow("Name:", self.name_edit) self.name_edit.editingFinished.connect(self.on_name_changed) def _setup_gui_labels(self): vlayout = QVBoxLayout() vlayout.setContentsMargins(0, 0, 0, 0) vlayout.setSpacing(1) self.labels_edit = QTreeView() self.labels_edit.setEditTriggers(QTreeView.CurrentChanged) self.labels_edit.setRootIsDecorated(False) self.labels_model = DictItemsModel() self.labels_edit.setModel(self.labels_model) self.labels_edit.selectionModel().selectionChanged.connect( self.on_label_selection_changed) # Necessary signals to know when the labels change self.labels_model.dataChanged.connect(self.on_labels_changed) self.labels_model.rowsInserted.connect(self.on_labels_changed) self.labels_model.rowsRemoved.connect(self.on_labels_changed) vlayout.addWidget(self.labels_edit) hlayout = QHBoxLayout() hlayout.setContentsMargins(0, 0, 0, 0) hlayout.setSpacing(1) self.add_label_action = QAction( "+", self, toolTip="Add a new label.", triggered=self.on_add_label, enabled=False, shortcut=QKeySequence(QKeySequence.New), ) self.remove_label_action = QAction( unicodedata.lookup("MINUS SIGN"), self, toolTip="Remove selected label.", triggered=self.on_remove_label, enabled=False, shortcut=QKeySequence(QKeySequence.Delete), ) button_size = gui.toolButtonSizeHint() button_size = QSize(button_size, button_size) button = QToolButton(self) button.setFixedSize(button_size) button.setDefaultAction(self.add_label_action) hlayout.addWidget(button) button = QToolButton(self) button.setFixedSize(button_size) button.setDefaultAction(self.remove_label_action) hlayout.addWidget(button) hlayout.addStretch(10) vlayout.addLayout(hlayout) self.main_form.addRow("Labels:", vlayout) def set_data(self, var): """Set the variable to edit. """ self.clear() self.var = var if var is not None: self.name_edit.setText(var.name) self.labels_model.set_dict(dict(var.attributes)) self.add_label_action.setEnabled(True) else: self.add_label_action.setEnabled(False) self.remove_label_action.setEnabled(False) def get_data(self): """Retrieve the modified variable. """ name = str(self.name_edit.text()).strip() labels = self.labels_model.get_dict() # Is the variable actually changed. if self.var is not None and not self.is_same(): var = type(self.var)(name) var.attributes.update(labels) self.var = var else: var = self.var return var def is_legal(self): name = str(self.name_edit.text()).strip() return not len(name) == 0 def is_same(self): """Is the current model state the same as the input. """ name = str(self.name_edit.text()).strip() labels = self.labels_model.get_dict() return (self.var is not None and name == self.var.name and labels == self.var.attributes) def clear(self): """Clear the editor state. """ self.var = None self.name_edit.setText("") self.labels_model.set_dict({}) def maybe_commit(self): if not self.is_same() and self.is_legal(): self.commit() def commit(self): """Emit a ``variable_changed()`` signal. """ self.variable_changed.emit() @Slot() def on_name_changed(self): self.maybe_commit() @Slot() def on_labels_changed(self, *args): self.maybe_commit() @Slot() def on_add_label(self): self.labels_model.appendRow([QStandardItem(""), QStandardItem("")]) row = self.labels_model.rowCount() - 1 index = self.labels_model.index(row, 0) self.labels_edit.edit(index) @Slot() def on_remove_label(self): rows = self.labels_edit.selectionModel().selectedRows() if rows: row = rows[0] self.labels_model.removeRow(row.row()) @Slot() def on_label_selection_changed(self): selected = self.labels_edit.selectionModel().selectedRows() self.remove_label_action.setEnabled(bool(len(selected)))
def __init__(self): super().__init__() self.data = None self._pca = None self._transformed = None self._variance_ratio = None self._cumulative = None self._line = False self._init_projector() # Components Selection box = gui.vBox(self.controlArea, "Components Selection") form = QFormLayout() box.layout().addLayout(form) self.components_spin = gui.spin( box, self, "ncomponents", 1, MAX_COMPONENTS, callback=self._update_selection_component_spin, keyboardTracking=False) self.components_spin.setSpecialValueText("All") self.variance_spin = gui.spin( box, self, "variance_covered", 1, 100, callback=self._update_selection_variance_spin, keyboardTracking=False) self.variance_spin.setSuffix("%") form.addRow("Components:", self.components_spin) form.addRow("Variance covered:", self.variance_spin) # Incremental learning self.sampling_box = gui.vBox(self.controlArea, "Incremental learning") self.addresstext = QLineEdit(box) self.addresstext.setPlaceholderText('Remote server') if self.address: self.addresstext.setText(self.address) self.sampling_box.layout().addWidget(self.addresstext) form = QFormLayout() self.sampling_box.layout().addLayout(form) self.batch_spin = gui.spin(self.sampling_box, self, "batch_size", 50, 100000, step=50, keyboardTracking=False) form.addRow("Batch size ~ ", self.batch_spin) self.start_button = gui.button( self.sampling_box, self, "Start remote computation", callback=self.start, autoDefault=False, tooltip="Start/abort computation on the server") self.start_button.setEnabled(False) gui.checkBox(self.sampling_box, self, "auto_update", "Periodically fetch model", callback=self.update_model) self.__timer = QTimer(self, interval=2000) self.__timer.timeout.connect(self.get_model) self.sampling_box.setVisible(remotely) # Decomposition self.decomposition_box = gui.radioButtons( self.controlArea, self, "decomposition_idx", [d.name for d in DECOMPOSITIONS], box="Decomposition", callback=self._update_decomposition) # Options self.options_box = gui.vBox(self.controlArea, "Options") self.normalize_box = gui.checkBox(self.options_box, self, "normalize", "Normalize data", callback=self._update_normalize) self.maxp_spin = gui.spin(self.options_box, self, "maxp", 1, MAX_COMPONENTS, label="Show only first", callback=self._setup_plot, keyboardTracking=False) self.controlArea.layout().addStretch() gui.auto_commit(self.controlArea, self, "auto_commit", "Apply", checkbox_label="Apply automatically") self.plot = pg.PlotWidget(background="w") axis = self.plot.getAxis("bottom") axis.setLabel("Principal Components") axis = self.plot.getAxis("left") axis.setLabel("Proportion of variance") self.plot_horlabels = [] self.plot_horlines = [] self.plot.getViewBox().setMenuEnabled(False) self.plot.getViewBox().setMouseEnabled(False, False) self.plot.showGrid(True, True, alpha=0.5) self.plot.setRange(xRange=(0.0, 1.0), yRange=(0.0, 1.0)) self.mainArea.layout().addWidget(self.plot) self._update_normalize()
class DiscreteVariableEditor(VariableEditor): """An editor widget for editing a discrete variable. Extends the :class:`VariableEditor` to enable editing of variables values. """ def setup_gui(self): layout = QVBoxLayout() self.setLayout(layout) self.main_form = QFormLayout() self.main_form.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow) layout.addLayout(self.main_form) self._setup_gui_name() self._setup_gui_values() self._setup_gui_labels() def _setup_gui_values(self): self.values_edit = QListView() self.values_edit.setEditTriggers(QTreeView.CurrentChanged) self.values_model = itemmodels.PyListModel( flags=Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable) self.values_edit.setModel(self.values_model) self.values_model.dataChanged.connect(self.on_values_changed) self.main_form.addRow("Values:", self.values_edit) def set_data(self, var): """Set the variable to edit """ VariableEditor.set_data(self, var) self.values_model[:] = list(var.values) if var is not None else [] def get_data(self): """Retrieve the modified variable """ name = str(self.name_edit.text()).strip() labels = self.labels_model.get_dict() values = map(str, self.values_model) if self.var is not None and not self.is_same(): var = type(self.var)(name, values=values) var.attributes.update(labels) self.var = var else: var = self.var return var def is_same(self): """Is the current model state the same as the input. """ values = list(map(str, self.values_model)) return (VariableEditor.is_same(self) and self.var is not None and self.var.values == values) def clear(self): """Clear the model state. """ VariableEditor.clear(self) self.values_model.clear() @Slot() def on_values_changed(self): self.maybe_commit()
def __setupUi(self): """Set up the UI. """ if self.__macUnified: self.tab = QToolBar() self.addToolBar(Qt.TopToolBarArea, self.tab) self.setUnifiedTitleAndToolBarOnMac(True) # This does not seem to work self.setWindowFlags(self.windowFlags() & \ ~Qt.MacWindowToolBarButtonHint) self.tab.actionTriggered[QAction].connect( self.__macOnToolBarAction ) central = QStackedWidget() central.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) else: self.tab = central = QTabWidget(self) self.stack = central self.setCentralWidget(central) # General Tab tab = QWidget() self.addTab(tab, self.tr("General"), toolTip=self.tr("General Options")) form = QFormLayout() tab.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) nodes = QWidget(self, objectName="nodes") nodes.setLayout(QVBoxLayout()) nodes.layout().setContentsMargins(0, 0, 0, 0) cb_anim = QCheckBox( self.tr("Enable node animations"), objectName="enable-node-animations", toolTip=self.tr("Enable shadow and ping animations for nodes " "in the workflow.") ) self.bind(cb_anim, "checked", "schemeedit/enable-node-animations") nodes.layout().addWidget(cb_anim) form.addRow(self.tr("Nodes"), nodes) links = QWidget(self, objectName="links") links.setLayout(QVBoxLayout()) links.layout().setContentsMargins(0, 0, 0, 0) cb_show = QCheckBox( self.tr("Show channel names between widgets"), objectName="show-channel-names", toolTip=self.tr("Show source and sink channel names " "over the links.") ) self.bind(cb_show, "checked", "schemeedit/show-channel-names") links.layout().addWidget(cb_show) form.addRow(self.tr("Links"), links) quickmenu = QWidget(self, objectName="quickmenu-options") quickmenu.setLayout(QVBoxLayout()) quickmenu.layout().setContentsMargins(0, 0, 0, 0) cb1 = QCheckBox(self.tr("On double click"), toolTip=self.tr("Open quick menu on a double click " "on an empty spot in the canvas")) cb2 = QCheckBox(self.tr("On right click"), toolTip=self.tr("Open quick menu on a right click " "on an empty spot in the canvas")) cb3 = QCheckBox(self.tr("On space key press"), toolTip=self.tr("On Space key press while the mouse" "is hovering over the canvas.")) cb4 = QCheckBox(self.tr("On any key press"), toolTip=self.tr("On any key press while the mouse" "is hovering over the canvas.")) self.bind(cb1, "checked", "quickmenu/trigger-on-double-click") self.bind(cb2, "checked", "quickmenu/trigger-on-right-click") self.bind(cb3, "checked", "quickmenu/trigger-on-space-key") self.bind(cb4, "checked", "quickmenu/trigger-on-any-key") quickmenu.layout().addWidget(cb1) quickmenu.layout().addWidget(cb2) quickmenu.layout().addWidget(cb3) quickmenu.layout().addWidget(cb4) form.addRow(self.tr("Open quick menu on"), quickmenu) startup = QWidget(self, objectName="startup-group") startup.setLayout(QVBoxLayout()) startup.layout().setContentsMargins(0, 0, 0, 0) cb_splash = QCheckBox(self.tr("Show splash screen"), self, objectName="show-splash-screen") cb_welcome = QCheckBox(self.tr("Show welcome screen"), self, objectName="show-welcome-screen") cb_updates = QCheckBox(self.tr("Check for updates"), self, objectName="check-updates") self.bind(cb_splash, "checked", "startup/show-splash-screen") self.bind(cb_welcome, "checked", "startup/show-welcome-screen") self.bind(cb_updates, "checked", "startup/check-updates") startup.layout().addWidget(cb_splash) startup.layout().addWidget(cb_welcome) startup.layout().addWidget(cb_updates) form.addRow(self.tr("On startup"), startup) toolbox = QWidget(self, objectName="toolbox-group") toolbox.setLayout(QVBoxLayout()) toolbox.layout().setContentsMargins(0, 0, 0, 0) exclusive = QCheckBox(self.tr("Only one tab can be open at a time")) self.bind(exclusive, "checked", "mainwindow/toolbox-dock-exclusive") toolbox.layout().addWidget(exclusive) form.addRow(self.tr("Tool box"), toolbox) tab.setLayout(form) # Output Tab tab = QWidget() self.addTab(tab, self.tr("Output"), toolTip="Output Redirection") form = QFormLayout() box = QWidget() layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) combo = QComboBox() combo.addItems([self.tr("Critical"), self.tr("Error"), self.tr("Warn"), self.tr("Info"), self.tr("Debug")]) self.bind(combo, "currentIndex", "logging/level") layout.addWidget(combo) box.setLayout(layout) form.addRow(self.tr("Logging"), box) box = QWidget() layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) cb1 = QCheckBox(self.tr("Open in external browser"), objectName="open-in-external-browser") self.bind(cb1, "checked", "help/open-in-external-browser") layout.addWidget(cb1) box.setLayout(layout) form.addRow(self.tr("Help window"), box) tab.setLayout(form) # Error Reporting Tab tab = QWidget() self.addTab(tab, self.tr("Error Reporting"), toolTip="Settings related to error reporting") form = QFormLayout() line_edit_mid = QLineEdit() self.bind(line_edit_mid, "text", "error-reporting/machine-id") form.addRow("Machine ID:", line_edit_mid) tab.setLayout(form) # Add-ons Tab tab = QWidget() self.addTab(tab, self.tr("Add-ons"), toolTip="Settings related to add-on installation") form = QFormLayout() conda = QWidget(self, objectName="conda-group") conda.setLayout(QVBoxLayout()) conda.layout().setContentsMargins(0, 0, 0, 0) cb_conda_install = QCheckBox(self.tr("Install add-ons with conda"), self, objectName="allow-conda-experimental") self.bind(cb_conda_install, "checked", "add-ons/allow-conda-experimental") conda.layout().addWidget(cb_conda_install) form.addRow(self.tr("Conda"), conda) tab.setLayout(form) if self.__macUnified: # Need some sensible size otherwise mac unified toolbar 'takes' # the space that should be used for layout of the contents self.adjustSize()
def __init__(self): super().__init__() self.data = None self.indices = None self.sampled_instances = self.remaining_instances = None box = gui.vBox(self.controlArea, "Information") self.dataInfoLabel = gui.widgetLabel(box, 'No data on input.') self.outputInfoLabel = gui.widgetLabel(box, ' ') self.sampling_box = gui.vBox(self.controlArea, "Sampling Type") sampling = gui.radioButtons(self.sampling_box, self, "sampling_type", callback=self.sampling_type_changed) def set_sampling_type(i): def f(): self.sampling_type = i self.sampling_type_changed() return f gui.appendRadioButton(sampling, "Fixed proportion of data:") self.sampleSizePercentageSlider = gui.hSlider( gui.indentedBox(sampling), self, "sampleSizePercentage", minValue=0, maxValue=99, ticks=10, labelFormat="%d %%", callback=set_sampling_type(self.FixedProportion), addSpace=12) gui.appendRadioButton(sampling, "Fixed sample size") ibox = gui.indentedBox(sampling) self.sampleSizeSpin = gui.spin( ibox, self, "sampleSizeNumber", label="Instances: ", minv=1, maxv=2 ** 31 - 1, callback=set_sampling_type(self.FixedSize)) gui.checkBox( ibox, self, "replacement", "Sample with replacement", callback=set_sampling_type(self.FixedSize), addSpace=12) gui.appendRadioButton(sampling, "Cross validation") form = QFormLayout( formAlignment=Qt.AlignLeft | Qt.AlignTop, labelAlignment=Qt.AlignLeft, fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow) ibox = gui.indentedBox(sampling, addSpace=True, orientation=form) form.addRow("Number of folds:", gui.spin( ibox, self, "number_of_folds", 2, 100, addToLayout=False, callback=self.number_of_folds_changed)) self.selected_fold_spin = gui.spin( ibox, self, "selectedFold", 1, self.number_of_folds, addToLayout=False, callback=self.fold_changed) form.addRow("Selected fold:", self.selected_fold_spin) gui.appendRadioButton(sampling, "Boostrap") self.sql_box = gui.vBox(self.controlArea, "Sampling Type") sampling = gui.radioButtons(self.sql_box, self, "sampling_type", callback=self.sampling_type_changed) gui.appendRadioButton(sampling, "Time:") ibox = gui.indentedBox(sampling) spin = gui.spin(ibox, self, "sampleSizeSqlTime", minv=1, maxv=3600, callback=set_sampling_type(self.SqlTime)) spin.setSuffix(" sec") gui.appendRadioButton(sampling, "Percentage") ibox = gui.indentedBox(sampling) spin = gui.spin(ibox, self, "sampleSizeSqlPercentage", spinType=float, minv=0.0001, maxv=100, step=0.1, decimals=4, callback=set_sampling_type(self.SqlProportion)) spin.setSuffix(" %") self.sql_box.setVisible(False) self.options_box = gui.vBox(self.controlArea, "Options") self.cb_seed = gui.checkBox( self.options_box, self, "use_seed", "Replicable (deterministic) sampling", callback=self.settings_changed) self.cb_stratify = gui.checkBox( self.options_box, self, "stratify", "Stratify sample (when possible)", callback=self.settings_changed) self.cb_sql_dl = gui.checkBox( self.options_box, self, "sql_dl", "Download data to local memory", callback=self.settings_changed) self.cb_sql_dl.setVisible(False) gui.button(self.buttonsArea, self, "Sample Data", callback=self.commit)
def __init__(self): super().__init__() self.data = None self.filename = "" self.basename = "" self.type_ext = "" self.compress_ext = "" form = QFormLayout( labelAlignment=Qt.AlignLeft, formAlignment=Qt.AlignLeft, rowWrapPolicy=QFormLayout.WrapLongRows, verticalSpacing=10, ) box = gui.vBox(self.controlArea, "格式") gui.comboBox( box, self, "filetype", callback=self._update_text, items=[item for item, _, _ in FILE_TYPES], sendSelectedValue=True, ) form.addRow( "文件类型", self.controls.filetype, ) gui.comboBox( box, self, "compression", callback=self._update_text, items=[item for item, _ in COMPRESSIONS], sendSelectedValue=True, ) gui.checkBox( box, self, "compress", label="使用压缩", callback=self._update_text, ) form.addRow(self.controls.compress, self.controls.compression) box.layout().addLayout(form) self.save = gui.auto_commit(self.controlArea, self, "auto_save", "保存", box=False, commit=self.save_file, callback=self.adjust_label, disabled=True, addSpace=True) self.save_as = gui.button(self.controlArea, self, "另存为...", callback=self.save_file_as, disabled=True) self.save_as.setMinimumWidth(220) self.adjustSize()
def __init__(self, parent, select_fn=None): QWidget.__init__(self) OWComponent.__init__(self, parent) self.parent = parent self.select_fn = select_fn self.selection_type = SELECTMANY self.saving_enabled = hasattr(self.parent, "save_graph") self.selection_enabled = True self.viewtype = INDIVIDUAL # required bt InteractiveViewBox self.highlighted = None self.data_points = None self.data_values = None self.data_imagepixels = None self.selection = None self.plotview = pg.PlotWidget(background="w", viewBox=InteractiveViewBox(self)) self.plot = self.plotview.getPlotItem() self.plot.scene().installEventFilter( HelpEventDelegate(self.help_event, self)) layout = QVBoxLayout() self.setLayout(layout) self.layout().setContentsMargins(0, 0, 0, 0) self.layout().addWidget(self.plotview) self.img = ImageItemNan() self.img.setOpts(axisOrder='row-major') self.plot.addItem(self.img) self.plot.vb.setAspectLocked() self.plot.scene().sigMouseMoved.connect(self.plot.vb.mouseMovedEvent) layout = QGridLayout() self.plotview.setLayout(layout) self.button = QPushButton("View", self.plotview) self.button.setAutoDefault(False) layout.setRowStretch(1, 1) layout.setColumnStretch(1, 1) layout.addWidget(self.button, 0, 0) view_menu = MenuFocus(self) self.button.setMenu(view_menu) actions = [] zoom_in = QAction( "Zoom in", self, triggered=self.plot.vb.set_mode_zooming ) zoom_in.setShortcuts([Qt.Key_Z, QKeySequence(QKeySequence.ZoomIn)]) zoom_in.setShortcutContext(Qt.WidgetWithChildrenShortcut) actions.append(zoom_in) zoom_fit = QAction( "Zoom to fit", self, triggered=lambda x: (self.plot.vb.autoRange(), self.plot.vb.set_mode_panning()) ) zoom_fit.setShortcuts([Qt.Key_Backspace, QKeySequence(Qt.ControlModifier | Qt.Key_0)]) zoom_fit.setShortcutContext(Qt.WidgetWithChildrenShortcut) actions.append(zoom_fit) select_square = QAction( "Select (square)", self, triggered=self.plot.vb.set_mode_select_square, ) select_square.setShortcuts([Qt.Key_S]) select_square.setShortcutContext(Qt.WidgetWithChildrenShortcut) actions.append(select_square) select_polygon = QAction( "Select (polygon)", self, triggered=self.plot.vb.set_mode_select_polygon, ) select_polygon.setShortcuts([Qt.Key_P]) select_polygon.setShortcutContext(Qt.WidgetWithChildrenShortcut) actions.append(select_polygon) if self.saving_enabled: save_graph = QAction( "Save graph", self, triggered=self.save_graph, ) save_graph.setShortcuts([QKeySequence(Qt.ControlModifier | Qt.Key_I)]) actions.append(save_graph) view_menu.addActions(actions) self.addActions(actions) common_options = dict( labelWidth=50, orientation=Qt.Horizontal, sendSelectedValue=True, valueType=str) choose_xy = QWidgetAction(self) box = gui.vBox(self) box.setFocusPolicy(Qt.TabFocus) self.xy_model = DomainModel(DomainModel.METAS | DomainModel.CLASSES, valid_types=DomainModel.PRIMITIVE) self.cb_attr_x = gui.comboBox( box, self, "attr_x", label="Axis x:", callback=self.update_attr, model=self.xy_model, **common_options) self.cb_attr_y = gui.comboBox( box, self, "attr_y", label="Axis y:", callback=self.update_attr, model=self.xy_model, **common_options) box.setFocusProxy(self.cb_attr_x) self.color_cb = gui.comboBox(box, self, "palette_index", label="Color:", labelWidth=50, orientation=Qt.Horizontal) self.color_cb.setIconSize(QSize(64, 16)) palettes = _color_palettes self.palette_index = min(self.palette_index, len(palettes) - 1) model = color_palette_model(palettes, self.color_cb.iconSize()) model.setParent(self) self.color_cb.setModel(model) self.color_cb.activated.connect(self.update_color_schema) self.color_cb.setCurrentIndex(self.palette_index) form = QFormLayout( formAlignment=Qt.AlignLeft, labelAlignment=Qt.AlignLeft, fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow ) lowslider = gui.hSlider( box, self, "threshold_low", minValue=0.0, maxValue=1.0, step=0.05, ticks=True, intOnly=False, createLabel=False, callback=self.update_color_schema) highslider = gui.hSlider( box, self, "threshold_high", minValue=0.0, maxValue=1.0, step=0.05, ticks=True, intOnly=False, createLabel=False, callback=self.update_color_schema) form.addRow("Low:", lowslider) form.addRow("High:", highslider) box.layout().addLayout(form) choose_xy.setDefaultWidget(box) view_menu.addAction(choose_xy) self.markings_integral = [] self.lsx = None # info about the X axis self.lsy = None # info about the Y axis self.data = None self.data_ids = {}
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) w = self.widget(0) # 'General' tab layout = w.layout() assert isinstance(layout, QFormLayout) cb = QCheckBox(self.tr("Automatically check for updates")) cb.setAttribute(Qt.WA_LayoutUsesWidgetRect) layout.addRow("Updates", cb) self.bind(cb, "checked", "startup/check-updates") # Reporting Tab tab = QWidget() self.addTab(tab, self.tr("Reporting"), toolTip="Settings related to reporting") form = QFormLayout() line_edit_mid = QLineEdit() self.bind(line_edit_mid, "text", "reporting/machine-id") form.addRow("Machine ID:", line_edit_mid) box = QWidget() layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) cb1 = QCheckBox( self.tr("Share"), toolTip=self.tr( "Share anonymous usage statistics to improve Orange")) self.bind(cb1, "checked", "reporting/send-statistics") cb1.clicked.connect(UsageStatistics.set_enabled) layout.addWidget(cb1) box.setLayout(layout) form.addRow(self.tr("Anonymous Statistics"), box) label = QLabel( "<a " "href=\"https://orange.biolab.si/statistics-more-info\">" "More info..." "</a>") label.setOpenExternalLinks(True) form.addRow(self.tr(""), label) tab.setLayout(form) # Notifications Tab tab = QWidget() self.addTab(tab, self.tr("Notifications"), toolTip="Settings related to notifications") form = QFormLayout() box = QWidget() layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) cb = QCheckBox(self.tr("Enable notifications"), self, toolTip="Pull and display a notification feed.") self.bind(cb, "checked", "notifications/check-notifications") layout.addWidget(cb) box.setLayout(layout) form.addRow(self.tr("On startup"), box) notifs = QWidget(self, objectName="notifications-group") notifs.setLayout(QVBoxLayout()) notifs.layout().setContentsMargins(0, 0, 0, 0) cb1 = QCheckBox( self.tr("Announcements"), self, toolTip="Show notifications about Biolab announcements.\n" "This entails events and courses hosted by the developers of " "Orange.") cb2 = QCheckBox(self.tr("Blog posts"), self, toolTip="Show notifications about blog posts.\n" "We'll only send you the highlights.") cb3 = QCheckBox( self.tr("New features"), self, toolTip="Show notifications about new features in Orange when a new " "version is downloaded and installed,\n" "should the new version entail notable updates.") self.bind(cb1, "checked", "notifications/announcements") self.bind(cb2, "checked", "notifications/blog") self.bind(cb3, "checked", "notifications/new-features") notifs.layout().addWidget(cb1) notifs.layout().addWidget(cb2) notifs.layout().addWidget(cb3) form.addRow(self.tr("Show notifications about"), notifs) tab.setLayout(form)
def __init__(self): super().__init__() self.primary_data = None self.more_data = OrderedDict() mergebox = gui.vBox(self.controlArea, "Domain Merging") box = gui.radioButtons( mergebox, self, "merge_type", callback=self._merge_type_changed) gui.widgetLabel( box, self.tr("When there is no primary table, " + "the domain should be:")) for opts in self.domain_opts: gui.appendRadioButton(box, self.tr(opts)) gui.separator(box) label = gui.widgetLabel( box, self.tr("The resulting table will have a class only if there " + "is no conflict between input classes.")) label.setWordWrap(True) ### box = gui.vBox( self.controlArea, self.tr("Source Identification"), addSpace=False) cb = gui.checkBox( box, self, "append_source_column", self.tr("Append data source IDs")) ibox = gui.indentedBox(box, sep=gui.checkButtonOffsetHint(cb)) form = QFormLayout( spacing=8, labelAlignment=Qt.AlignLeft, formAlignment=Qt.AlignLeft, fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow ) form.addRow( self.tr("Feature name:"), gui.lineEdit(ibox, self, "source_attr_name", valueType=str)) form.addRow( self.tr("Place:"), gui.comboBox(ibox, self, "source_column_role", items=self.id_roles) ) ibox.layout().addLayout(form) mleft, mtop, mright, _ = ibox.layout().getContentsMargins() ibox.layout().setContentsMargins(mleft, mtop, mright, 4) cb.disables.append(ibox) cb.makeConsistent() box = gui.auto_commit( self.controlArea, self, "auto_commit", "Apply", commit=self.apply) box.layout().insertWidget(0, self.report_button) box.layout().insertSpacing(1, 20)
def __init__(self): super().__init__() self.primary_data = None self.more_data = OrderedDict() self.mergebox = gui.vBox(self.controlArea, "Domain Merging") box = gui.radioButtons(self.mergebox, self, "merge_type", callback=self._merge_type_changed) gui.widgetLabel( box, self.tr("When there is no primary table, " + "the domain should be:")) for opts in self.domain_opts: gui.appendRadioButton(box, self.tr(opts)) gui.separator(box) label = gui.widgetLabel( box, self.tr("The resulting table will have a class only if there " + "is no conflict between input classes.")) label.setWordWrap(True) ### box = gui.vBox(self.controlArea, self.tr("Source Identification"), addSpace=False) cb = gui.checkBox(box, self, "append_source_column", self.tr("Append data source IDs"), callback=self._source_changed) ibox = gui.indentedBox(box, sep=gui.checkButtonOffsetHint(cb)) form = QFormLayout(spacing=8, labelAlignment=Qt.AlignLeft, formAlignment=Qt.AlignLeft, fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow) form.addRow( self.tr("Feature name:"), gui.lineEdit(ibox, self, "source_attr_name", valueType=str, callback=self._source_changed)) form.addRow( self.tr("Place:"), gui.comboBox(ibox, self, "source_column_role", items=self.id_roles, callback=self._source_changed)) ibox.layout().addLayout(form) mleft, mtop, mright, _ = ibox.layout().getContentsMargins() ibox.layout().setContentsMargins(mleft, mtop, mright, 4) cb.disables.append(ibox) cb.makeConsistent() box = gui.auto_commit(self.controlArea, self, "auto_commit", "Apply", commit=self.apply) box.layout().insertWidget(0, self.report_button) box.layout().insertSpacing(1, 20)
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__() #: Input dissimilarity matrix self.matrix = None # type: Optional[Orange.misc.DistMatrix] #: Effective data used for plot styling/annotations. Can be from the #: input signal (`self.signal_data`) or the input matrix #: (`self.matrix.data`) self.data = None # type: Optional[Orange.data.Table] #: Input subset data table self.subset_data = None # type: Optional[Orange.data.Table] #: Data table from the `self.matrix.row_items` (if present) self.matrix_data = None # type: Optional[Orange.data.Table] #: Input data table self.signal_data = None self._similar_pairs = None self._subset_mask = None # type: Optional[np.ndarray] self._invalidated = False self.effective_matrix = None self._curve = None self.variable_x = ContinuousVariable("mds-x") self.variable_y = ContinuousVariable("mds-y") self.__update_loop = None # timer for scheduling updates self.__timer = QTimer(self, singleShot=True, interval=0) self.__timer.timeout.connect(self.__next_step) self.__state = OWMDS.Waiting self.__in_next_step = False self.__draw_similar_pairs = False box = gui.vBox(self.controlArea, "MDS Optimization") form = QFormLayout(labelAlignment=Qt.AlignLeft, formAlignment=Qt.AlignLeft, fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow, verticalSpacing=10) form.addRow("Max iterations:", gui.spin(box, self, "max_iter", 10, 10**4, step=1)) form.addRow( "Initialization:", gui.radioButtons(box, self, "initialization", btnLabels=("PCA (Torgerson)", "Random"), callback=self.__invalidate_embedding)) box.layout().addLayout(form) form.addRow( "Refresh:", gui.comboBox(box, self, "refresh_rate", items=[t for t, _ in OWMDS.RefreshRate], callback=self.__invalidate_refresh)) gui.separator(box, 10) self.runbutton = gui.button(box, self, "Run", callback=self._toggle_run) box = gui.vBox(self.mainArea, True, margin=0) self.graph = OWMDSGraph(self, box, "MDSGraph", view_box=MDSInteractiveViewBox) box.layout().addWidget(self.graph.plot_widget) self.plot = self.graph.plot_widget g = self.graph.gui box = g.point_properties_box(self.controlArea) self.models = g.points_models self.models[2].order = \ self.models[2].order[:1] + ("Stress", ) + self.models[2].order[1:] gui.hSlider(box, self, "connected_pairs", label="Show similar pairs:", minValue=0, maxValue=20, createLabel=False, callback=self._on_connected_changed) g.add_widgets(ids=[g.JitterSizeSlider], widget=box) box = gui.vBox(self.controlArea, "Plot Properties") g.add_widgets([ g.ShowLegend, g.ToolTipShowsAll, g.ClassDensity, g.LabelOnlySelected ], box) self.controlArea.layout().addStretch(100) self.icons = gui.attributeIconDict palette = self.graph.plot_widget.palette() self.graph.set_palette(palette) gui.rubber(self.controlArea) self.graph.box_zoom_select(self.controlArea) gui.auto_commit(box, self, "auto_commit", "Send Selected", checkbox_label="Send selected automatically", box=None) self.plot.getPlotItem().hideButtons() self.plot.setRenderHint(QPainter.Antialiasing) self.graph.jitter_continuous = True self._initialize()
def __init__(self, parent): super().__init__() self.parent = parent self.api = None self.info = gui.widgetLabel(self.controlArea, 'There are two ways to connect. Either register a Facebook app or obtain a temporary access token. Both require a Facebook account.') self.info.setWordWrap(True); login_box = gui.hBox(self.controlArea) login_box.setMinimumWidth(300) app_login = gui.widgetBox(login_box, box='Option 1: App login') temp_login = gui.widgetBox(login_box, box = 'Option 2: Temporary access token') ## app login app_form = QFormLayout() app_form.setContentsMargins(5, 5, 5, 5) app_info = gui.widgetLabel(app_login, 'To obtain an App ID and secret, <a href=\"https://developers.facebook.com/?advanced_app_create=true\">register</a> a new app (no actual app required). If you already registered an app you need to <a href=\"https://developers.facebook.com/apps/\">visit your app page</a>. The information is on the app dashboard.') app_info.setWordWrap(True); app_info.setOpenExternalLinks(True) self.app_id_edit = gui.lineEdit(self, self, 'app_id_input', controlWidth=350) self.app_secret_edit = gui.lineEdit(self, self, 'app_secret_input', controlWidth=350) app_form.addRow('App ID:', self.app_id_edit) app_form.addRow('App secret:', self.app_secret_edit) app_login.layout().addLayout(app_form) self.submit_button = gui.button(app_login, self, 'Connect', self.app_accept) ## temp login temp_form = QFormLayout() temp_form.setContentsMargins(5, 5, 5, 5) temp_info = gui.widgetLabel(temp_login, 'To obtain a temporary (1 hour) access token, visit <a href=\"https://developers.facebook.com/tools/explorer">here</a>. Copy the token (the long line of gibberish) from the "Access Token:" box.') temp_info.setWordWrap(True); temp_info.setOpenExternalLinks(True) self.temp_token_edit = gui.lineEdit(self, self, 'temp_token_input', controlWidth=350) temp_form.addRow('Access Token:', self.temp_token_edit) temp_login.layout().addLayout(temp_form) self.submit_button = gui.button(temp_login, self, 'Connect', self.temp_accept) self.load_credentials()
def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self.var = None # type: Optional[Variable] layout = QVBoxLayout() self.setLayout(layout) self.form = form = QFormLayout( fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow, objectName="editor-form-layout") layout.addLayout(self.form) self.name_edit = QLineEdit(objectName="name-editor") self.name_edit.editingFinished.connect( lambda: self.name_edit.isModified() and self.on_name_changed()) form.addRow("Name:", self.name_edit) vlayout = QVBoxLayout(margin=0, spacing=1) self.labels_edit = view = QTreeView( objectName="annotation-pairs-edit", rootIsDecorated=False, editTriggers=QTreeView.DoubleClicked | QTreeView.EditKeyPressed, ) self.labels_model = model = DictItemsModel() view.setModel(model) view.selectionModel().selectionChanged.connect( self.on_label_selection_changed) agrp = QActionGroup(view, objectName="annotate-action-group") action_add = QAction("+", self, objectName="action-add-label", toolTip="Add a new label.", shortcut=QKeySequence(QKeySequence.New), shortcutContext=Qt.WidgetShortcut) action_delete = QAction("\N{MINUS SIGN}", self, objectName="action-delete-label", toolTip="Remove selected label.", shortcut=QKeySequence(QKeySequence.Delete), shortcutContext=Qt.WidgetShortcut) agrp.addAction(action_add) agrp.addAction(action_delete) view.addActions([action_add, action_delete]) def add_label(): row = [QStandardItem(), QStandardItem()] model.appendRow(row) idx = model.index(model.rowCount() - 1, 0) view.setCurrentIndex(idx) view.edit(idx) def remove_label(): rows = view.selectionModel().selectedRows(0) if rows: assert len(rows) == 1 idx = rows[0].row() model.removeRow(idx) action_add.triggered.connect(add_label) action_delete.triggered.connect(remove_label) agrp.setEnabled(False) self.add_label_action = action_add self.remove_label_action = action_delete # Necessary signals to know when the labels change model.dataChanged.connect(self.on_labels_changed) model.rowsInserted.connect(self.on_labels_changed) model.rowsRemoved.connect(self.on_labels_changed) vlayout.addWidget(self.labels_edit) hlayout = QHBoxLayout() hlayout.setContentsMargins(0, 0, 0, 0) button = FixedSizeButton( self, defaultAction=self.add_label_action, accessibleName="Add", ) hlayout.addWidget(button) button = FixedSizeButton( self, defaultAction=self.remove_label_action, accessibleName="Remove", ) hlayout.addWidget(button) hlayout.addStretch(10) vlayout.addLayout(hlayout) form.addRow("Labels:", vlayout)
def __run_add_package_dialog(self): dlg = QDialog(self, windowTitle="Add add-on by name") dlg.setAttribute(Qt.WA_DeleteOnClose) vlayout = QVBoxLayout() form = QFormLayout() form.setContentsMargins(0, 0, 0, 0) nameentry = QLineEdit( placeholderText="Package name", toolTip="Enter a package name as displayed on " "PyPI (capitalization is not important)") nameentry.setMinimumWidth(250) form.addRow("Name:", nameentry) vlayout.addLayout(form) buttons = QDialogButtonBox( standardButtons=QDialogButtonBox.Ok | QDialogButtonBox.Cancel ) okb = buttons.button(QDialogButtonBox.Ok) okb.setEnabled(False) okb.setText("Add") def changed(name): okb.setEnabled(bool(name)) nameentry.textChanged.connect(changed) vlayout.addWidget(buttons) vlayout.setSizeConstraint(QVBoxLayout.SetFixedSize) dlg.setLayout(vlayout) f = None def query(): nonlocal f name = nameentry.text() f = self._executor.submit(pypi_json_query_project_meta, [name]) okb.setDisabled(True) def ondone(f): error_text = "" error_details = "" try: pkgs = f.result() except Exception: log.error("Query error:", exc_info=True) error_text = "Failed to query package index" error_details = traceback.format_exc() pkg = None else: pkg = pkgs[0] if pkg is None: error_text = "'{}' not was not found".format(name) if pkg: method_queued(self.add_package, (object,))(pkg) method_queued(dlg.accept, ())() else: method_queued(self.__show_error_for_query, (str, str)) \ (error_text, error_details) method_queued(dlg.reject, ())() f.add_done_callback(ondone) buttons.accepted.connect(query) buttons.rejected.connect(dlg.reject) dlg.exec_()
def __init__(self): super().__init__() self.data = None self._pca = None self._transformed = None self._variance_ratio = None self._cumulative = None self._init_projector() # Components Selection box = gui.vBox(self.controlArea, "Components Selection") form = QFormLayout() box.layout().addLayout(form) self.components_spin = gui.spin( box, self, "ncomponents", 1, MAX_COMPONENTS, callback=self._update_selection_component_spin, keyboardTracking=False) self.components_spin.setSpecialValueText("All") self.variance_spin = gui.spin( box, self, "variance_covered", 1, 100, callback=self._update_selection_variance_spin, keyboardTracking=False) self.variance_spin.setSuffix("%") form.addRow("Components:", self.components_spin) form.addRow("Explained variance:", self.variance_spin) # Options self.options_box = gui.vBox(self.controlArea, "Options") self.normalize_box = gui.checkBox(self.options_box, self, "normalize", "Normalize variables", callback=self._update_normalize) self.maxp_spin = gui.spin(self.options_box, self, "maxp", 1, MAX_COMPONENTS, label="Show only first", callback=self._setup_plot, keyboardTracking=False) self.controlArea.layout().addStretch() gui.auto_apply(self.controlArea, self, "auto_commit") self.plot = SliderGraph("Principal Components", "Proportion of variance", self._on_cut_changed) self.mainArea.layout().addWidget(self.plot) self._update_normalize()
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.separator(namesBox) gui.widgetLabel(namesBox, "Labels") self.classValuesView = listView = QListView( selectionMode=QListView.SingleSelection, sizePolicy=QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Maximum) ) 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.controlArea, "Tools", addSpace=True) buttonBox = gui.hBox(tBox) toolsBox = gui.widgetBox(buttonBox, 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(lambda _: self.invalidate()) gui.separator(tBox) 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 ) form.addRow("Radius:", slider) slider = gui.hSlider( indBox, self, "density", None, minValue=1, maxValue=100, createLabel=False ) form.addRow("Intensity:", slider) self.btResetToInput = gui.button( tBox, self, "Reset to Input Data", self.reset_to_input) self.btResetToInput.setDisabled(True) gui.rubber(self.controlArea) gui.auto_commit(self.left_side, self, "autocommit", "Send") # 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()