def __init__(self, oba, parent): super(EditOBAUI, self).__init__() self.parent = parent self.oba = oba self.setLayout(QVBoxLayout(self)) self.layout().setAlignment(Qt.AlignCenter) # Init Name text control self._nameControl = LineEdit('Name', self) self._nameControl.setText(self.oba.name) self._nameControl.kb.connect(self.showOSK) # Init Output Pin dropdown control self._outputPinControlLabel = QLabel('Output Pin', self) self._outputPinControl = QComboBox(self) for _pin in self.parent.availablePins(): self._outputPinControl.addItem(str(_pin)) for _i in range(self._outputPinControl.count()): if self._outputPinControl.itemText(_i) == str(self.oba.outputPin): self._outputPinControl.setCurrentIndex(_i) break # Init Momentary checkbox control and set value self._momentaryControl = QCheckBox('Momentary', self) self._momentaryControl.setChecked(self.oba.momentary) # Init Enabled checkbox control and set value self._enabledControl = QCheckBox('Enabled', self) self._enabledControl.setChecked(self.oba.enabled) # Init Icon dropdown control self._iconControlLabel = QLabel('Icon Path', self) self._iconControl = QComboBox(self) for _key in Config.icons['oba'].keys(): icon = Config.icon('oba', _key) self._iconControl.addItem(icon['name'], _key) self._iconControl.setItemIcon(self._iconControl.count() - 1, QIcon(icon['path'])) for _i in range(self._iconControl.count()): # Set current index if matching icon attribute if self.oba.icon is not None and self._iconControl.itemData( _i) == self.oba.icon: self._iconControl.setCurrentIndex(_i) break # Init Save button self._saveBtn = QPushButton('Save', self) self._saveBtn.clicked.connect(self.__saveBtnAction) # Init cancel button self._cancelBtn = QPushButton('Cancel', self) self._cancelBtn.clicked.connect(self.__cancel) # Assign control layout _layout = [['_nameControl'], ['_outputPinControlLabel', '_outputPinControl'], ['_momentaryControl', '_enabledControl'], ['_iconControlLabel', '_iconControl'], ['_saveBtn', '_cancelBtn']] for _list in _layout: _panel = QWidget(self) _panel.setLayout(QHBoxLayout(_panel)) _panel.layout().setAlignment(Qt.AlignCenter) _panel.layout().setSpacing(20) for _control in _list: _panel.layout().addWidget(eval('self.%s' % _control)) self.layout().addWidget(_panel)
def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self._lower_bound = self.DEFAULT_LOWER_BOUND self._upper_bound = self.DEFAULT_UPPER_BOUND self.setLayout(QVBoxLayout()) box = QGroupBox(title="Clipping", flat=True) form = QFormLayout() self.lower_check = QCheckBox("Lower Bound: ") self.lower_check.clicked.connect(self.edited) self.lower_spin = QSpinBox(minimum=-99, maximum=0, value=self._lower_bound) self.lower_spin.valueChanged[int].connect(self._set_lower_bound) self.lower_spin.editingFinished.connect(self.edited) self.upper_check = QCheckBox("Upper Bound: ") self.upper_check.clicked.connect(self.edited) self.upper_spin = QSpinBox(value=self._upper_bound) self.upper_spin.valueChanged[int].connect(self._set_upper_bound) self.upper_spin.editingFinished.connect(self.edited) form.addRow(self.lower_check, self.lower_spin) form.addRow(self.upper_check, self.upper_spin) box.setLayout(form) self.layout().addWidget(box)
def __init__(self, master): super().__init__(master) label = gui.label(self, self, 'Language:') label.setAlignment(Qt.AlignRight) self.method_layout.addWidget(label, self.SNOWBALL, 1) snowball_box = widgets.ComboBox(self, 'snowball_language', items=preprocess.SnowballStemmer.supported_languages) snowball_box.currentIndexChanged.connect(self.change_language) self.method_layout.addWidget(snowball_box, self.SNOWBALL, 2) self.methods[self.SNOWBALL].language = self.snowball_language self.udpipe_tokenizer_box = QCheckBox("UDPipe tokenizer", self, checked=self.udpipe_tokenizer) self.udpipe_tokenizer_box.stateChanged.connect(self.change_tokenizer) self.method_layout.addWidget(self.udpipe_tokenizer_box, self.UDPIPE, 1) self.udpipe_label = gui.label(self, self, 'Language:') self.udpipe_label.setAlignment(Qt.AlignRight) self.method_layout.addWidget(self.udpipe_label, self.UDPIPE, 2) self.udpipe_models = UDPipeModels() self.create_udpipe_box() self.udpipe_online = self.udpipe_models.online self.on_off_button.stateChanged.connect(self.check_udpipe_online) self.check_udpipe_online() self.methods[self.UDPIPE].language = self.udpipe_language self.methods[self.UDPIPE].use_tokenizer = self.udpipe_tokenizer
def __init__(self, parent=None, defaults=[True, False, False, False], enabled=[False, True, True, True], **kwargs): super().__init__(parent, **kwargs) self.setLayout(QVBoxLayout()) for item, default in zip(self.items, defaults): setattr(self, item[0], default) for item, enable, checked in zip(self.items, enabled, defaults): cb = QCheckBox(text=item[1], checked=checked, enabled=enable) cb.toggled[bool].connect( lambda state, name=item[0]: setattr(self, name, state)) self.layout().addWidget(cb) bbox = QDialogButtonBox(Qt.Horizontal, standardButtons=QDialogButtonBox.Ok | QDialogButtonBox.Cancel) bbox.accepted.connect(self.accept) bbox.rejected.connect(self.reject) self.layout().addWidget(bbox) self.layout().setSizeConstraint(QLayout.SetFixedSize)
def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self.__snowball_lang = self.DEFAULT_LANGUAGE self.__udpipe_lang = self.DEFAULT_LANGUAGE self.__use_tokenizer = self.DEFAULT_USE_TOKE self.__combo_sbl = ComboBox( self, SnowballStemmer.supported_languages, self.__snowball_lang, self.__set_snowball_lang ) self.__combo_udl = UDPipeComboBox( self, self.__udpipe_lang, self.DEFAULT_LANGUAGE, self.__set_udpipe_lang ) self.__check_use = QCheckBox("UDPipe tokenizer", checked=self.DEFAULT_USE_TOKE) self.__check_use.clicked.connect(self.__set_use_tokenizer) label = QLabel("Language:") label.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.layout().addWidget(label, self.Snowball, 1) self.layout().addWidget(self.__combo_sbl, self.Snowball, 2) label = QLabel("Language:") label.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.layout().addWidget(label, self.UDPipe, 1) self.layout().addWidget(self.__combo_udl, self.UDPipe, 2) self.layout().addWidget(self.__check_use, self.UDPipe, 3) self.layout().setColumnStretch(2, 1) self.__enable_udpipe()
def __setupUi(self): layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) self.editor = SchemeInfoEdit(self) self.editor.layout().setContentsMargins(20, 20, 20, 20) self.editor.layout().setSpacing(15) self.editor.setSizePolicy( QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding ) heading = self.tr("Workflow Info") heading = "<h3>{0}</h3>".format(heading) self.heading = QLabel(heading, self, objectName="heading") # Insert heading self.editor.layout().insertRow(0, self.heading) self.buttonbox = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self ) # Insert button box self.editor.layout().addRow(self.buttonbox) widget = StyledWidget(self, objectName="auto-show-container") check_layout = QHBoxLayout() check_layout.setContentsMargins(20, 10, 20, 10) self.__showAtNewSchemeCheck = QCheckBox( self.tr("Show when I make a New Workflow."), self, objectName="auto-show-check", checked=False, ) check_layout.addWidget(self.__showAtNewSchemeCheck) check_layout.addWidget( QLabel( self.tr( "You can also edit Workflow Info later " "(File -> Workflow Info)." ), self, objectName="auto-show-info", ), alignment=Qt.AlignRight, ) widget.setLayout(check_layout) widget.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) if self.__autoCommit: self.buttonbox.accepted.connect(self.editor.commit) self.buttonbox.accepted.connect(self.accept) self.buttonbox.rejected.connect(self.reject) layout.addWidget(self.editor, stretch=10) layout.addWidget(widget) self.setLayout(layout)
def __init__(self, parent=None, master=None, **kwargs): super().__init__(parent, **kwargs) self._group_var = self.DEFAULT_GROUP_VAR self._master = master self._master.input_data_changed.connect(self._set_model) self.setLayout(QVBoxLayout()) form = QFormLayout() cpm_b = QRadioButton("Counts per million", checked=True) med_b = QRadioButton("Median") self.group = QButtonGroup() self.group.buttonClicked.connect(self._on_button_clicked) for i, button in enumerate([cpm_b, med_b]): index = index_to_enum(Normalize.Method, i).value self.group.addButton(button, index - 1) form.addRow(button) self.group_by_check = QCheckBox("Cell Groups: ", enabled=self.DEFAULT_GROUP_BY) self.group_by_check.clicked.connect(self.edited) self.group_by_combo = QComboBox(enabled=self.DEFAULT_GROUP_BY) self.group_by_model = DomainModel(order=(DomainModel.METAS, DomainModel.CLASSES), valid_types=DiscreteVariable, alphabetical=True) self.group_by_combo.setModel(self.group_by_model) self.group_by_combo.currentIndexChanged.connect(self.changed) self.group_by_combo.activated.connect(self.edited) form.addRow(self.group_by_check, self.group_by_combo) self.layout().addLayout(form) self._set_model()
def setupUi(self): self.setLayout(QVBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) self.layout().setSpacing(0) self.__mainLayout = QVBoxLayout() self.__mainLayout.setContentsMargins(0, 40, 0, 40) self.__mainLayout.setSpacing(65) self.layout().addLayout(self.__mainLayout) self.setStyleSheet(WELCOME_WIDGET_BUTTON_STYLE) bottom_bar = QWidget(objectName="bottom-bar") bottom_bar_layout = QHBoxLayout() bottom_bar_layout.setContentsMargins(20, 10, 20, 10) bottom_bar.setLayout(bottom_bar_layout) bottom_bar.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Maximum) check = QCheckBox(self.tr("Show at startup"), bottom_bar) check.setChecked(False) self.__showAtStartupCheck = check bottom_bar_layout.addWidget(check, alignment=Qt.AlignVCenter | \ Qt.AlignLeft) self.layout().addWidget(bottom_bar, alignment=Qt.AlignBottom, stretch=1) self.setSizeGripEnabled(False) self.setFixedSize(620, 390)
def __add_aggregation_controls(self): def new_inbox(): nonlocal row, col, inbox inbox = QWidget() layout = QGridLayout() inbox.setLayout(layout) layout.setContentsMargins(0, 0, 0, 0) box.layout().addWidget(inbox) row = col = 0 box = gui.vBox(self.controlArea, "Aggregations") row = col = 0 inbox = None new_inbox() self.aggregation_checkboxes = [] # for test purposes for agg in self.AGGREGATIONS: if agg is None: line = QFrame() line.setFrameShape(QFrame.HLine) line.setLineWidth(1) line.setFrameShadow(QFrame.Sunken) box.layout().addWidget(line) new_inbox() continue elif agg == 2: col += 1 row = 0 continue check_box = QCheckBox(str(agg), inbox) check_box.setChecked(agg in self.sel_agg_functions) check_box.clicked.connect( lambda *args, a=agg: self.__aggregation_cb_clicked(a, args[0])) inbox.layout().addWidget(check_box, row, col) self.aggregation_checkboxes.append(check_box) row += 1
def main(argv=None): # pragma: no cover from AnyQt.QtWidgets import QVBoxLayout, QCheckBox, QStatusBar app = QApplication(list(argv) if argv else []) l1 = QVBoxLayout() l1.setContentsMargins(0, 0, 0, 0) blayout = QVBoxLayout() l1.addLayout(blayout) sb = QStatusBar() w = QWidget() w.setLayout(l1) messages = [ Message( Severity.Error, text="Encountered a HCF", detailedText="<em>AAA! It burns.</em>", textFormat=Qt.RichText, ), Message( Severity.Warning, text="ACHTUNG!", detailedText=('<div style="color: red">DAS KOMPUTERMASCHINE IST ' "NICHT FÜR DER GEFINGERPOKEN</div>"), textFormat=Qt.RichText, ), Message( Severity.Information, text="The rain in spain falls mostly on the plain", informativeText=( '<a href="https://www.google.si/search?q=' 'Average+Yearly+Precipitation+in+Spain">Link</a>'), textFormat=Qt.RichText, ), Message( Severity.Error, text="I did not do this!", informativeText="The computer made suggestions...", detailedText="... and the default options was yes.", ), Message(), ] mw = MessagesWidget(openExternalLinks=True) for i, m in enumerate(messages): cb = QCheckBox(m.text) def toogled(state, i=i, m=m): if state: mw.setMessage(i, m) else: mw.removeMessage(i) cb.toggled[bool].connect(toogled) blayout.addWidget(cb) sb.addWidget(mw) w.layout().addWidget(sb, 0) w.show() return app.exec_()
def __init__(self, parent): super(AddLightUI, self).__init__() self.title = 'Create Lighting Element' self.setLayout(QVBoxLayout(self)) self.parent = parent self.light = Light(name='', outputPin=0, enabled=False, icon=Config.faIcon('lightbulb'), strobe=False) self._nameControl = LineEdit('Name', self) self._nameControl.kb.connect(self.showOSK) self._outputPinControlLabel = QLabel('Output Pin', self) self._outputPinControl = QComboBox(self) for _pin in self.parent.availablePins(): self._outputPinControl.addItem(str(_pin)) self._outputPinControl.setCurrentIndex( self._outputPinControl.findText(str(self.light.outputPin))) self._enabledControl = QCheckBox('Enabled', self) self._iconControlLabel = QLabel('Icon', self) self._iconControl = QComboBox(self) for _key in Config.icons['lights'].keys(): icon = Config.icon('lights', _key) self._iconControl.addItem(icon['name'], _key) self._iconControl.setItemIcon(self._iconControl.count() - 1, QIcon(icon['path'])) self._strobeControl = QCheckBox('Strobe', self) self._addLightBtn = QPushButton('Add Lighting Element', self) self._addLightBtn.clicked.connect(self.__createLightBtnAction) self._cancelBtn = QPushButton('Cancel', self) self._cancelBtn.clicked.connect(self.__cancel) _layout = [['_nameControl'], ['_outputPinControlLabel', '_outputPinControl'], ['_enabledControl', '_strobeControl'], ['_iconControlLabel', '_iconControl'], ['_addLightBtn', '_cancelBtn']] for _list in _layout: _panel = QWidget(self) _panel.setLayout(QHBoxLayout(_panel)) _panel.layout().setAlignment(Qt.AlignCenter) for _control in _list: _panel.layout().addWidget(eval('self.%s' % _control)) self.layout().addWidget(_panel)
def _add_row(self, parameter: Optional[Parameter] = None): row_id = len(self.__controls) if parameter is None: parameter = Parameter(f"p{row_id + 1}") edit = QLineEdit(text=parameter.name) edit.setFixedWidth(60) edit.textChanged.connect(self.__on_text_changed) button = gui.button(None, self, "×", callback=self.__on_remove_button_clicked, autoDefault=False, width=34, sizePolicy=(QSizePolicy.Maximum, QSizePolicy.Maximum)) kwargs = {"minimum": -2147483647, "maximum": 2147483647} init_spin = QDoubleSpinBox(decimals=4, **kwargs) lower_spin = QDoubleSpinBox(**kwargs) upper_spin = QDoubleSpinBox(**kwargs) init_spin.setValue(parameter.initial) lower_spin.setValue(parameter.lower) upper_spin.setValue(parameter.upper) lower_check = QCheckBox(checked=bool(parameter.use_lower)) upper_check = QCheckBox(checked=bool(parameter.use_upper)) lower_spin.setEnabled(lower_check.isChecked()) upper_spin.setEnabled(upper_check.isChecked()) init_spin.valueChanged.connect(self.__on_init_spin_changed) lower_spin.valueChanged.connect(self.__on_lower_spin_changed) upper_spin.valueChanged.connect(self.__on_upper_spin_changed) lower_check.stateChanged.connect(self.__on_lower_check_changed) upper_check.stateChanged.connect(self.__on_upper_check_changed) controls = (button, edit, init_spin, lower_check, lower_spin, upper_check, upper_spin) n_rows = self.__layout.rowCount() for i, control in enumerate(controls): self.__layout.addWidget(control, n_rows, i) self.__data.append(parameter) self.__controls.append(controls) self._set_labels_visible(True)
def setup_method_layout(self): self.methods = [method() for method in self.methods] self.buttons = [] for i, method in enumerate(self.methods): cb = QCheckBox(self.textify(method.name)) cb.setChecked(i in self.checked) cb.stateChanged.connect(self.update_value) cb.setToolTip(self.get_tooltip(method)) self.method_layout.addWidget(cb) self.buttons.append(cb)
def __init__(self, parent=None, **kwargs): super(AddonManagerWidget, self).__init__(parent, **kwargs) self.__items = [] self.setLayout(QVBoxLayout()) self.__header = QLabel(wordWrap=True, textFormat=Qt.RichText) self.__search = QLineEdit(placeholderText=self.tr("Filter")) self.__only_trusted = QCheckBox(self.tr("Show only trusted add-ons"), ) topline = QHBoxLayout() topline.addWidget(self.__search) topline.addWidget(self.__only_trusted) self.layout().addLayout(topline) self.__only_trusted.setChecked(True) self.show_only_trusted = True self.__only_trusted.stateChanged.connect( self._show_only_trusted_changed) self.__view = view = QTreeView(rootIsDecorated=False, editTriggers=QTreeView.NoEditTriggers, selectionMode=QTreeView.SingleSelection, alternatingRowColors=True) self.__view.setItemDelegateForColumn(0, TristateCheckItemDelegate()) self.layout().addWidget(view) self.__model = model = QStandardItemModel() model.setHorizontalHeaderLabels(["", "Name", "Version", "Action"]) model.dataChanged.connect(self.__data_changed) self.__proxy = proxy = SortFilterProxyTrusted( filterKeyColumn=1, filterCaseSensitivity=Qt.CaseInsensitive) proxy.setSourceModel(model) self.__search.textChanged.connect(proxy.setFilterFixedString) view.setModel(proxy) view.selectionModel().selectionChanged.connect(self.__update_details) header = self.__view.header() header.setSectionResizeMode(0, QHeaderView.Fixed) header.setSectionResizeMode(2, QHeaderView.ResizeToContents) self.__details = QTextBrowser( frameShape=QTextBrowser.NoFrame, readOnly=True, lineWrapMode=QTextBrowser.WidgetWidth, openExternalLinks=True, ) self.__details.setWordWrapMode(QTextOption.WordWrap) palette = QPalette(self.palette()) palette.setColor(QPalette.Base, Qt.transparent) self.__details.setPalette(palette) self.layout().addWidget(self.__details)
def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self.__methods = self.DEFAULT_METHODS self.setLayout(QGridLayout()) self.__cbs = [] for method in range(len(self.Methods)): cb = QCheckBox(self.Methods[method].name, self) cb.setChecked(method in self.__methods) cb.clicked.connect(self.__method_check_clicked) cb.setToolTip(self.get_tooltip(self.Methods[method])) self.__cbs.append((method, cb)) self.layout().addWidget(cb)
def __init__(self, trac, parent): super(EditTracUI, self).__init__() self.title = 'Edit TracControl Element' self.setLayout(QVBoxLayout(self)) self.layout().setAlignment(Qt.AlignCenter) self.parent = parent self.trac = trac # Init controls self._nameControl = LineEdit('Name', self) self._nameControl.setText(self.trac.name) self._nameControl.kb.connect(self.showOSK) self._outputPinControlLabel = QLabel('Output Pin', self) self._outputPinControl = QComboBox(self) for _pins in self.parent.availablePins(): self._outputPinControl.addItem(str(_pins)) for _i in range(self._outputPinControl.count()): if self._outputPinControl.itemText(_i) == str(self.trac.outputPin): self._outputPinControl.setCurrentIndex(_i) break self._enabledControl = QCheckBox('Enabled', self) self._enabledControl.setChecked(self.trac.enabled) self._iconControlLabel = QLabel('Icon Path', self) self._iconControl = QComboBox(self) for _key in Config.icons['tracControl'].keys(): icon = Config.icon('tracControl', _key) self._iconControl.addItem(icon['name'], _key) self._iconControl.setItemIcon(self._iconControl.count() - 1, QIcon(icon['path'])) # Set combobox selection to icon variable for iconIdx in range(self._iconControl.count()): if self.trac.icon is not None and self._iconControl.itemData( iconIdx) == self.trac.icon: self._iconControl.setCurrentIndex(iconIdx) break self._saveBtn = QPushButton('Save', self) self._saveBtn.clicked.connect(self.__saveBtnAction) self._cancelBtn = QPushButton('Cancel', self) self._cancelBtn.clicked.connect(self.__cancel) _layout = [['_nameControl'], ['_outputPinControlLabel', '_outputPinControl'], ['_enabledControl'], ['_iconControlLabel', '_iconControl'], ['_saveBtn', '_cancelBtn']] for _list in _layout: _panel = QWidget(self) _panel.setLayout(QHBoxLayout(_panel)) _panel.layout().setAlignment(Qt.AlignCenter) for _ctrl in _list: _panel.layout().addWidget(eval('self.%s' % _ctrl)) self.layout().addWidget(_panel)
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, state=AVAILABLE, parent=None): QWidget.__init__(self, parent) layout = QHBoxLayout() layout.setSpacing(1) layout.setContentsMargins(1, 1, 1, 1) self.checkButton = QCheckBox() layout.addWidget(self.checkButton) self.setLayout(layout) self.setMinimumHeight(20) self.setMaximumHeight(20) self._state = state self._update()
def __add_aggregation_controls(self): box = gui.vBox(self.controlArea, "Aggregations") for agg in self.AGGREGATIONS: if agg is None: gui.separator(box, height=1) line = QFrame() line.setFrameShape(QFrame.HLine) line.setLineWidth(1) line.setFrameShadow(QFrame.Sunken) box.layout().addWidget(line) continue check_box = QCheckBox(str(agg), box) check_box.setChecked(agg in self.sel_agg_functions) check_box.clicked.connect( lambda *args, a=agg: self.__aggregation_cb_clicked(a, args[0])) box.layout().addWidget(check_box)
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 setCollection(self, collection, dataset, flags=0): CollectionWidget.setCollection(self, collection, dataset, flags) filters = [f for f in collection.elements("FilterDescription") if not is_hidden(f)] + \ [f for f in collection.elements("AttributeDescription") if not is_hidden(f)] # in case of pointers to filters (upstream/downstream flank) self.enableCB = QCheckBox(getattr(collection, "displayName", ""), self) if hasattr(collection, "description"): self.setToolTip(collection.description) if len(filters) == 1 and (not hasattr(filters[0], "displayName") or \ getattr(filters[0], "displayName", "") == getattr(collection, "displayName", "")): flags = flags | self.SINGLE_FILTER_FLAG i = 0 if not flags & self.SINGLE_FILTER_FLAG: self.layout().addWidget(self.enableCB, 0, 0) i += 1 for filter in filters: fType = getattr(filter, "type", None) if filter.is_pointer(): try: dataset, newfilter = filter.get_pointed() except ValueError as ex: newfilter = None if not newfilter: continue filter = newfilter fType = getattr(filter, "type", None) if fType is None else fType label, filter_widget = self.buildFilter(filter, flags, fTypeHint=fType) if isinstance(label, six.string_types): label = QLabel(label) self.layout().addWidget(label, i, 0) self.layout().addWidget(filter_widget, i, 1) i += 1 self.addSubControl(filter, filter_widget) if self.layout().count() == 0: self.layout().addWidget(self.enableCB, 0, 0)
def setupUi(self): self.setLayout(QVBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) self.layout().setSpacing(0) self.__mainLayout = QVBoxLayout() self.__mainLayout.setContentsMargins(0, 40, 0, 40) self.__mainLayout.setSpacing(65) self.layout().addLayout(self.__mainLayout) self.setStyleSheet(WELCOME_WIDGET_BUTTON_STYLE) bottom_bar = QWidget(objectName="bottom-bar") bottom_bar_layout = QHBoxLayout() bottom_bar_layout.setContentsMargins(20, 10, 20, 10) bottom_bar.setLayout(bottom_bar_layout) bottom_bar.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Maximum) check = QCheckBox(self.tr("启动显示"), bottom_bar) check.setChecked(False) self.__showAtStartupCheck = check """ feedback = QLabel( '<a href="http://orange.biolab.si/survey/long.html">Help us improve!</a>') feedback.setTextInteractionFlags(Qt.TextBrowserInteraction) feedback.setOpenExternalLinks(True) """ bottom_bar_layout.addWidget(check, alignment=Qt.AlignVCenter | \ Qt.AlignLeft) """ bottom_bar_layout.addWidget(feedback, alignment=Qt.AlignVCenter | \ Qt.AlignRight) """ self.layout().addWidget(bottom_bar, alignment=Qt.AlignBottom, stretch=1) self.setSizeGripEnabled(False) self.setFixedSize(620, 390)
def test_prop(self): w = QWidget() layout = QVBoxLayout() cb = QCheckBox("Check", w) sp = QSpinBox(w) le = QLineEdit(w) textw = QTextEdit(w, readOnly=True) textw.setProperty("checked_", False) textw.setProperty("spin_", 0) textw.setProperty("line_", "") textexpr = PropertyBindingExpr( r""" ("Check box is {0}\n" "Spin has value {1}\n" "Line contains {2}").format( "checked" if checked else "unchecked", spin, line) """, dict( checked=binding_for(cb, "checked"), spin=binding_for(sp, "value"), line=binding_for(le, "text"), ), ) layout.addWidget(cb) layout.addWidget(sp) layout.addWidget(le) layout.addWidget(textw) manager = BindingManager(submitPolicy=BindingManager.AutoSubmit) manager.bind(PropertyBinding(textw, "plainText", "textChanged"), textexpr) w.setLayout(layout) w.show() self.app.exec_()
def __add_aggregation_controls(self): box = gui.vBox(self.controlArea, "聚合") chinese_aggs = [ "计数(Count)", "计数已定义项(Count_defined)", None, "总和(Sum)", "平均(Mean)", "样式(Mode)", "最小(Min)", "最大(Max)", "中位数(Median)", "变量(Var)", None, "大多数(Majority)" ] for agg, chinese_agg in zip(self.AGGREGATIONS, chinese_aggs): if agg is None: gui.separator(box, height=1) line = QFrame() line.setFrameShape(QFrame.HLine) line.setLineWidth(1) line.setFrameShadow(QFrame.Sunken) box.layout().addWidget(line) continue check_box = QCheckBox(str(chinese_agg), box) check_box.setChecked(agg in self.sel_agg_functions) check_box.clicked.connect( lambda *args, a=agg: self.__aggregation_cb_clicked(a, args[0])) box.layout().addWidget(check_box)
def __init__(self, title, master, attr, items, cols=1, callback=None): super().__init__(title=title) self.master = master self.attr = attr self.items = items self.callback = callback self.current_values = getattr(self.master, self.attr) layout = QGridLayout() self.setLayout(layout) nrows = len(items) // cols + bool(len(items) % cols) self.boxes = [] for i, value in enumerate(self.items): box = QCheckBox(value) box.setChecked(value in self.current_values) box.stateChanged.connect(self.synchronize) self.boxes.append(box) layout.addWidget(box, i % nrows, i // nrows)
def setupUi(self): self.setLayout(QVBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) self.layout().setSpacing(0) self.__mainLayout = QVBoxLayout() self.__mainLayout.setContentsMargins(0, 40, 0, 40) self.__mainLayout.setSpacing(65) self.layout().addLayout(self.__mainLayout) self.setStyleSheet(WELCOME_WIDGET_BUTTON_STYLE) bottom_bar = QWidget(objectName="bottom-bar") bottom_bar_layout = QHBoxLayout() bottom_bar_layout.setContentsMargins(20, 10, 20, 10) bottom_bar.setLayout(bottom_bar_layout) bottom_bar.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Maximum) self.__showAtStartupCheck = QCheckBox( self.tr("Show at startup"), bottom_bar, checked=False ) self.__feedbackLabel = QLabel( textInteractionFlags=Qt.TextBrowserInteraction, openExternalLinks=True, visible=False, ) bottom_bar_layout.addWidget( self.__showAtStartupCheck, alignment=Qt.AlignVCenter | Qt.AlignLeft ) bottom_bar_layout.addWidget( self.__feedbackLabel, alignment=Qt.AlignVCenter | Qt.AlignRight ) self.layout().addWidget(bottom_bar, alignment=Qt.AlignBottom, stretch=1) self.setSizeGripEnabled(False) self.setFixedSize(620, 390)
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__() 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 __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, data): icon = QApplication.style().standardIcon(QStyle.SP_MessageBoxWarning) F = self.DataField def _finished(*, key=(data.get(F.MODULE), data.get(F.WIDGET_MODULE)), filename=data.get(F.WIDGET_SCHEME)): self._cache.add(key) try: os.remove(filename) except Exception: pass super().__init__(None, Qt.Window, modal=True, sizeGripEnabled=True, windowIcon=icon, windowTitle='Unexpected Error', finished=_finished) self._data = data layout = QVBoxLayout(self) self.setLayout(layout) labels = QWidget(self) labels_layout = QHBoxLayout(self) labels.setLayout(labels_layout) labels_layout.addWidget(QLabel(pixmap=icon.pixmap(50, 50))) labels_layout.addWidget( QLabel('The program encountered an unexpected error. Please<br>' 'report it anonymously to the developers.<br><br>' 'The following data will be reported:')) labels_layout.addStretch(1) layout.addWidget(labels) font = QFont('Monospace', 10) font.setStyleHint(QFont.Monospace) font.setFixedPitch(True) textbrowser = QTextBrowser(self, font=font, openLinks=False, lineWrapMode=QTextBrowser.NoWrap, anchorClicked=QDesktopServices.openUrl) layout.addWidget(textbrowser) def _reload_text(): add_scheme = cb.isChecked() settings.setValue('error-reporting/add-scheme', add_scheme) lines = ['<table>'] for k, v in data.items(): if k.startswith('_'): continue _v, v = v, escape(str(v)) if k == F.WIDGET_SCHEME: if not add_scheme: continue v = '<a href="{}">{}</a>'.format( urljoin('file:', pathname2url(_v)), v) if k in (F.STACK_TRACE, F.LOCALS): v = v.replace('\n', '<br>').replace(' ', ' ') lines.append( '<tr><th align="left">{}:</th><td>{}</td></tr>'.format( k, v)) lines.append('</table>') textbrowser.setHtml(''.join(lines)) settings = QSettings() cb = QCheckBox('Include workflow (data will NOT be transmitted)', self, checked=settings.value('error-reporting/add-scheme', True, type=bool)) cb.stateChanged.connect(_reload_text) _reload_text() layout.addWidget(cb) buttons = QWidget(self) buttons_layout = QHBoxLayout(self) buttons.setLayout(buttons_layout) buttons_layout.addWidget( QPushButton('Send Report (Thanks!)', default=True, clicked=self.accept)) buttons_layout.addWidget( QPushButton("Don't Send", default=False, clicked=self.reject)) layout.addWidget(buttons)