def __init__(self, widget, master, attribute, minimum=0., maximum=1., step=.05, min_label=None, max_label=None, allow_absolute=False, dtype=float, callback=None, *args): super().__init__(*args) if widget: widget.layout().addWidget(self) self.allow_absolute_values = allow_absolute self.master = master self.attribute = attribute self.min = minimum self.max = maximum self.step = step self.min_label = min_label self.max_label = max_label a, b = self.master_value() layout = QHBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) if self.allow_absolute_values: SpinBox = AbsoluteRelativeSpinBox else: if dtype == float: SpinBox = QDoubleSpinBox else: SpinBox = QSpinBox if self.min_label: layout.addWidget(QLabel(self.min_label)) self.min_spin = SpinBox(value=a) self.min_spin.setSingleStep(self.step) layout.addWidget(self.min_spin) if self.max_label: layout.addWidget(QLabel(self.max_label)) self.max_spin = SpinBox(value=b) self.max_spin.setSingleStep(self.step) layout.addWidget(self.max_spin) self.set_range() self.min_spin.editingFinished.connect(self._editing_finished) self.max_spin.editingFinished.connect(self._editing_finished) if callback: self.valueChanged.connect(callback)
def __init__(self, master): QWidget.__init__(self) gui.OWComponent.__init__(self, master) self.master = master # type: OWPreprocess # Title bar. title_holder = QWidget() title_holder.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) title_holder.setStyleSheet(""" .QWidget { background: qlineargradient( x1:0 y1:0, x2:0 y2:1, stop:0 #F8F8F8, stop:1 #C8C8C8); border-bottom: 1px solid #B3B3B3; } """) self.titleArea = QHBoxLayout() self.titleArea.setContentsMargins(10, 5, 10, 5) self.titleArea.setSpacing(0) title_holder.setLayout(self.titleArea) self.title_label = QLabel(self.title) self.title_label.mouseDoubleClickEvent = self.on_toggle self.title_label.setStyleSheet('font-size: 12px; border: 2px solid red;') self.titleArea.addWidget(self.title_label) self.off_label = QLabel('[disabled]') self.off_label.setStyleSheet('color: #B0B0B0; margin-left: 5px;') self.titleArea.addWidget(self.off_label) self.off_label.hide() self.titleArea.addStretch() # Root. self.rootArea = QVBoxLayout() self.rootArea.setContentsMargins(0, 0, 0, 0) self.rootArea.setSpacing(0) self.setLayout(self.rootArea) self.rootArea.addWidget(title_holder) self.contents = QWidget() contentArea = QVBoxLayout() contentArea.setContentsMargins(15, 10, 15, 10) self.contents.setLayout(contentArea) self.rootArea.addWidget(self.contents) self.method_layout = self.Layout() self.setup_method_layout() self.contents.layout().addLayout(self.method_layout) if self.toggle_enabled: self.on_off_button = OnOffButton(enabled=self.enabled) self.on_off_button.stateChanged.connect(self.on_toggle) self.on_off_button.setContentsMargins(0, 0, 0, 0) self.titleArea.addWidget(self.on_off_button) self.display_widget()
def _add_type_box(self): form = QGridLayout() self.type_box = box = gui.radioButtonsInBox(self.controlArea, self, "svrtype", [], box="SVR Type", orientation=form) self.epsilon_radio = gui.appendRadioButton(box, "ε-SVR", addToLayout=False) self.epsilon_C_spin = gui.doubleSpin(box, self, "epsilon_C", 0.1, 512.0, 0.1, decimals=2, addToLayout=False) self.epsilon_spin = gui.doubleSpin(box, self, "epsilon", 0.1, 512.0, 0.1, decimals=2, addToLayout=False) form.addWidget(self.epsilon_radio, 0, 0, Qt.AlignLeft) form.addWidget(QLabel("Cost (C):"), 0, 1, Qt.AlignRight) form.addWidget(self.epsilon_C_spin, 0, 2) form.addWidget(QLabel("Loss epsilon (ε):"), 1, 1, Qt.AlignRight) form.addWidget(self.epsilon_spin, 1, 2) self.nu_radio = gui.appendRadioButton(box, "ν-SVR", addToLayout=False) self.nu_C_spin = gui.doubleSpin(box, self, "nu_C", 0.1, 512.0, 0.1, decimals=2, addToLayout=False) self.nu_spin = gui.doubleSpin(box, self, "nu", 0.05, 1.0, 0.05, decimals=2, addToLayout=False) form.addWidget(self.nu_radio, 2, 0, Qt.AlignLeft) form.addWidget(QLabel("Cost (C):"), 2, 1, Qt.AlignRight) form.addWidget(self.nu_C_spin, 2, 2) form.addWidget(QLabel("Complexity bound (ν):"), 3, 1, Qt.AlignRight) form.addWidget(self.nu_spin, 3, 2)
def __setupUi(self): vlayout = QVBoxLayout() vlayout.setContentsMargins(0, 0, 0, 0) top_layout = QHBoxLayout() top_layout.setContentsMargins(12, 12, 12, 12) # Top row with full text description and a large preview # image. self.__label = QLabel(self, objectName="description-label", wordWrap=True, alignment=Qt.AlignTop | Qt.AlignLeft) self.__label.setWordWrap(True) self.__label.setFixedSize(220, PREVIEW_SIZE[1]) self.__image = QSvgWidget(self, objectName="preview-image") self.__image.setFixedSize(*PREVIEW_SIZE) self.__imageFrame = DropShadowFrame(self) self.__imageFrame.setWidget(self.__image) # Path text below the description and image path_layout = QHBoxLayout() path_layout.setContentsMargins(12, 0, 12, 0) path_label = QLabel("<b>{0!s}</b>".format(self.tr("Path:")), self, objectName="path-label") self.__path = TextLabel(self, objectName="path-text") path_layout.addWidget(path_label) path_layout.addWidget(self.__path) self.__selectAction = \ QAction(self.tr("Select"), self, objectName="select-action", ) top_layout.addWidget(self.__label, 1, alignment=Qt.AlignTop | Qt.AlignLeft) top_layout.addWidget(self.__image, 1, alignment=Qt.AlignTop | Qt.AlignRight) vlayout.addLayout(top_layout) vlayout.addLayout(path_layout) # An list view with small preview icons. self.__previewList = LinearIconView(objectName="preview-list-view") self.__previewList.doubleClicked.connect(self.__onDoubleClicked) vlayout.addWidget(self.__previewList) self.setLayout(vlayout)
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, openExternalLinks=False, defaultStyleSheet="", **kwargs): kwargs.setdefault( "sizePolicy", QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)) super().__init__(parent, **kwargs) self.__openExternalLinks = openExternalLinks # type: bool self.__messages = OrderedDict() # type: Dict[Hashable, Message] #: The full (joined all messages text - rendered as html), displayed #: in a tooltip. self.__fulltext = "" #: The full text displayed in a popup. Is empty if the message is #: short self.__popuptext = "" #: Leading icon self.__iconwidget = IconWidget( sizePolicy=QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) #: Inline message text self.__textlabel = QLabel( wordWrap=False, textInteractionFlags=Qt.LinksAccessibleByMouse, openExternalLinks=self.__openExternalLinks, sizePolicy=QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum)) #: Indicator that extended contents are accessible with a click on the #: widget. self.__popupicon = QLabel( sizePolicy=QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum), text="\N{VERTICAL ELLIPSIS}", visible=False, ) self.__textlabel.linkActivated.connect(self.linkActivated) self.__textlabel.linkHovered.connect(self.linkHovered) self.setLayout(QHBoxLayout()) self.layout().setContentsMargins(2, 1, 2, 1) self.layout().setSpacing(0) self.layout().addWidget(self.__iconwidget) self.layout().addSpacing(4) self.layout().addWidget(self.__textlabel) self.layout().addWidget(self.__popupicon) self.__textlabel.setAttribute(Qt.WA_MacSmallSize) self.__defaultStyleSheet = defaultStyleSheet self.anim = QPropertyAnimation(self.__iconwidget, b"opacity") self.anim.setDuration(350) self.anim.setStartValue(1) self.anim.setKeyValueAt(0.5, 0) self.anim.setEndValue(1) self.anim.setEasingCurve(QEasingCurve.OutQuad) self.anim.setLoopCount(5)
def add_row(self): def sync_combos(): combo = self.sender() index = combo.currentIndex() model = combo.model() other = ({row_items.left_combo, row_items.right_combo} - {combo}).pop() other_index = other.currentIndex() other_model = other.model() if 0 <= index < len(combo.model()): var = model[index] if isinstance(var, str): other.setCurrentText(model[index]) elif isinstance(other_model[other_index], str): for other_var in other_model: if isinstance(other_var, Variable) \ and var.name == other_var.name \ and (type(other_var) is type(var) or (not var.is_continuous and not other_var.is_continuous)): other.setCurrentText(var.name) break self.emit_list() def get_combo(model): combo = ComboBoxSearch(self) combo.setModel(model) # We use signal activated because it is triggered only on user # interaction, not programmatically. combo.activated.connect(sync_combos) return combo row = self.layout().count() row_items = self.RowItems( QLabel("和" if row else self.pre_label), get_combo(self.model_left), QLabel(self.in_label), get_combo(self.model_right), self.get_button("×", self.on_remove_row) ) layout = QHBoxLayout() layout.setSpacing(10) self.layout().insertLayout(self.layout().count() - 1, layout) layout.addStretch(10) for item in row_items: layout.addWidget(item) self.rows.append(row_items) self._reset_buttons()
def ShowInfo(self): dialog = QDialog(self) dialog.setModal(False) dialog.setLayout(QVBoxLayout()) label = QLabel(dialog) label.setText("Ontology:\n" + self.ontology.header if self.ontology else "Ontology not loaded!") dialog.layout().addWidget(label) label = QLabel(dialog) label.setText("Annotations:\n" + self.annotations.header.replace("!", "") if self.annotations else "Annotations not loaded!") dialog.layout().addWidget(label) dialog.show()
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.api = WikipediaAPI(on_error=self.Error.api_error) self.result = None query_box = gui.hBox(self.controlArea, '查询') # Queries configuration layout = QGridLayout() layout.setSpacing(7) row = 0 self.query_edit = ListEdit(self, 'query_list', "每一行表示一个不同的查询", 100, self) layout.addWidget(QLabel('查询词:'), row, 0, 1, self.label_width) layout.addWidget(self.query_edit, row, self.label_width, 1, self.widgets_width) # Articles per query row += 1 layout.addWidget(QLabel('每次查询文章数量:'), row, 0, 1, self.label_width) slider = gui.valueSlider(query_box, self, 'articles_per_query', box='', values=[10, 30, 50, 80, 100]) layout.addWidget(slider.box, row, 1, 1, self.widgets_width) query_box.layout().addLayout(layout) self.controlArea.layout().addWidget(query_box) self.controlArea.layout().addWidget( CheckListLayout('包含的内容', self, 'text_includes', self.attributes, cols=2, callback=self.set_text_features)) self.info_box = gui.hBox(self.controlArea, '基本信息') self.result_label = gui.label(self.info_box, self, self.info_label.format(0)) self.button_box = gui.hBox(self.controlArea) self.search_button = gui.button(self.button_box, self, '查询', self.start_stop) self.search_button.setFocusPolicy(Qt.NoFocus)
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 update_legend(self, colors, labels): layout = self.legend.layout() while self.legend_items: w = self.legend_items.pop() layout.removeWidget(w) w.deleteLater() for row, (color, label) in enumerate(zip(colors, labels)): icon = QLabel() p = QPixmap(12, 12) p.fill(color) icon.setPixmap(p) label = QLabel(label) layout.addWidget(icon, row, 0) layout.addWidget(label, row, 1, alignment=Qt.AlignLeft) self.legend_items += (icon, label)
def __init__(self, flags, *args, server_type: str = 'resolwe', **kwargs): super().__init__(flags, *args, **kwargs) self.server_type: str = server_type self.cm: CredentialManager = get_credential_manager(server_type) self.setWindowTitle('Sign in') self.setFixedSize(400, 250) self.server_cb_label = QLabel('Server *') self.server_cb = QComboBox(self) self.server_cb.addItems(resapi.RESOLWE_URLS if server_type == RESOLWE_PLATFORM else [genapi.DEFAULT_URL]) self.server_cb.setEditable(True) self.username_label = QLabel('Username *') self.username_line_edit = QLineEdit(self) self.username_line_edit.setPlaceholderText('Enter correct username') self.username_line_edit.returnPressed.connect(self.sign_in) self.username_line_edit.textChanged.connect(self.handle_sign_in_btn) self.password_label = QLabel('Password *') self.password_line_edit = QLineEdit(self) self.password_line_edit.setPlaceholderText('Enter correct password') self.password_line_edit.returnPressed.connect(self.sign_in) self.password_line_edit.textChanged.connect(self.handle_sign_in_btn) self.password_line_edit.setEchoMode(QLineEdit.Password) self.sign_in_btn = QPushButton('Sign in', self) self.sign_in_btn.setDisabled(True) self.sign_in_btn.clicked.connect(self.sign_in) self.error_msg = QLabel('Unable to log in with provided credentials.') self.error_msg.setStyleSheet('color:red') self.error_msg.hide() layout = QVBoxLayout(self) layout.addWidget(self.server_cb_label) layout.addWidget(self.server_cb) layout.addWidget(self.username_label) layout.addWidget(self.username_line_edit) layout.addWidget(self.password_label) layout.addWidget(self.password_line_edit) layout.addWidget(self.error_msg) layout.addStretch() layout.addWidget(self.sign_in_btn) self.resolwe_instance = None
def __init__(self): super().__init__() self.corpus = None self.form = QGridLayout() self.method_box = box = gui.radioButtonsInBox( self.controlArea, self, "method_idx", [], box="Method", orientation=self.form, callback=self._method_changed) self.liu_hu = gui.appendRadioButton(box, "Liu Hu", addToLayout=False) self.liu_lang = gui.comboBox(None, self, 'liu_language', sendSelectedValue=True, contentsLength=10, items=self.LANG, callback=self._method_changed) self.vader = gui.appendRadioButton(box, "Vader", addToLayout=False) self.multi_sent = gui.appendRadioButton(box, "Multilingual " "sentiment", addToLayout=False) self.multi_box = gui.comboBox(None, self, 'multi_language', sendSelectedValue=True, contentsLength=10, items=[''], callback=self._method_changed) self.form.addWidget(self.liu_hu, 0, 0, Qt.AlignLeft) self.form.addWidget(QLabel("Language:"), 0, 1, Qt.AlignRight) self.form.addWidget(self.liu_lang, 0, 2, Qt.AlignRight) self.form.addWidget(self.vader, 1, 0, Qt.AlignLeft) self.form.addWidget(self.multi_sent, 2, 0, Qt.AlignLeft) self.form.addWidget(QLabel("Language:"), 2, 1, Qt.AlignRight) self.form.addWidget(self.multi_box, 2, 2, Qt.AlignRight) self.senti_dict = SentimentDictionaries() self.update_multi_box() self.senti_online = self.senti_dict.online self.check_sentiment_online() ac = gui.auto_commit(self.controlArea, self, 'autocommit', 'Commit', 'Autocommit is on') ac.layout().insertSpacing(1, 8)
def __init__(self, parent=None): super().__init__(parent) self.errorLabel = QLabel( textInteractionFlags=Qt.TextSelectableByMouse, wordWrap=True) self.errorLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.controlArea.layout().addWidget(self.errorLabel)
def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self.__snowball_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) 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)
def __init__(self): super().__init__() self.corpus = None form = QGridLayout() self.method_box = box = gui.radioButtonsInBox( self.controlArea, self, "method_idx", [], box="Method", orientation=form, callback=self._method_changed) self.liu_hu = gui.appendRadioButton(box, "Liu Hu", addToLayout=False) self.liu_lang = gui.comboBox(None, self, 'language', sendSelectedValue=True, items=self.LANG, callback=self._method_changed) self.vader = gui.appendRadioButton(box, "Vader", addToLayout=False) form.addWidget(self.liu_hu, 0, 0, Qt.AlignLeft) form.addWidget(QLabel("Language:"), 0, 1, Qt.AlignRight) form.addWidget(self.liu_lang, 0, 2, Qt.AlignRight) form.addWidget(self.vader, 1, 0, Qt.AlignLeft) ac = gui.auto_commit(self.controlArea, self, 'autocommit', 'Commit', 'Autocommit is on') ac.layout().insertSpacing(1, 8)
def _add_line(): self.query_edits.append([]) n_lines = len(self.query_edits) label_edit = gui.LineEditWFocusOut(self, self.query_changed) label_edit.setMaxLength(500000) self.query_edits[-1].append(label_edit) self.queries_box.addWidget(label_edit, n_lines, 1) query_edit = gui.LineEditWFocusOut(self, self.query_changed) query_edit.setMaxLength(500000) self.query_edits[-1].append(query_edit) self.queries_box.addWidget(query_edit, n_lines, 2) button = gui.button( None, self, label='×', flat=True, height=20, styleSheet='* {font-size: 16pt; color: silver}' '*:hover {color: black}', autoDefault=False, callback=self.remove_row) button.setMinimumSize(QSize(3, 3)) self.remove_buttons.append(button) self.queries_box.addWidget(button, n_lines, 0) for coli, kwargs in enumerate( (dict(alignment=Qt.AlignRight), dict(alignment=Qt.AlignLeft, styleSheet="color: gray"))): label = QLabel(**kwargs) self.queries_box.addWidget(label, n_lines, 3 + coli)
def __init__(self): super().__init__() info_box = gui.widgetBox(self.controlArea, "Info") self.info_label = QLabel() info_box.layout().addWidget(self.info_label) self.res = ResolweHelper() data_objects = self.res.list_data_objects(self.DATA_TYPE) descriptor_schema = self.res.get_descriptor_schema( self.DESCRIPTOR_SCHEMA) self.res_widget = ResolweDataWidget(data_objects, descriptor_schema) self.res_widget.view.selectionModel().selectionChanged.connect( self.commit) self.res_widget.set_target_column(self.res_widget.header.target) self.__assign_delegates() self.udpdate_info_box() self.mainArea.layout().addWidget(self.res_widget) self.controlArea.layout().addStretch(10) gui.auto_commit(self.controlArea, self, "auto_commit", "&Commit") print(os.environ.get('RESOLWE_HOST_URL')) print(os.environ.get('RESOLWE_API_USERNAME')) print(os.environ.get('RESOLWE_API_PASSWORD'))
def __init__(self): OWWidget.__init__(self) ConcurrentWidgetMixin.__init__(self) # self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) self.vc = cv.VideoCapture(0) self.vc.set(3, 640) # set width self.vc.set(4, 480) # set height self.image_label = QLabel() # self.image_label.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored) self.controlArea.layout().addWidget(self.image_label) # self.resize(pixmap.width(), pixmap.height()) # # self.frame_timer = QTimer() # self.frame_timer.timeout.connect(self.update_frame) # self.frame_timer.start(0) # # self.output_timer = QTimer() # self.output_timer.timeout.connect(self.commit) # self.output_timer.start(0) # self.current_frame = None self.start(self.worker) self.setBlocking(False)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setFocusPolicy(Qt.TabFocus) vlayout = QVBoxLayout(spacing=0) vlayout.setContentsMargins(0, 0, 0, 0) self.__currentIndex = -1 self.__contents = QLabel( sizePolicy=QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)) vlayout.addWidget(self.__contents) hlayout = QHBoxLayout(spacing=0) hlayout.setContentsMargins(0, 0, 0, 0) self.__items = items = [ FancyWelcomeScreen.StartItem(objectName="item"), FancyWelcomeScreen.StartItem(objectName="item"), FancyWelcomeScreen.StartItem(objectName="item"), ] items[0].setProperty("-position", QStyleOptionViewItem.Beginning) items[1].setProperty("-position", QStyleOptionViewItem.Middle) items[-1].setProperty("-position", QStyleOptionViewItem.End) for item in items: hlayout.addWidget(item) vlayout.addLayout(hlayout) self.setLayout(vlayout) self.setCurrentIndex(0)
def init_form(self): self._layout = QHBoxLayout() self._combo = QComboBox(self.form) if self._label is not None: self._combolabel = QLabel(self.form) self._layout.addWidget(self._combolabel) self._combolabel.setAccessibleName('ControlCombo-label') self.label = self._label else: self._combolabel = None self._layout.addWidget(self._combo) self.form.setLayout(self._layout) self._combo.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self._layout.setContentsMargins(0, 0, 0, 0) self.form.setContentsMargins(0, 0, 0, 0) self.form.setMinimumHeight(38) self.form.setMaximumHeight(38) self.form.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) self._combo.currentIndexChanged.connect(self._currentIndexChanged) self._combo.activated.connect(self._activated) self._combo.highlighted.connect(self._highlighted) self._combo.editTextChanged.connect(self._editTextChanged) self._items = {} self._addingItem = False
def test_dock_standalone(self): widget = QWidget() layout = QHBoxLayout() widget.setLayout(layout) layout.addStretch(1) widget.show() dock = CollapsibleDockWidget() layout.addWidget(dock) list_view = QListView() list_view.setModel(QStringListModel(["a", "b"], list_view)) label = QLabel("A label. ") label.setWordWrap(True) dock.setExpandedWidget(label) dock.setCollapsedWidget(list_view) dock.setExpanded(True) self.app.processEvents() def toogle(): dock.setExpanded(not dock.expanded()) self.singleShot(2000, toogle) toogle() self.app.exec_()
def test_dock_standalone(self): widget = QWidget() layout = QHBoxLayout() widget.setLayout(layout) layout.addStretch(1) widget.show() dock = CollapsibleDockWidget() layout.addWidget(dock) list_view = QListView() list_view.setModel(QStringListModel(["a", "b"], list_view)) label = QLabel("A label. ") label.setWordWrap(True) dock.setExpandedWidget(label) dock.setCollapsedWidget(list_view) dock.setExpanded(True) dock.setExpanded(False) timer = QTimer(dock, interval=50) timer.timeout.connect(lambda: dock.setExpanded(not dock.expanded())) timer.start() self.qWait() timer.stop()
def __init__(self): super().__init__() self.cap = None self.snapshot_flash = 0 self.IMAGE_DIR = tempfile.mkdtemp(prefix='Orange-WebcamCapture-') self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) box = self.controlArea image = self.imageLabel = QLabel(margin=0, alignment=Qt.AlignCenter, sizePolicy=QSizePolicy( QSizePolicy.Ignored, QSizePolicy.Ignored)) box.layout().addWidget(image, 100) self.name_edit = line_edit = gui.lineEdit(box, self, 'image_title', 'Title:', orientation=Qt.Horizontal) line_edit.setPlaceholderText(self.DEFAULT_TITLE) hbox = gui.hBox(box) gui.checkBox(hbox, self, 'avatar_filter', 'Avatar filter') button = self.capture_button = QPushButton('Capture', self, clicked=self.capture_image) hbox.layout().addWidget(button, 1000) box.layout().addWidget(hbox) timer = QTimer(self, interval=40) timer.timeout.connect(self.update_webcam_image) timer.start()
def _add_line(): self.line_edits.append([]) n_lines = len(self.line_edits) for coli in range(1, 3): edit = QLineEdit() self.line_edits[-1].append(edit) self.rules_box.addWidget(edit, n_lines, coli) edit.textChanged.connect(self.sync_edit) button = gui.button(None, self, label='×', flat=True, height=20, styleSheet='* {font-size: 16pt; color: silver}' '*:hover {color: black}', autoDefault=False, callback=self.remove_row) button.setMinimumSize(QSize(12, 20)) self.remove_buttons.append(button) self.rules_box.addWidget(button, n_lines, 0) self.counts.append([]) for coli, kwargs in enumerate((dict(alignment=Qt.AlignRight), dict(alignment=Qt.AlignLeft, styleSheet="color: gray"))): label = QLabel(**kwargs) self.counts[-1].append(label) self.rules_box.addWidget(label, n_lines, 3 + coli)
def __init__(self, *args, headingText="", **kwargs): super().__init__(*args, **kwargs) self.setLayout(QVBoxLayout()) self.__top_label = QLabel(headingText, visible=bool(headingText), objectName="-top-heading-text") self.__top_label.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) self.__model = model = encodings_model() self.__model.setParent(self) self.__view = view = EncodingsView( self, uniformItemSizes=True, editTriggers=QListView.NoEditTriggers) self.__view.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred) view.setModel(model) self.layout().addWidget(self.__top_label) self.layout().addWidget(view) buttons = QDialogButtonBox( standardButtons=QDialogButtonBox.RestoreDefaults) b = buttons.addButton("Select all", QDialogButtonBox.ActionRole) b.clicked.connect(self.selectAll) b = buttons.button(QDialogButtonBox.RestoreDefaults) b.clicked.connect(self.reset) self.layout().addWidget(buttons) self.setAttribute(Qt.WA_MacSmallSize)
def add_main_layout(self): form = QFormLayout() form.setFieldGrowthPolicy(form.AllNonFixedFieldsGrow) form.setVerticalSpacing(25) gui.widgetBox(self.controlArea, True, orientation=form) form.addRow( "Neurons in hidden layers:", gui.lineEdit( None, self, "hidden_layers_input", orientation=Qt.Horizontal, callback=self.settings_changed, tooltip="A list of integers defining neurons. Length of list " "defines the number of layers. E.g. 4, 2, 2, 3.", placeholderText="e.g. 100,")) form.addRow( "Activation:", gui.comboBox(None, self, "activation_index", orientation=Qt.Horizontal, label="Activation:", items=[i for i in self.act_lbl], callback=self.settings_changed)) form.addRow(" ", gui.separator(None, 16)) form.addRow( "Solver:", gui.comboBox(None, self, "solver_index", orientation=Qt.Horizontal, label="Solver:", items=[i for i in self.solv_lbl], callback=self.settings_changed)) self.reg_label = QLabel() slider = gui.hSlider(None, self, "alpha_index", minValue=0, maxValue=len(self.alphas) - 1, callback=lambda: (self.set_alpha(), self.settings_changed()), createLabel=False) form.addRow(self.reg_label, slider) self.set_alpha() form.addRow( "Maximal number of iterations:", gui.spin(None, self, "max_iterations", 10, 10000, step=10, label="Max iterations:", orientation=Qt.Horizontal, alignment=Qt.AlignRight, callback=self.settings_changed))
def __init__(self): super().__init__() self.data = None self._invalidated = False # List of available preprocessors (DescriptionRole : Description) self.preprocessors = QStandardItemModel() def mimeData(indexlist): assert len(indexlist) == 1 index = indexlist[0] qname = index.data(DescriptionRole).qualname m = QMimeData() m.setData("application/x-qwidget-ref", qname.encode("utf-8")) return m # TODO: Fix this (subclass even if just to pass a function # for mimeData delegate) self.preprocessors.mimeData = mimeData box = gui.vBox(self.controlArea, "Preprocessors") self.preprocessorsView = view = QListView( selectionMode=QListView.SingleSelection, dragEnabled=True, dragDropMode=QListView.DragOnly) view.setModel(self.preprocessors) view.activated.connect(self.__activated) box.layout().addWidget(view) #### self._qname2ppdef = {ppdef.qualname: ppdef for ppdef in PREPROCESSORS} # List of 'selected' preprocessors and their parameters. self.preprocessormodel = None self.flow_view = SequenceFlow() self.controler = Controller(self.flow_view, parent=self) self.overlay = OverlayWidget(self) self.overlay.setAttribute(Qt.WA_TransparentForMouseEvents) self.overlay.setWidget(self.flow_view) self.overlay.setLayout(QVBoxLayout()) self.overlay.layout().addWidget( QLabel("Drag items from the list on the left", wordWrap=True)) self.scroll_area = QScrollArea( verticalScrollBarPolicy=Qt.ScrollBarAlwaysOn) self.scroll_area.viewport().setAcceptDrops(True) self.scroll_area.setWidget(self.flow_view) self.scroll_area.setWidgetResizable(True) self.mainArea.layout().addWidget(self.scroll_area) self.flow_view.installEventFilter(self) box = gui.vBox(self.controlArea, "Output") gui.auto_commit(box, self, "autocommit", "Send", box=False) self._initialize()
def __init__(self, widget, master, attribute, label, margin=(0, 0, 0, 0), display_format=QT_DATE_FORMAT, min_date=None, max_date=None, calendar_popup=True): super().__init__() self.master = master self.attribute = attribute hb = hBox(widget) hb.layout().setContentsMargins(*margin) hb.layout().addWidget(QLabel(label)) hb.layout().addWidget(self) self.setCalendarPopup(calendar_popup) self.setDisplayFormat(display_format) self.setDate(self.to_qdate(getattr(master, attribute))) if min_date: self.setMinimumDate(self.to_qdate(min_date)) if max_date: self.setMaximumDate(self.to_qdate(max_date)) self.dateChanged.connect(self.synchronize)
def __init__(self, parent=None): super(FileUploadHelper, self).__init__( parent, Qt.Window | Qt.WindowTitleHint | Qt.CustomizeWindowHint | Qt.WindowCloseButtonHint | Qt.WindowMaximizeButtonHint) self.setAttribute(Qt.WA_DeleteOnClose) self.setWindowTitle('Add new file') self.info_state = INFO_FILE_SCHEMA self.layout = QVBoxLayout(self) # domain selection combobox self.domain_selection = QComboBox() self.domain_selection.addItems(self.supported_domains.keys()) self.domain_selection.currentIndexChanged.connect( self.__on_domain_selection) self.__create_selection_row('Domain: ', self.domain_selection) # domain selection combobox self.hierarchy_selection = QComboBox() self.hierarchy_selection.addItems(self.hierarchies.keys()) self.layout.addWidget(self.hierarchy_selection, alignment=Qt.AlignVCenter) self.__on_domain_selection() # select organism self.organism_selection = QComboBox() self.organism_selection.addItems(self.supported_organisms) self.__create_selection_row('Organism: ', self.organism_selection) # title self.line_edit_title = QLineEdit() self.__create_selection_row('Title: ', self.line_edit_title) # tags self.line_edit_tags = QLineEdit() self.__create_selection_row('Tags (comma-separated): ', self.line_edit_tags) # file selector self.file_info = QLabel() self.file_select_btn = QPushButton('Select File', self) self.file_select_btn.clicked.connect(self.__handle_file_selector) self.__create_selection_row(' ', self.file_select_btn) # add file info section self.layout.addWidget(self.file_info, alignment=Qt.AlignCenter) self.layout.addStretch(1) # Ok and Cancel buttons self.buttons = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self) self.layout.addWidget(self.buttons, alignment=Qt.AlignJustify) self.buttons.accepted.connect(self.__accept) self.buttons.rejected.connect(self.__close) # path to a selected file self.file_path = None