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_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) 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 __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 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, 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, 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): super().__init__() self.data = None layout = QFormLayout() gui.widgetBox(self.controlArea, box="Coordinates:", orientation=layout) self.variable_model = DomainModel(order=DomainModel.MIXED, valid_types=(ContinuousVariable, )) args = dict(contentsLength=100, searchable=True, model=self.variable_model, orientation=Qt.Horizontal) layout.addRow("Latitude:", gui.comboBox(None, self, "attr_lat", **args)) layout.addRow("Longitude:", gui.comboBox(None, self, "attr_lon", **args)) layout.addWidget( gui.checkBox( None, self, "replace_original", "Replace original coordinates", tooltip="If unchecked, the original coordinates are retained " "and new coordinates are added as separate variables.")) layout = QFormLayout() gui.widgetBox(self.controlArea, "Transformation:", orientation=layout) args["model"] = PyListModelTooltip(self.EPSG_CODES, list(self.EPSG_CODES)) layout.addRow("From:", gui.comboBox(None, self, "from_idx", **args)) layout.addRow("To:", gui.comboBox(None, self, "to_idx", **args)) self.commit_button = gui.button(self.controlArea, self, "&Commit", self.apply)
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 = gui.OrangeComboBox( 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 = gui.OrangeComboBox( 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 add_specific_parameters(self, parent): form = QFormLayout() self.edits = {} for parameter in self.parameters: edit = self.edits[parameter.arg_name] = QLineEdit() edit.convert = getattr(parameter.arg_type, "convert", parameter.arg_type) validator = getattr(parameter.arg_type, "validator", None) if validator is not None: edit.setValidator(validator) edit.setText(str(parameter.default)) edit.setAlignment(Qt.AlignRight) edit.setFixedWidth(50) form.addRow(parameter.label, edit) parent.layout().addLayout(form)
def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self.setLayout(QVBoxLayout()) form = QFormLayout() self.base_cb = QComboBox() self.base_cb.addItems([ "2 (Binary Logarithm)", "e (Natural Logarithm)", "10 (Common Logarithm)" ]) self.base_cb.currentIndexChanged.connect(self.changed) self.base_cb.activated.connect(self.edited) form.addRow("Logarithm Base:", self.base_cb) self.layout().addLayout(form)
def add_standard_parameters(self, parent): form = QFormLayout() parent.layout().addLayout(form) self.number_of_vars = edit = QLineEdit() edit.setValidator(pos_int.validator) edit.setText("10") edit.setAlignment(Qt.AlignRight) edit.setFixedWidth(50) form.addRow("Variables", edit) self.name_prefix = edit = QLineEdit() edit.setPlaceholderText(self.default_prefix) edit.setFixedWidth(50) form.addRow("Name prefix", edit)
def __setupUi(self): layout = QFormLayout() layout.setRowWrapPolicy(QFormLayout.WrapAllRows) layout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow) self.name_edit = LineEdit(self) self.name_edit.setPlaceholderText(self.tr("无标题")) self.name_edit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.desc_edit = QTextEdit(self) self.desc_edit.setTabChangesFocus(True) layout.addRow(self.tr("标题"), self.name_edit) layout.addRow(self.tr("描述"), self.desc_edit) self.setLayout(layout)
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, ) self.perplexity_spin = gui.spin( box, self, "perplexity", 1, 500, step=1, alignment=Qt.AlignRight, callback=self._invalidate_affinities, ) 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, )) 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, ) form.addRow(self.normalize_cbx) box.layout().addLayout(form) gui.separator(box, 10) self.run_button = gui.button(box, self, "Start", callback=self._toggle_run) self.para_box = [] self._add_ann_box() self.para_box[0].hide()
def create_configuration_layout(self): layout = QFormLayout() spin = gui.spin(self, self, "f", minv=8, maxv=SimhashVectorizer.max_f, step=8) spin.editingFinished.connect(self.f_spin_changed) 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 __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 __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 __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 _add_controls_start_box(self): box = gui.vBox(self.controlArea, True) form = QFormLayout( labelAlignment=Qt.AlignLeft, formAlignment=Qt.AlignLeft, fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow, verticalSpacing=10, ) self.perplexity_spin = gui.spin( box, self, "perplexity", 1, 500, step=1, alignment=Qt.AlignRight, callback=self._params_changed ) form.addRow("Perplexity:", self.perplexity_spin) self.perplexity_spin.setEnabled(not self.multiscale) form.addRow(gui.checkBox( box, self, "multiscale", label="Preserve global structure", callback=self._multiscale_changed )) sbe = gui.hBox(self.controlArea, False, addToLayout=False) gui.hSlider( sbe, self, "exaggeration", minValue=1, maxValue=4, step=1, callback=self._params_changed ) form.addRow("Exaggeration:", sbe) sbp = gui.hBox(self.controlArea, False, addToLayout=False) gui.hSlider( sbp, self, "pca_components", minValue=2, maxValue=50, 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, ) form.addRow(self.normalize_cbx) box.layout().addLayout(form) gui.separator(box, 10) self.runbutton = gui.button(box, self, "Run", callback=self._toggle_run)
def __init__(self): super().__init__() self.selected_node = None self.root_node = None self.model = None box = gui.vBox( self.controlArea, 'Tree', addSpace=20, sizePolicy=QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)) self.infolabel = gui.widgetLabel(box, 'No tree.') layout = QFormLayout() layout.setVerticalSpacing(20) layout.setFieldGrowthPolicy(layout.ExpandingFieldsGrow) box = self.display_box = \ gui.widgetBox(self.controlArea, "Display", addSpace=True, orientation=layout) layout.addRow( "Zoom: ", 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( "Width: ", 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( "Depth: ", gui.comboBox(box, self, 'max_tree_depth', items=["Unlimited"] + [ "{} levels".format(x) for x in range(2, 10)], addToLayout=False, sendSelectedValue=False, callback=self.toggle_tree_depth, sizePolicy=policy)) layout.addRow( "Edge width: ", gui.comboBox(box, self, 'line_width_method', items=['Fixed', 'Relative to root', 'Relative to parent'], 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 _add_controls_start_box(self): box = gui.vBox(self.controlArea, True) form = QFormLayout( labelAlignment=Qt.AlignLeft, formAlignment=Qt.AlignLeft, fieldGrowthPolicy=QFormLayout.AllNonFixedFieldsGrow, verticalSpacing=10, ) self.perplexity_spin = gui.spin(box, self, "perplexity", 1, 500, step=1, alignment=Qt.AlignRight, callback=self._params_changed) form.addRow("困惑度:", self.perplexity_spin) self.perplexity_spin.setEnabled(not self.multiscale) form.addRow( gui.checkBox(box, self, "multiscale", label="保留总体结构", callback=self._multiscale_changed)) sbe = gui.hBox(self.controlArea, False, addToLayout=False) gui.hSlider(sbe, self, "exaggeration", minValue=1, maxValue=4, step=1, callback=self._params_changed) form.addRow("Exaggeration:", sbe) sbp = gui.hBox(self.controlArea, False, addToLayout=False) gui.hSlider(sbp, self, "pca_components", minValue=2, maxValue=50, step=1, callback=self._params_changed) form.addRow("PCA components:", sbp) box.layout().addLayout(form) gui.separator(box, 10) self.runbutton = gui.button(box, self, "Run", callback=self._toggle_run)
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): 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 __init__(self): super().__init__() self.data = None self.embedder = "" self.basename = "" self.type_ext = "" self.compress_ext = "" self.writer = None self.id_smiles_attr = 0 self._embedder = '' self._embedders = list(EMBEDDERS.keys()) self._smiles_attr = '' form = QFormLayout() box = gui.vBox(self.controlArea, "Options") gui.comboBox( box, self, "_smiles_attr", sendSelectedValue=True, callback=self._update_options, ) form.addRow( "SMILES attribute: ", self.controls._smiles_attr ) gui.comboBox( box, self, "_embedder", sendSelectedValue=True, callback=self._update_options, items=self._embedders, ) form.addRow( "Embedder: ", self.controls._embedder ) box.layout().addLayout(form) gui.auto_commit(self.controlArea, self, "auto_commit", "Apply", callback=self.commit, checkbox_label="Apply automatically") self.adjustSize()
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): 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, 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) 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(minimum=minf, maximum=maxf, singleStep=0.5, value=v) e.focusIn = self.activateOptions e.editingFinished.connect(self.edited) def cf(x, name=name): self.edited.emit() 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) def set_rounded(_, line=l, name=name): cf(float(line.rounded_value()), name) l.sigMoved.connect(set_rounded) self.__lines[name] = l self.focusIn = self.activateOptions self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred) self.user_changed = False
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 __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, 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._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): 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, *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): super().__init__() self.selected_node = None self.root_node = None self.model = None box = gui.vBox( self.controlArea, 'Tree', sizePolicy=QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)) self.infolabel = gui.widgetLabel(box, 'No tree.') layout = QFormLayout() layout.setFieldGrowthPolicy(layout.ExpandingFieldsGrow) box = self.display_box = gui.widgetBox(self.controlArea, "Display", orientation=layout) layout.addRow( "Zoom: ", gui.hSlider(box, self, 'zoom', minValue=1, maxValue=10, step=1, ticks=False, callback=self.toggle_zoom_slider, createLabel=False, addToLayout=False)) layout.addRow( "Width: ", gui.hSlider(box, self, 'max_node_width', minValue=50, maxValue=200, step=1, ticks=False, callback=self.toggle_node_size, createLabel=False, addToLayout=False)) policy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) layout.addRow( "Depth: ", gui.comboBox(box, self, 'max_tree_depth', items=["Unlimited"] + [ "{} levels".format(x) for x in range(2, 10)], addToLayout=False, sendSelectedValue=False, callback=self.toggle_tree_depth, sizePolicy=policy)) layout.addRow( "Edge width: ", gui.comboBox(box, self, 'line_width_method', items=['Fixed', 'Relative to root', 'Relative to parent'], addToLayout=False, callback=self.toggle_line_width, sizePolicy=policy)) gui.rubber(self.controlArea) 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, *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 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) gui.checkBox(box, self, "show_legend", label="Show legend", callback=self.update_legend_visible) 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) self.update_legend_visible() return box
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.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): 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 __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 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 __init__(self, parent): super().__init__() self.parent = parent self.api = None form = QFormLayout() form.setContentsMargins(5, 5, 5, 5) self.host_edit = gui.lineEdit(self, self, 'host_input', controlWidth=150) self.user_edit = gui.lineEdit(self, self, 'user_input', controlWidth=150) self.passwd_edit = gui.lineEdit(self, self, 'passwd_input', controlWidth=150) self.passwd_edit.setEchoMode(QLineEdit.Password) tokenbox = gui.vBox(self) self.submit_button = gui.button(tokenbox, self, 'request new token', self.accept, width=100) self.token_edit = gui.lineEdit(tokenbox, self, 'token_input', controlWidth=200) form.addRow('Host:', self.host_edit) form.addRow('username:'******'password:', self.passwd_edit) form.addRow(tokenbox) self.controlArea.layout().addLayout(form) 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, *args, **kwargs): super().__init__(*args, **kwargs) self._current_palette = "" form = QFormLayout() styles = QStyleFactory.keys() styles = sorted(styles, key=cmp_to_key( lambda a, b: 1 if a.lower() == "windows" and b.lower() == "fusion" else (-1 if a.lower() == "fusion" and b.lower() == "windows" else 0) )) styles = [ (self.DisplayNames.get(st.lower(), st.capitalize()), st) for st in styles ] # Default style with empty userData key so it cleared in # persistent settings, allowing for default style resolution # on application star. styles = [("Default", "")] + styles self.style_cb = style_cb = QComboBox(objectName="style-cb") for name, key in styles: self.style_cb.addItem(name, userData=key) style_cb.currentIndexChanged.connect(self._style_changed) self.colors_cb = colors_cb = QComboBox(objectName="palette-cb") colors_cb.addItem("Default", userData="") colors_cb.addItem("Breeze Light", userData="breeze-light") colors_cb.addItem("Breeze Dark", userData="breeze-dark") colors_cb.addItem("Zion Reversed", userData="zion-reversed") colors_cb.addItem("Dark", userData="dark") form.addRow("Style", style_cb) form.addRow("Color theme", colors_cb) label = QLabel( "<small>Changes will be applied on next application startup.</small>", enabled=False, ) label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) form.addRow(label) self.setLayout(form) self._update_colors_enabled_state() style_cb.currentIndexChanged.connect(self.selectedStyleChanged) colors_cb.currentIndexChanged.connect(self.selectedPaletteChanged)
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)))
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 __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.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) # 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()
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 __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.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.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()
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_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()