def __init__(self): super().__init__() self.corpus = None self.learning_thread = None # Commit button gui.auto_commit(self.buttonsArea, self, 'autocommit', 'Commit', box=False) button_group = QButtonGroup(self, exclusive=True) button_group.buttonClicked[int].connect(self.change_method) self.widgets = [] method_layout = QVBoxLayout() self.controlArea.layout().addLayout(method_layout) for i, (method, attr_name) in enumerate(self.methods): widget = method(self, title='Options') widget.setFixedWidth(self.control_area_width) widget.valueChanged.connect(self.commit) self.widgets.append(widget) setattr(self, attr_name, widget) rb = QRadioButton(text=widget.Model.name) button_group.addButton(rb, i) method_layout.addWidget(rb) method_layout.addWidget(widget) button_group.button(self.method_index).setChecked(True) self.toggle_widgets() method_layout.addStretch() # Topics description self.topic_desc = TopicViewer() self.topic_desc.topicSelected.connect(self.send_topic_by_id) self.mainArea.layout().addWidget(self.topic_desc) self.topic_desc.setFocus()
def create_configuration_layout(self): layout = QVBoxLayout() rbtns = gui.radioButtons(None, self, "method", callback=self.on_change) layout.addWidget(rbtns) gui.appendRadioButton(rbtns, "Multilingual SBERT") gui.appendRadioButton(rbtns, "fastText:") ibox = gui.indentedBox(rbtns) self.language_cb = gui.comboBox( ibox, self, "language", items=LANGUAGES, label="Language:", sendSelectedValue=True, # value is actual string not index orientation=Qt.Horizontal, callback=self.on_change, searchable=True, ) self.aggregator_cb = gui.comboBox( ibox, self, "aggregator", items=AGGREGATORS, label="Aggregator:", sendSelectedValue=True, # value is actual string not index orientation=Qt.Horizontal, callback=self.on_change, searchable=True, ) return layout
def __init__(self, parent): QFrame.__init__(self, parent) self.setContentsMargins(0, 0, 0, 0) layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(1) self._setNameLineEdit = QLineEdit(self) layout.addWidget(self._setNameLineEdit) self._setListView = QListView(self) self._listModel = QStandardItemModel(self) self._proxyModel = QSortFilterProxyModel(self) self._proxyModel.setSourceModel(self._listModel) self._setListView.setModel(self._proxyModel) self._setListView.setItemDelegate(ListItemDelegate(self)) self._setNameLineEdit.textChanged.connect( self._proxyModel.setFilterFixedString) self._completer = QCompleter(self._listModel, self) self._setNameLineEdit.setCompleter(self._completer) self._listModel.itemChanged.connect(self._onSetNameChange) layout.addWidget(self._setListView) buttonLayout = QHBoxLayout() self._addAction = QAction( "+", self, toolTip="Add a new sort key") self._updateAction = QAction( "Update", self, toolTip="Update/save current selection") self._removeAction = QAction( "\u2212", self, toolTip="Remove selected sort key.") self._addToolButton = QToolButton(self) self._updateToolButton = QToolButton(self) self._removeToolButton = QToolButton(self) self._updateToolButton.setSizePolicy( QSizePolicy.MinimumExpanding, QSizePolicy.Minimum) self._addToolButton.setDefaultAction(self._addAction) self._updateToolButton.setDefaultAction(self._updateAction) self._removeToolButton.setDefaultAction(self._removeAction) buttonLayout.addWidget(self._addToolButton) buttonLayout.addWidget(self._updateToolButton) buttonLayout.addWidget(self._removeToolButton) layout.addLayout(buttonLayout) self.setLayout(layout) self._addAction.triggered.connect(self.addCurrentSelection) self._updateAction.triggered.connect(self.updateSelectedSelection) self._removeAction.triggered.connect(self.removeSelectedSelection) self._setListView.selectionModel().selectionChanged.connect( self._onListViewSelectionChanged) self.selectionModel = None self._selections = []
def __setupUi(self): layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) view = QTreeView(objectName="tool-tree-view") view.setUniformRowHeights(True) view.setFrameStyle(QTreeView.NoFrame) view.setModel(self.__model) view.setRootIsDecorated(False) view.setHeaderHidden(True) view.setItemsExpandable(True) view.setEditTriggers(QTreeView.NoEditTriggers) view.setItemDelegate(ToolTreeItemDelegate(self)) view.activated.connect(self.__onActivated) view.clicked.connect(self.__onActivated) view.entered.connect(self.__onEntered) view.installEventFilter(self) self.__view = view layout.addWidget(view) self.setLayout(layout)
def __init__(self, parent=None, **kwargs): # type: (Optional[QWidget], Any) -> None super().__init__(parent, **kwargs) self.setWindowFlags(self.windowFlags() | Qt.Popup) layout = QVBoxLayout() layout.setContentsMargins(6, 6, 6, 6) self.__menu = MenuPage() self.__menu.setActionRole(QtWidgetRegistry.WIDGET_ACTION_ROLE) if sys.platform == "darwin": self.__menu.view().setAttribute(Qt.WA_MacShowFocusRect, False) self.__menu.triggered.connect(self.__onTriggered) self.__menu.hovered.connect(self.hovered) self.__dragListener = ItemViewDragStartEventListener(self) self.__dragListener.dragStarted.connect(self.__onDragStarted) self.__menu.view().viewport().installEventFilter(self.__dragListener) self.__menu.view().installEventFilter(self) layout.addWidget(self.__menu) self.setLayout(layout) self.__action = None # type: Optional[QAction] self.__loop = None # type: Optional[QEventLoop]
def __setupUi(self): layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) self.toolbox = WidgetToolBox() self.help = QuickHelpWidget(objectName="quick-help") self.__splitter = QSplitter() self.__splitter.setOrientation(Qt.Vertical) self.__splitter.addWidget(self.toolbox) self.__splitter.addWidget(self.help) self.toolbar = DynamicResizeToolBar() self.toolbar.setMovable(False) self.toolbar.setFloatable(False) self.toolbar.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred) layout.addWidget(self.__splitter, 10) layout.addWidget(self.toolbar) self.setLayout(layout) self.__splitterResizer = SplitterResizer(self) self.__splitterResizer.setSplitterAndWidget(self.__splitter, self.help)
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._form = QWidget() layout = QVBoxLayout() if _api.USED_API == _api.QT_API_PYQT5: layout.setContentsMargins(0, 0, 0, 0) elif _api.USED_API == _api.QT_API_PYQT4: layout.setMargin(0) self._form.setLayout(layout) self._app = vv.use('pyqt5') self._app.Create() self._first = True Figure = self._app.GetFigureClass() self._fig = Figure(self._form) vv.figure(self._fig.nr) policy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) widget = self._fig._widget widget.setSizePolicy(policy) widget.setMinimumSize(100, 100) layout.addWidget(widget) self._colorMap = vv.CM_AUTUMN self._colors_limits = None super(ControlVisVisVolume, self).init_form()
def initUI(self): "Create the GUI layout to be used in the tests." log.info("Initialising the UI") self.setWindowTitle(self.app_title) ## Create all necessary widgets ## Short alternate names make configuration simpler. ## Buttons self.button_bar = QDialogButtonBox.Ok | QDialogButtonBox.Cancel self.button_box = QDialogButtonBox(self.button_bar) ## Bring all the HBoxes together in a VBox vbox = QVBoxLayout() self.grid = self.form.render() vbox.addLayout(self.grid) vbox.addWidget(self.button_box) ## Connect UI signals to slots self.button_box.accepted.connect(self.accept) self.button_box.rejected.connect(self.reject) ## Establish the window layout self.setLayout(vbox) ## Set pints.components to desired initial state ## tb.setEnabled(False) ## sn.setEnabled(False) self.setGeometry(300, 300, 300, 250)
def __init__(self, master: Union[QWidget, None], settings: Dict[str, Dict[str, SettingsType]]): super().__init__(master, windowTitle="Visual Settings") self.__controls: Dict[KeyType, Tuple[QWidget, ValueType]] = {} self.__changed_settings: Dict[KeyType, ValueType] = {} self.setting_changed.connect(self.__on_setting_changed) layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout) self.main_box = gui.vBox(self, box=None) # type: QWidget buttons = QDialogButtonBox( orientation=Qt.Horizontal, standardButtons=QDialogButtonBox.Close | QDialogButtonBox.Reset, ) closeButton = buttons.button(QDialogButtonBox.Close) closeButton.clicked.connect(self.close) resetButton = buttons.button(QDialogButtonBox.Reset) resetButton.clicked.connect(self.__reset) resetButton.setAutoDefault(False) layout.addWidget(buttons) self.__initialize(settings)
def __init__(self, parent=None, **kwargs): # type: (Optional[QWidget], Any) -> None super().__init__(parent, **kwargs) self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Expanding) self.__model = QStandardItemModel() # type: QAbstractItemModel self.__flattened = False self.__actionRole = Qt.UserRole layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) view = QTreeView(objectName="tool-tree-view") view.setUniformRowHeights(True) view.setFrameStyle(QTreeView.NoFrame) view.setModel(self.__model) view.setRootIsDecorated(False) view.setHeaderHidden(True) view.setItemsExpandable(True) view.setEditTriggers(QTreeView.NoEditTriggers) view.activated.connect(self.__onActivated) view.clicked.connect(self.__onActivated) view.entered.connect(self.__onEntered) view.installEventFilter(self) self.__view = view # type: QTreeView layout.addWidget(view) self.setLayout(layout)
def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self.setWindowFlags(self.windowFlags() | Qt.Popup) layout = QVBoxLayout() layout.setContentsMargins(6, 6, 6, 6) self.__menu = MenuPage() self.__menu.setActionRole(QtWidgetRegistry.WIDGET_ACTION_ROLE) if sys.platform == "darwin": self.__menu.view().setAttribute(Qt.WA_MacShowFocusRect, False) self.__menu.triggered.connect(self.__onTriggered) self.__menu.hovered.connect(self.hovered) self.__dragListener = ItemViewDragStartEventListener(self) self.__dragListener.dragStarted.connect(self.__onDragStarted) self.__menu.view().viewport().installEventFilter(self.__dragListener) layout.addWidget(self.__menu) self.setLayout(layout) self.__action = None self.__loop = None self.__item = None
def __setupUi(self): layout = QVBoxLayout() # Scene with the link editor. self.scene = LinksEditScene() self.view = QGraphicsView(self.scene) self.view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.view.setRenderHint(QPainter.Antialiasing) self.scene.editWidget.geometryChanged.connect(self.__onGeometryChanged) # Ok/Cancel/Clear All buttons. buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel | QDialogButtonBox.Reset, Qt.Horizontal) clear_button = buttons.button(QDialogButtonBox.Reset) clear_button.setText(self.tr("Clear All")) buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject) clear_button.clicked.connect(self.scene.editWidget.clearLinks) layout.addWidget(self.view) layout.addWidget(buttons) self.setLayout(layout) layout.setSizeConstraint(QVBoxLayout.SetFixedSize) self.setSizeGripEnabled(False)
def init_form(self): vlayout = QVBoxLayout() if _api.USED_API == _api.QT_API_PYQT5: vlayout.setContentsMargins(0, 0, 0, 0) elif _api.USED_API == _api.QT_API_PYQT4: vlayout.setMargin(0) self.setLayout(vlayout) self._scroll = QScrollBar(QtCore.Qt.Horizontal) scrollarea = QScrollArea() scrollarea.setMinimumHeight(140) scrollarea.setWidgetResizable(True) self._events_widget = EventsWidget(scroll=self._scroll) scrollarea.setWidget(self._events_widget) self._scroll.actionTriggered.connect(self.__scroll_changed) vlayout.addWidget(scrollarea) # The timeline widget vlayout.addWidget(self._scroll) # Add scroll self._scroll.setMaximum(0) self._scroll.setSliderPosition(0)
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, tree, dataset, master, parent=None): QWidget.__init__(self, parent) Control.__init__(self, tree, dataset, master) self.setLayout(QHBoxLayout()) self.cb = QComboBox(self) self.layout().addWidget(self.cb) rblayout = QVBoxLayout() self.radioButtons = [ QRadioButton("Only", self), QRadioButton("Excluded", self) ] for b in self.radioButtons: rblayout.addWidget(b) self.radioButtons[0].setChecked(True) self.layout().addLayout(rblayout) self.options = [] self.setOptions(tree.subelements_top("Option"))
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 __setupUi(self): vlayout = QVBoxLayout() vlayout.setContentsMargins(0, 0, 0, 0) top_layout = QVBoxLayout(objectName="top-layout") margin = self.__margin top_layout.setContentsMargins(margin, margin, margin, margin) # Optional heading label self.__heading = QLabel( self, objectName="heading", visible=False ) # Horizontal row with full text description and a large preview # image. hlayout = QHBoxLayout() hlayout.setContentsMargins(0, 0, 0, 0) 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.__label.setMinimumWidth(PREVIEW_SIZE[0] // 2) self.__label.setMaximumHeight(PREVIEW_SIZE[1]) self.__image = QSvgWidget(self, objectName="preview-image") self.__image.setFixedSize(*PREVIEW_SIZE) self.__imageFrame = DropShadowFrame(self) self.__imageFrame.setWidget(self.__image) hlayout.addWidget(self.__label) hlayout.addWidget(self.__image) # Path text below the description and image path_layout = QHBoxLayout() path_layout.setContentsMargins(0, 0, 0, 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) top_layout.addWidget(self.__heading) top_layout.addLayout(hlayout) top_layout.addLayout(path_layout) vlayout.addLayout(top_layout) # An list view with small preview icons. self.__previewList = LinearIconView( objectName="preview-list-view", wordWrap=True ) 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 _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 __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 __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]) inst = None # type: Optional[Installable] if res is not None: inst = installable_from_json_response(res) else: inst = None return _QueryResult(queryname=name, installable=inst) 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, parent=None): super().__init__(parent=parent) self.__stack: List = [] self.__stack_index: int = -1 def push_on_data_changed(_, __, roles): if Qt.EditRole in roles: self._push_data() self.__model = QStandardItemModel() self.__model.dataChanged.connect(self.dataChanged) self.__model.dataChanged.connect(push_on_data_changed) self.__root: QStandardItem = self.__model.invisibleRootItem() self.__tree = TreeView(self.dataChanged) self.__tree.drop_finished.connect(self.dataChanged) self.__tree.drop_finished.connect(self._push_data) self.__tree.setModel(self.__model) self.__tree.selectionModel().selectionChanged.connect( self.selectionChanged) actions_widget = ModelActionsWidget() actions_widget.layout().setSpacing(1) action = QAction("+", self, toolTip="Add a new word") action.triggered.connect(self.__on_add) actions_widget.addAction(action) action = QAction("\N{MINUS SIGN}", self, toolTip="Remove word") action.triggered.connect(self.__on_remove) actions_widget.addAction(action) action = QAction("\N{MINUS SIGN}R", self, toolTip="Remove word recursively (incl. children)") action.triggered.connect(self.__on_remove_recursive) actions_widget.addAction(action) gui.rubber(actions_widget) self.__undo_action = action = QAction("Undo", self, toolTip="Undo") action.triggered.connect(self.__on_undo) actions_widget.addAction(action) self.__redo_action = action = QAction("Redo", self, toolTip="Redo") action.triggered.connect(self.__on_redo) actions_widget.addAction(action) self._enable_undo_redo() layout = QVBoxLayout() layout.setSpacing(1) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.__tree) layout.addWidget(actions_widget) self.setLayout(layout)
def init_form(self): self._fig = Figure((5.0, 4.0), dpi=100) self.canvas = FigureCanvas(self._fig) self.canvas.setParent(self) self.mpl_toolbar = NavigationToolbar(self.canvas, self) vbox = QVBoxLayout() vbox.addWidget(self.canvas) vbox.addWidget(self.mpl_toolbar) self.setLayout(vbox)
def __init__(self, parent=None): super().__init__(parent) self.corpus = None self.initial_ngram_range = None # initial range of input corpus — used for inplace self.preprocessor = preprocess.Preprocessor() # -- INFO -- info_box = gui.widgetBox(self.controlArea, 'Info') info_box.setFixedWidth(self.control_area_width) self.controlArea.layout().addStretch() self.info_label = gui.label(info_box, self, '') self.update_info() # -- PIPELINE -- frame = QFrame() frame.setContentsMargins(0, 0, 0, 0) frame.setFrameStyle(QFrame.Box) frame.setStyleSheet('.QFrame { border: 1px solid #B3B3B3; }') frame_layout = QVBoxLayout() frame_layout.setContentsMargins(0, 0, 0, 0) frame_layout.setSpacing(0) frame.setLayout(frame_layout) self.stages = [] for stage in self.preprocessors: widget = stage(self) self.stages.append(widget) setattr(self, stage.attribute, widget) frame_layout.addWidget(widget) widget.change_signal.connect(self.settings_invalidated) frame_layout.addStretch() self.scroll = QScrollArea() self.scroll.setWidget(frame) self.scroll.setWidgetResizable(True) self.scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.scroll.resize(frame_layout.sizeHint()) self.scroll.setMinimumHeight(500) self.set_minimal_width() self.mainArea.layout().sizeHint() self.mainArea.layout().addWidget(self.scroll) # Buttons area self.report_button.setFixedWidth(self.control_area_width) commit_button = gui.auto_commit(self.buttonsArea, self, 'autocommit', 'Commit', box=False) commit_button.setFixedWidth(self.control_area_width) self.buttonsArea.layout().addWidget(commit_button)
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 __init__(self, owwidget, ax, varmodel): QWidget.__init__(self, owwidget) gui.OWComponent.__init__(self) self.ax = ax self.view = view = QListView( self, selectionMode=QTreeWidget.ExtendedSelection, ) view.setModel(varmodel) selection = view.selectionModel() selection.selectionChanged.connect(self.selection_changed) box = QVBoxLayout(self) box.setContentsMargins(0, 0, 0, 0) self.setLayout(box) hbox = gui.hBox(self) gui.comboBox( hbox, self, "plot_type", label="类型:", orientation="horizontal", items=("线", "折线", "柱", "面积", "样条曲线"), sendSelectedValue=True, callback=lambda: self.sigType.emit(ax, self.plot_types[self. plot_type]), ) gui.rubber(hbox) self.button_close = button = QPushButton( "×", hbox, visible=False, minimumSize=QSize(20, 20), maximumSize=QSize(20, 20), styleSheet=""" QPushButton { font-weight: bold; font-size:14pt; margin:0; padding:0; }""", ) button.clicked.connect(lambda: self.sigClosed.emit(ax, self)) hbox.layout().addWidget(button) gui.checkBox( self, self, "is_logarithmic", "对数轴", callback=lambda: self.sigLogarithmic.emit(ax, self.is_logarithmic), ) box.addWidget(view)
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_form(self): self._fig = Figure((5.0, 4.0), dpi=100) self.canvas = FigureCanvas(self._fig) self.canvas.setParent(self) self.mpl_toolbar = NavigationToolbar(self.canvas, self) vbox = QVBoxLayout() vbox.addWidget(self.canvas) vbox.addWidget(self.mpl_toolbar) vbox.setContentsMargins(QMargins(0, 0, 0, 0)) self.setLayout(vbox) super(ControlMatplotlib, self).init_form()
class TaskParametersGUIConfirmDialog(QDialog): def __init__(self, parent, label): super().__init__(parent) self.setWindowTitle('Confirmation') QBtn = QDialogButtonBox.Yes | QDialogButtonBox.No self.buttonBox = QDialogButtonBox(QBtn) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) self.layout = QVBoxLayout() message = QLabel(label) self.layout.addWidget(message) self.layout.addWidget(self.buttonBox) self.setLayout(self.layout)
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 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 _setup_gui_values(self): vlayout = QVBoxLayout() vlayout.setContentsMargins(0, 0, 0, 0) vlayout.setSpacing(1) 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_edit.selectionModel().selectionChanged.connect( self.on_value_selection_changed) self.values_model.dataChanged.connect(self.on_values_changed) vlayout.addWidget(self.values_edit) hlayout = QHBoxLayout() hlayout.setContentsMargins(0, 0, 0, 0) hlayout.setSpacing(1) self.move_value_up = QAction(unicodedata.lookup("UPWARDS ARROW"), self, toolTip="Move up.", triggered=self.move_up, enabled=False, shortcut=QKeySequence(QKeySequence.New)) self.move_value_down = QAction(unicodedata.lookup("DOWNWARDS ARROW"), self, toolTip="Move down.", triggered=self.move_down, 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.move_value_up) hlayout.addWidget(button) button = QToolButton(self) button.setFixedSize(button_size) button.setDefaultAction(self.move_value_down) hlayout.addWidget(button) hlayout.addStretch(10) vlayout.addLayout(hlayout) self.main_form.addRow("Values:", vlayout)
def __init__(self, parent=None): super().__init__(parent) self.corpus = None self.initial_ngram_range = None # initial range of input corpus — used for inplace self.preprocessor = preprocess.Preprocessor() # -- INFO -- info_box = gui.widgetBox(self.controlArea, 'Info') info_box.setFixedWidth(self.control_area_width) self.controlArea.layout().addStretch() self.info_label = gui.label(info_box, self, '') self.update_info() # -- PIPELINE -- frame = QFrame() frame.setContentsMargins(0, 0, 0, 0) frame.setFrameStyle(QFrame.Box) frame.setStyleSheet('.QFrame { border: 1px solid #B3B3B3; }') frame_layout = QVBoxLayout() frame_layout.setContentsMargins(0, 0, 0, 0) frame_layout.setSpacing(0) frame.setLayout(frame_layout) self.stages = [] for stage in self.preprocessors: widget = stage(self) self.stages.append(widget) setattr(self, stage.attribute, widget) frame_layout.addWidget(widget) widget.change_signal.connect(self.settings_invalidated) frame_layout.addStretch() self.scroll = QScrollArea() self.scroll.setWidget(frame) self.scroll.setWidgetResizable(True) self.scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.scroll.resize(frame_layout.sizeHint()) self.scroll.setMinimumHeight(500) self.set_minimal_width() self.mainArea.layout().addWidget(self.scroll) # Buttons area self.report_button.setFixedWidth(self.control_area_width) commit_button = gui.auto_commit(self.buttonsArea, self, 'autocommit', 'Commit', box=False) commit_button.setFixedWidth(self.control_area_width - 5) self.buttonsArea.layout().addWidget(commit_button)
def __init__(self): super().__init__() ConcurrentWidgetMixin.__init__(self) self.corpus = None self.learning_thread = None self.__pending_selection = self.selection self.perplexity = "n/a" self.coherence = "n/a" # Commit button gui.auto_commit(self.buttonsArea, self, 'autocommit', 'Commit', box=False) button_group = QButtonGroup(self, exclusive=True) button_group.buttonClicked[int].connect(self.change_method) self.widgets = [] method_layout = QVBoxLayout() self.controlArea.layout().addLayout(method_layout) for i, (method, attr_name) in enumerate(self.methods): widget = method(self, title='Options') widget.setFixedWidth(self.control_area_width) widget.valueChanged.connect(self.commit.deferred) self.widgets.append(widget) setattr(self, attr_name, widget) rb = QRadioButton(text=widget.Model.name) button_group.addButton(rb, i) method_layout.addWidget(rb) method_layout.addWidget(widget) button_group.button(self.method_index).setChecked(True) self.toggle_widgets() method_layout.addStretch() box = gui.vBox(self.controlArea, "Topic evaluation") gui.label(box, self, "Log perplexity: %(perplexity)s") gui.label(box, self, "Topic coherence: %(coherence)s") self.controlArea.layout().insertWidget(1, box) # Topics description self.topic_desc = TopicViewer() self.topic_desc.topicSelected.connect(self.send_topic_by_id) self.mainArea.layout().addWidget(self.topic_desc) self.topic_desc.setFocus()
def __init__(self, owwidget, ax, varmodel): QWidget.__init__(self, owwidget) gui.OWComponent.__init__(self) self.ax = ax self.view = view = QListView( self, selectionMode=QTreeWidget.ExtendedSelection, ) view.setModel(varmodel) selection = view.selectionModel() selection.selectionChanged.connect(self.selection_changed) box = QVBoxLayout(self) box.setContentsMargins(0, 0, 0, 0) self.setLayout(box) hbox = gui.hBox(self) gui.comboBox(hbox, self, 'plot_type', label='Type:', orientation='horizontal', items=('line', 'step line', 'column', 'area', 'spline'), sendSelectedValue=True, callback=lambda: self.sigType.emit(ax, self.plot_type)) gui.rubber(hbox) self.button_close = button = QPushButton('×', hbox, visible=False, minimumSize=QSize(20, 20), maximumSize=QSize(20, 20), styleSheet=''' QPushButton { font-weight: bold; font-size:14pt; margin:0; padding:0; }''') button.clicked.connect(lambda: self.sigClosed.emit(ax, self)) hbox.layout().addWidget(button) gui.checkBox( self, self, "is_logarithmic", "Logarithmic axis", callback=self.on_logarithmic, ) box.addWidget(view)
def __init__(self, parent=None, **kwargs): # type: (Optional[QWidget], Any)-> None super().__init__(parent, **kwargs) self.__pages = [] # type: List[_ToolBoxPage] self.__tabButtonHeight = -1 self.__tabIconSize = QSize() self.__exclusive = False layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) # Scroll area for the contents. self.__scrollArea = QScrollArea( self, objectName="toolbox-scroll-area", sizePolicy=QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding), horizontalScrollBarPolicy=Qt.ScrollBarAlwaysOff, widgetResizable=True, ) sb = ScrollBar() sb.styleChange.connect(self.updateGeometry) self.__scrollArea.setVerticalScrollBar(sb) self.__scrollArea.setFrameStyle(QScrollArea.NoFrame) # A widget with all of the contents. # The tabs/contents are placed in the layout inside this widget self.__contents = QWidget(self.__scrollArea, objectName="toolbox-contents") self.__contentsLayout = _ToolBoxLayout( sizeConstraint=_ToolBoxLayout.SetMinAndMaxSize, spacing=0) self.__contentsLayout.setContentsMargins(0, 0, 0, 0) self.__contents.setLayout(self.__contentsLayout) self.__scrollArea.setWidget(self.__contents) layout.addWidget(self.__scrollArea) self.setLayout(layout) self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.MinimumExpanding) self.__tabActionGroup = QActionGroup( self, objectName="toolbox-tab-action-group", ) self.__tabActionGroup.setExclusive(self.__exclusive) self.__actionMapper = QSignalMapper(self) self.__actionMapper.mapped[QObject].connect(self.__onTabActionToggled)
def init_form(self): plt.ion() self._fig = Figure() self._ax = self._fig.add_subplot(111) self._img = self._ax.imshow(np.zeros([512, 512])) self._canvas = FigureCanvas(self._fig) self._canvas.setParent(self) self._mpl_toolbar = NavigationToolbar(self._canvas, self) self._cb = self._fig.colorbar(self._img) self._cb.formatter.set_useOffset(False) self._cb.update_ticks() vbox = QVBoxLayout() vbox.addWidget(self._canvas) vbox.addWidget(self._mpl_toolbar) self.setLayout(vbox) self.on_draw()
def __setupUi(self): layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) # Scroll area for the contents. self.__scrollArea = \ _ToolBoxScrollArea(self, objectName="toolbox-scroll-area") self.__scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.__scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.__scrollArea.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) self.__scrollArea.setFrameStyle(QScrollArea.NoFrame) self.__scrollArea.setWidgetResizable(True) # A widget with all of the contents. # The tabs/contents are placed in the layout inside this widget self.__contents = QWidget(self.__scrollArea, objectName="toolbox-contents") # The layout where all the tab/pages are placed self.__contentsLayout = QVBoxLayout() self.__contentsLayout.setContentsMargins(0, 0, 0, 0) self.__contentsLayout.setSizeConstraint(QVBoxLayout.SetMinAndMaxSize) self.__contentsLayout.setSpacing(0) self.__contents.setLayout(self.__contentsLayout) self.__scrollArea.setWidget(self.__contents) layout.addWidget(self.__scrollArea) self.setLayout(layout) self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.MinimumExpanding) self.__tabActionGroup = \ QActionGroup(self, objectName="toolbox-tab-action-group") self.__tabActionGroup.setExclusive(self.__exclusive) self.__actionMapper = QSignalMapper(self) self.__actionMapper.mapped[QObject].connect(self.__onTabActionToogled)
def __init__(self, parent=None, **kwargs): BaseEditor.__init__(self, parent, **kwargs) self.__method = DiscretizeEditor.EqualFreq self.__nintervals = 4 layout = QVBoxLayout() self.setLayout(layout) self.__group = group = QButtonGroup(self, exclusive=True) for method in [self.EntropyMDL, self.EqualFreq, self.EqualWidth, self.Drop]: rb = QRadioButton( self, text=self.Names[method], checked=self.__method == method ) layout.addWidget(rb) group.addButton(rb, method) group.buttonClicked.connect(self.__on_buttonClicked) self.__slbox = slbox = QGroupBox( title="Number of intervals (for equal width/frequency)", flat=True ) slbox.setLayout(QHBoxLayout()) self.__slider = slider = QSlider( orientation=Qt.Horizontal, minimum=2, maximum=10, value=self.__nintervals, enabled=self.__method in [self.EqualFreq, self.EqualWidth], pageStep=1, tickPosition=QSlider.TicksBelow ) slider.valueChanged.connect(self.__on_valueChanged) slbox.layout().addWidget(slider) self.__slabel = slabel = QLabel() slbox.layout().addWidget(slabel) container = QHBoxLayout() container.setContentsMargins(13, 0, 0, 0) container.addWidget(slbox) self.layout().insertLayout(3, container) self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
def __setupUi(self): layout = QVBoxLayout() label = QLabel(self) pixmap, _ = config.splash_screen() label.setPixmap(pixmap) layout.addWidget(label, Qt.AlignCenter) name = QApplication.applicationName() version = QApplication.applicationVersion() text = ABOUT_TEMPLATE.format( name=escape(name), version=escape(version), ) # TODO: Also list all known add-on versions??. text_label = QLabel(text) layout.addWidget(text_label, Qt.AlignCenter) buttons = QDialogButtonBox( QDialogButtonBox.Close, Qt.Horizontal, self) layout.addWidget(buttons) buttons.rejected.connect(self.accept) layout.setSizeConstraint(QVBoxLayout.SetFixedSize) self.setLayout(layout)
def __setupUi(self): layout = QVBoxLayout() label = QLabel(self) pixmap, _ = config.splash_screen() label.setPixmap(pixmap) layout.addWidget(label, Qt.AlignCenter) try: from Orange.version import version from Orange.version import git_revision except ImportError: dist = pkg_resources.get_distribution("Orange3") version = dist.version git_revision = "Unknown" text = ABOUT_TEMPLATE.format(version=version, git_revision=git_revision[:7]) # TODO: Also list all known add-on versions. text_label = QLabel(text) layout.addWidget(text_label, Qt.AlignCenter) buttons = QDialogButtonBox(QDialogButtonBox.Close, Qt.Horizontal, self) layout.addWidget(buttons) buttons.rejected.connect(self.accept) layout.setSizeConstraint(QVBoxLayout.SetFixedSize) self.setLayout(layout)
def __init__(self, owwidget, ax, varmodel): QWidget.__init__(self, owwidget) gui.OWComponent.__init__(self) self.ax = ax self.view = view = QListView(self, selectionMode=QTreeWidget.ExtendedSelection,) view.setModel(varmodel) selection = view.selectionModel() selection.selectionChanged.connect(self.selection_changed) box = QVBoxLayout(self) box.setContentsMargins(0, 0, 0, 0) self.setLayout(box) hbox = gui.hBox(self) gui.comboBox(hbox, self, 'plot_type', label='Type:', orientation='horizontal', items=('line', 'step line', 'column', 'area', 'spline'), sendSelectedValue=True, callback=lambda: self.sigType.emit(ax, self.plot_type)) gui.rubber(hbox) self.button_close = button = QPushButton('×', hbox, visible=False, minimumSize=QSize(20, 20), maximumSize=QSize(20, 20), styleSheet=''' QPushButton { font-weight: bold; font-size:14pt; margin:0; padding:0; }''') button.clicked.connect(lambda: self.sigClosed.emit(ax, self)) hbox.layout().addWidget(button) gui.checkBox(self, self, 'is_logarithmic', 'Logarithmic axis', callback=lambda: self.sigLogarithmic.emit(ax, self.is_logarithmic)) box.addWidget(view)
def __init__(self, tree, dataset, master, parent=None): QWidget.__init__(self, parent) Control.__init__(self, tree, dataset, master) self.setLayout(QHBoxLayout()) self.cb = QComboBox(self) self.layout().addWidget(self.cb) rblayout = QVBoxLayout() self.radioButtons = [QRadioButton("Only", self), QRadioButton("Excluded", self) ] for b in self.radioButtons: rblayout.addWidget(b) self.radioButtons[0].setChecked(True) self.layout().addLayout(rblayout) self.options = [] self.setOptions(tree.subelements_top("Option"))
def __setupUi(self): layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) self.setContentsMargins(0, 0, 0, 0) heading = self.tr("Preview") heading = "<h3>{0}</h3>".format(heading) self.__heading = QLabel(heading, self, objectName="heading") self.__heading.setContentsMargins(12, 12, 12, 0) self.__browser = previewbrowser.PreviewBrowser(self) self.__buttons = QDialogButtonBox(QDialogButtonBox.Open | \ QDialogButtonBox.Cancel, Qt.Horizontal,) self.__buttons.button(QDialogButtonBox.Open).setAutoDefault(True) # Set the Open dialog as disabled until the current index changes self.__buttons.button(QDialogButtonBox.Open).setEnabled(False) # The QDialogButtonsWidget messes with the layout if it is # contained directly in the QDialog. So we create an extra # layer of indirection. buttons = QWidget(objectName="button-container") buttons_l = QVBoxLayout() buttons_l.setContentsMargins(12, 0, 12, 12) buttons.setLayout(buttons_l) buttons_l.addWidget(self.__buttons) layout.addWidget(self.__heading) layout.addWidget(self.__browser) layout.addWidget(buttons) self.__buttons.accepted.connect(self.accept) self.__buttons.rejected.connect(self.reject) self.__browser.currentIndexChanged.connect( self.__on_currentIndexChanged ) self.__browser.activated.connect(self.__on_activated) layout.setSizeConstraint(QVBoxLayout.SetFixedSize) self.setLayout(layout) self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
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 __init__(self): super().__init__() self.data = None self.editors = {} box = gui.vBox(self.controlArea, "Variable Definitions") toplayout = QHBoxLayout() toplayout.setContentsMargins(0, 0, 0, 0) box.layout().addLayout(toplayout) self.editorstack = QStackedWidget( sizePolicy=QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) ) for descclass, editorclass in self.EDITORS: editor = editorclass() editor.featureChanged.connect(self._on_modified) self.editors[descclass] = editor self.editorstack.addWidget(editor) self.editorstack.setEnabled(False) buttonlayout = QVBoxLayout(spacing=10) buttonlayout.setContentsMargins(0, 0, 0, 0) self.addbutton = QPushButton( "New", toolTip="Create a new variable", minimumWidth=120, shortcut=QKeySequence.New ) def unique_name(fmt, reserved): candidates = (fmt.format(i) for i in count(1)) return next(c for c in candidates if c not in reserved) def reserved_names(): varnames = [] if self.data is not None: varnames = [var.name for var in self.data.domain.variables + self.data.domain.metas] varnames += [desc.name for desc in self.featuremodel] return set(varnames) def generate_newname(fmt): return unique_name(fmt, reserved_names()) menu = QMenu(self.addbutton) cont = menu.addAction("Numeric") cont.triggered.connect( lambda: self.addFeature( ContinuousDescriptor(generate_newname("X{}"), "", 3)) ) disc = menu.addAction("Categorical") disc.triggered.connect( lambda: self.addFeature( DiscreteDescriptor(generate_newname("D{}"), "", ("A", "B"), -1, False)) ) string = menu.addAction("Text") string.triggered.connect( lambda: self.addFeature( StringDescriptor(generate_newname("S{}"), "")) ) menu.addSeparator() self.duplicateaction = menu.addAction("Duplicate Selected Variable") self.duplicateaction.triggered.connect(self.duplicateFeature) self.duplicateaction.setEnabled(False) self.addbutton.setMenu(menu) self.removebutton = QPushButton( "Remove", toolTip="Remove selected variable", minimumWidth=120, shortcut=QKeySequence.Delete ) self.removebutton.clicked.connect(self.removeSelectedFeature) buttonlayout.addWidget(self.addbutton) buttonlayout.addWidget(self.removebutton) buttonlayout.addStretch(10) toplayout.addLayout(buttonlayout, 0) toplayout.addWidget(self.editorstack, 10) # Layout for the list view layout = QVBoxLayout(spacing=1, margin=0) self.featuremodel = DescriptorModel(parent=self) self.featureview = QListView( minimumWidth=200, sizePolicy=QSizePolicy(QSizePolicy.Minimum, QSizePolicy.MinimumExpanding) ) self.featureview.setItemDelegate(FeatureItemDelegate(self)) self.featureview.setModel(self.featuremodel) self.featureview.selectionModel().selectionChanged.connect( self._on_selectedVariableChanged ) layout.addWidget(self.featureview) box.layout().addLayout(layout, 1) box = gui.hBox(self.controlArea) gui.rubber(box) commit = gui.button(box, self, "Send", callback=self.apply, default=True) commit.setMinimumWidth(180)
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__() main_layout = QVBoxLayout() main_layout.setContentsMargins(10, 10, 10, 10) self.controlArea.layout().addLayout(main_layout) box = QGroupBox(title=self.tr("Default Method"), flat=False) box_layout = QVBoxLayout(box) main_layout.addWidget(box) button_group = QButtonGroup() button_group.buttonClicked[int].connect(self.set_default_method) for i, method in enumerate(self.METHODS): if not method.columns_only: button = QRadioButton(method.name) button.setChecked(i == self.default_method_index) button_group.addButton(button, i) box_layout.addWidget(button) self.default_button_group = button_group box = QGroupBox(title=self.tr("Individual Attribute Settings"), flat=False) main_layout.addWidget(box) horizontal_layout = QHBoxLayout(box) main_layout.addWidget(box) self.varview = QListView( selectionMode=QListView.ExtendedSelection ) self.varview.setItemDelegate(DisplayFormatDelegate()) self.varmodel = itemmodels.VariableListModel() self.varview.setModel(self.varmodel) self.varview.selectionModel().selectionChanged.connect( self._on_var_selection_changed ) self.selection = self.varview.selectionModel() horizontal_layout.addWidget(self.varview) method_layout = QVBoxLayout() horizontal_layout.addLayout(method_layout) button_group = QButtonGroup() for i, method in enumerate(self.METHODS): button = QRadioButton(text=method.name) button_group.addButton(button, i) method_layout.addWidget(button) self.value_combo = QComboBox( minimumContentsLength=8, sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLength, activated=self._on_value_selected ) self.value_combo.currentIndexChanged.connect(self._on_value_changed) self.value_double = QDoubleSpinBox( editingFinished=self._on_value_selected, minimum=-1000., maximum=1000., singleStep=.1, decimals=3, value=self.default_value ) self.value_stack = value_stack = QStackedLayout() value_stack.addWidget(self.value_combo) value_stack.addWidget(self.value_double) method_layout.addLayout(value_stack) button_group.buttonClicked[int].connect( self.set_method_for_current_selection ) method_layout.addStretch(2) reset_button = QPushButton( "Restore All to Default", checked=False, checkable=False, clicked=self.reset_variable_methods, default=False, autoDefault=False) method_layout.addWidget(reset_button) self.variable_button_group = button_group box = gui.auto_commit( self.controlArea, self, "autocommit", "Apply", orientation=Qt.Horizontal, checkbox_label="Apply automatically") box.layout().insertSpacing(0, 80) box.layout().insertWidget(0, self.report_button) self.data = None self.modified = False self.default_method = self.METHODS[self.default_method_index] self.update_varview()
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)
class PreprocessorModule(gui.OWComponent, QWidget): """The base widget for the pre-processing modules.""" change_signal = pyqtSignal() # Emitted when the settings are changed. title = NotImplemented attribute = NotImplemented methods = NotImplemented single_method = True toggle_enabled = True enabled = settings.Setting(True) disabled_value = None Layout = QGridLayout def __init__(self, master): QWidget.__init__(self) gui.OWComponent.__init__(self, master) self.master = master # 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() @staticmethod def get_tooltip(method): return ' '.join([l.strip() for l in method.__doc__.split('\n')]).strip('.') \ if method.__doc__ else None @staticmethod def textify(text): return text.replace('&', '&&') @property def value(self): if self.enabled: return self.get_value() return self.disabled_value def setup_method_layout(self): raise NotImplementedError def on_toggle(self, event=None): # Activated when the widget is enabled/disabled. self.enabled = not self.enabled self.display_widget() self.update_value() def display_widget(self): if self.enabled: self.off_label.hide() self.contents.show() self.title_label.setStyleSheet('color: #000000;') else: self.off_label.show() self.contents.hide() self.title_label.setStyleSheet('color: #B0B0B0;') def get_value(self): raise NotImplemented def update_value(self): self.change_signal.emit()
def __init__(self, *args): QWidget.__init__(self, *args) self.setContentsMargins(0, 0, 0, 0) gridLayout = QGridLayout() gridLayout.setContentsMargins(0, 0, 0, 0) gridLayout.setSpacing(1) model = QStandardItemModel(self) model.rowsInserted.connect(self.__changed) model.rowsRemoved.connect(self.__changed) model.dataChanged.connect(self.__changed) self._listView = QListView(self) self._listView.setModel(model) # self._listView.setDragEnabled(True) self._listView.setDropIndicatorShown(True) self._listView.setDragDropMode(QListView.InternalMove) self._listView.viewport().setAcceptDrops(True) self._listView.setMinimumHeight(100) gridLayout.addWidget(self._listView, 0, 0, 2, 2) vButtonLayout = QVBoxLayout() self._upAction = QAction( "\u2191", self, toolTip="Move up") self._upButton = QToolButton(self) self._upButton.setDefaultAction(self._upAction) self._upButton.setSizePolicy( QSizePolicy.Fixed, QSizePolicy.MinimumExpanding) self._downAction = QAction( "\u2193", self, toolTip="Move down") self._downButton = QToolButton(self) self._downButton.setDefaultAction(self._downAction) self._downButton.setSizePolicy( QSizePolicy.Fixed, QSizePolicy.MinimumExpanding) vButtonLayout.addWidget(self._upButton) vButtonLayout.addWidget(self._downButton) gridLayout.addLayout(vButtonLayout, 0, 2, 2, 1) hButtonLayout = QHBoxLayout() self._addAction = QAction("+", self) self._addButton = QToolButton(self) self._addButton.setDefaultAction(self._addAction) self._removeAction = QAction("-", self) self._removeButton = QToolButton(self) self._removeButton.setDefaultAction(self._removeAction) hButtonLayout.addWidget(self._addButton) hButtonLayout.addWidget(self._removeButton) hButtonLayout.addStretch(10) gridLayout.addLayout(hButtonLayout, 2, 0, 1, 2) self.setLayout(gridLayout) self._addAction.triggered.connect(self._onAddAction) self._removeAction.triggered.connect(self._onRemoveAction) self._upAction.triggered.connect(self._onUpAction) self._downAction.triggered.connect(self._onDownAction)
def __init__(self): super().__init__() self.data = None # type: Optional[Orange.data.Table] self.learner = None # type: Optional[Learner] self.default_learner = SimpleTreeLearner() self.modified = False self.executor = qconcurrent.ThreadExecutor(self) self.__task = None main_layout = QVBoxLayout() main_layout.setContentsMargins(10, 10, 10, 10) self.controlArea.layout().addLayout(main_layout) box = QGroupBox(title=self.tr("Default Method"), flat=False) box_layout = QVBoxLayout(box) main_layout.addWidget(box) button_group = QButtonGroup() button_group.buttonClicked[int].connect(self.set_default_method) for method, _ in list(METHODS.items())[1:-1]: imputer = self.create_imputer(method) button = QRadioButton(imputer.name) button.setChecked(method == self.default_method_index) button_group.addButton(button, method) box_layout.addWidget(button) self.default_button_group = button_group box = QGroupBox(title=self.tr("Individual Attribute Settings"), flat=False) main_layout.addWidget(box) horizontal_layout = QHBoxLayout(box) main_layout.addWidget(box) self.varview = QListView( selectionMode=QListView.ExtendedSelection, uniformItemSizes=True ) self.varview.setItemDelegate(DisplayFormatDelegate()) self.varmodel = itemmodels.VariableListModel() self.varview.setModel(self.varmodel) self.varview.selectionModel().selectionChanged.connect( self._on_var_selection_changed ) self.selection = self.varview.selectionModel() horizontal_layout.addWidget(self.varview) method_layout = QVBoxLayout() horizontal_layout.addLayout(method_layout) button_group = QButtonGroup() for method in Method: imputer = self.create_imputer(method) button = QRadioButton(text=imputer.name) button_group.addButton(button, method) method_layout.addWidget(button) self.value_combo = QComboBox( minimumContentsLength=8, sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLength, activated=self._on_value_selected ) self.value_double = QDoubleSpinBox( editingFinished=self._on_value_selected, minimum=-1000., maximum=1000., singleStep=.1, decimals=3, ) self.value_stack = value_stack = QStackedWidget() value_stack.addWidget(self.value_combo) value_stack.addWidget(self.value_double) method_layout.addWidget(value_stack) button_group.buttonClicked[int].connect( self.set_method_for_current_selection ) method_layout.addStretch(2) reset_button = QPushButton( "Restore All to Default", checked=False, checkable=False, clicked=self.reset_variable_state, default=False, autoDefault=False) method_layout.addWidget(reset_button) self.variable_button_group = button_group box = gui.auto_commit( self.controlArea, self, "autocommit", "Apply", orientation=Qt.Horizontal, checkbox_label="Apply automatically") box.button.setFixedWidth(180) box.layout().insertStretch(0)
def __init__(self, parent): QWidget.__init__(self) OWComponent.__init__(self, parent) SelectionGroupMixin.__init__(self) ImageColorSettingMixin.__init__(self) self.parent = parent self.selection_type = SELECTMANY self.saving_enabled = True self.selection_enabled = True self.viewtype = INDIVIDUAL # required bt InteractiveViewBox self.highlighted = None self.data_points = None self.data_imagepixels = None self.plotview = pg.PlotWidget(background="w", viewBox=InteractiveViewBox(self)) self.plot = self.plotview.getPlotItem() self.plot.scene().installEventFilter( HelpEventDelegate(self.help_event, self)) layout = QVBoxLayout() self.setLayout(layout) self.layout().setContentsMargins(0, 0, 0, 0) self.layout().addWidget(self.plotview) self.img = ImageItemNan() self.img.setOpts(axisOrder='row-major') self.plot.addItem(self.img) self.plot.scene().sigMouseMoved.connect(self.plot.vb.mouseMovedEvent) layout = QGridLayout() self.plotview.setLayout(layout) self.button = QPushButton("Menu", self.plotview) self.button.setAutoDefault(False) layout.setRowStretch(1, 1) layout.setColumnStretch(1, 1) layout.addWidget(self.button, 0, 0) view_menu = MenuFocus(self) self.button.setMenu(view_menu) # prepare interface according to the new context self.parent.contextAboutToBeOpened.connect(lambda x: self.init_interface_data(x[0])) self.add_zoom_actions(view_menu) common_options = dict( labelWidth=50, orientation=Qt.Horizontal, sendSelectedValue=True, valueType=str) choose_xy = QWidgetAction(self) box = gui.vBox(self) box.setFocusPolicy(Qt.TabFocus) self.xy_model = DomainModel(DomainModel.METAS | DomainModel.CLASSES, valid_types=DomainModel.PRIMITIVE, placeholder="Position (index)") self.cb_attr_x = gui.comboBox( box, self, "attr_x", label="Axis x:", callback=self.update_attr, model=self.xy_model, **common_options) box.setFocusProxy(self.cb_attr_x) box.layout().addWidget(self.color_settings_box()) choose_xy.setDefaultWidget(box) view_menu.addAction(choose_xy) self.lsx = None # info about the X axis self.lsy = None # info about the Y axis self.data = None self.data_ids = {}
def __init__(self, parent=None, filename=None): super(MainForm, self).__init__(parent) self.view = GraphicsView() background = QPixmap(filename) # assume screnshots were taken on the same system stamper is being used on # DPI check might be more robust, can be added if needed background.setDevicePixelRatio(self.devicePixelRatioF()) self.filename = os.path.splitext(filename)[0] if ("-%s" % ORG) in self.filename: self.filename = self.filename[:-len(ORG)-5] + ".png" # self.view.setBackgroundBrush(QBrush(background)) # self.view.setCacheMode(QGraphicsView.CacheBackground) # self.view.setDragMode(QGraphicsView.ScrollHandDrag) self.scene = QGraphicsScene(self) self.scene.addPixmap(background) global scene scene = self.scene self.view.dialog = self self.view.setScene(self.scene) self.prevPoint = QPoint() self.lastStamp = -1 buttonLayout = QVBoxLayout() for text, slot in ( ("&Tag", self.addTag), ("Align &bottom", self.alignBottom), ("Align &left", self.alignLeft), ("&Save", self.save), ("&Quit", self.accept)): button = QPushButton(text) button.clicked.connect(slot) if not MAC: button.setFocusPolicy(Qt.NoFocus) self.lineedit.returnPressed.connect(self.updateUi) if text == "&Save": buttonLayout.addStretch(5) if text == "&Quit": buttonLayout.addStretch(1) buttonLayout.addWidget(button) buttonLayout.addStretch() size = background.size() / background.devicePixelRatioF() self.view.resize(size.width(), size.height()) self.scene.setSceneRect(0, 0, size.width(), size.height()) self.view.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) layout = QHBoxLayout() layout.addWidget(self.view, 1) layout.addLayout(buttonLayout) self.setLayout(layout) self.setWindowTitle(AppName) info_name = self.filename + "-" + TAG + ".txt" if os.path.exists(info_name): for tag, x, y in [line.strip().split("\t") for line in open(info_name, "rt").readlines()]: self.addTag(int(tag), QPointF(int(x), int(y)), adjust_position=False) global Dirty; Dirty=False self.show() self.raise_()