def init_ui(self): self.textFrame = QFrame(self) self.hTextLayout = QHBoxLayout(self.textFrame) self.hTextLayout.setContentsMargins(10, 0, 10, 0) self.hTextLayout.setAlignment(Qt.AlignVCenter | Qt.AlignLeft) self.label = ElideLabel(self.textFrame) self.hTextLayout.addWidget(self.label) self.popupFrame = QFrame(self.parent) self.popupFrame.setObjectName("PComboBoxPopup") self.lsWidget = PListWidget(self.parent) self.hPopuplayout = QHBoxLayout(self.popupFrame) self.hPopuplayout.setContentsMargins(0, 0, 0, 0) self.hPopuplayout.addWidget(self.lsWidget) self.popupFrame.hide() self.lsWidget.currentTextChanged.connect(self.set_current_text) self.lsWidget.itemClicked.connect(self.hide_popup) self.lsWidget.focusOut.connect(self.hide_popup) self.setFocusProxy(self.lsWidget) self.set_font(QFont("Arial", 14)) self.set_border_radius(self.border_radius)
def __init__(self, *, gpc, gui_vars): super().__init__(Qt.Horizontal) # Global processing classes self.gpc = gpc # Global GUI variables (used for control of GUI state) self.gui_vars = gui_vars self.frame_left = QFrame(self) self.frame_left.setFrameShape(QFrame.StyledPanel) self.frame_right = QFrame(self) self.frame_right.setFrameShape(QFrame.StyledPanel) self.addWidget(self.frame_left) self.addWidget(self.frame_right) hbox = QHBoxLayout() self.left_panel = LeftPanel(gpc=self.gpc, gui_vars=self.gui_vars) hbox.addWidget(self.left_panel) self.frame_left.setLayout(hbox) hbox = QHBoxLayout() self.right_panel = RightPanel(gpc=self.gpc, gui_vars=self.gui_vars) hbox.addWidget(self.right_panel) self.frame_right.setLayout(hbox) self._show_first_time = True # Set stretch factor of the left panel to 0 (we want it to keep its width # as the window is resized. The panel can still be resized manually self.setStretchFactor(0, 0) # Set stretch factor for the right panel to some non-zero value, e.g. 1 self.setStretchFactor(1, 1)
def __init__(self, parent=None, **kwargs): super(PCDSSymbolBase, self).__init__(parent=parent, **kwargs) self._expert_display = None self.interlock = None self._channels_prefix = None self._rotate_icon = False self._show_icon = True self._show_status_tooltip = True self._icon_size = -1 self._icon = None self._expert_ophyd_class = self.EXPERT_OPHYD_CLASS or "" self.interlock = QFrame(self) self.interlock.setObjectName("interlock") self.interlock.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.controls_frame = QFrame(self) self.controls_frame.setObjectName("controls") self.controls_frame.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) self.setLayout(QVBoxLayout()) self.layout().setSpacing(0) self.layout().setContentsMargins(0, 0, 0, 0) self.layout().addWidget(self.interlock) if not hasattr(self, '_controls_location'): self._controls_location = ContentLocation.Bottom self.setup_icon() self.assemble_layout() self.update_status_tooltip()
def add_image(self, image, label): w = QFrame() w.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken) w.setLineWidth(2) w.setFixedSize(QSize(500, 500)) w.setLayout(QVBoxLayout()) gv = ScrollableGraphicsLayoutWidget() vb = ViewBox(lockAspect=True) ii = ActivatableImageItem(image=image) ii.sigActivated.connect(self.set_current_imageitem) self.hist_widget.item.setImageItem(ii) self.current_image_item = ii self.image_items.append(ii) self.views.append(vb) vb.sigRangeChangedManually.connect(self.propagate_axes) vb.addItem(ii) gv.addItem(vb) self.set_current_imageitem(ii) w.layout().addWidget(gv) l = QLabel(label) # l.setStyleSheet("color: white;") w.layout().addWidget(l) self.flow_layout.addWidget(w) self.last_vb = vb
def _create_buttons(self) -> QFrame: """ Creates buttons for the bottom of the dialog box, one for opening the output folder, and one for closing the dialog box Params: None Returns: (QFrame): A QFrame that has two horizontally laid out buttons, first button is Open output directory, second button is close. """ buttons: QFrame = QFrame() buttons.setLayout(QHBoxLayout()) self.run_sweep_button = QPushButton("Start Sweep") self.run_sweep_button.setToolTip( "Start sweep using the selected napari layer as the input image.") self.run_sweep_button.clicked.connect(self._run_sweep) self.run_sweep_button.setAutoDefault(False) close_button: QPushButton = QPushButton("Cancel") close_button.setToolTip("Cancel an active parameter sweep.") close_button.clicked.connect(self.cancel) close_button.setAutoDefault(False) buttons.layout().addWidget(self.run_sweep_button) buttons.layout().addWidget(close_button) return buttons
def __init__(self, parent): QWidget.__init__(self, parent) vert_layout = QVBoxLayout() # Type frame type_layout = QHBoxLayout() type_label = QLabel(_("Import as")) type_layout.addWidget(type_label) self.array_btn = array_btn = QRadioButton(_("array")) array_btn.setEnabled(ndarray is not FakeObject) array_btn.setChecked(ndarray is not FakeObject) type_layout.addWidget(array_btn) list_btn = QRadioButton(_("list")) list_btn.setChecked(not array_btn.isChecked()) type_layout.addWidget(list_btn) if pd: self.df_btn = df_btn = QRadioButton(_("DataFrame")) df_btn.setChecked(False) type_layout.addWidget(df_btn) h_spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) type_layout.addItem(h_spacer) type_frame = QFrame() type_frame.setLayout(type_layout) self._table_view = PreviewTable(self) vert_layout.addWidget(type_frame) vert_layout.addWidget(self._table_view) self.setLayout(vert_layout)
def __init__(self, parent: Optional[QWidget] = None, prog: progress = None) -> None: super().__init__(parent) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.progress = prog self.qt_progress_bar = QProgressBar() self.description_label = QLabel() self.eta_label = QLabel() base_layout = QVBoxLayout() pbar_layout = QHBoxLayout() pbar_layout.addWidget(self.description_label) pbar_layout.addWidget(self.qt_progress_bar) pbar_layout.addWidget(self.eta_label) base_layout.addLayout(pbar_layout) line = QFrame(self) line.setObjectName("QtCustomTitleBarLine") line.setFixedHeight(1) base_layout.addWidget(line) self.setLayout(base_layout)
def __init__(self, wintitle): super(Window, self).__init__() self.default_tool = None self.plots = [] self.itemlist = PlotItemList(None) self.contrast = ContrastAdjustment(None) self.xcsw = XCrossSection(None) self.ycsw = YCrossSection(None) self.manager = PlotManager(self) self.toolbar = QToolBar(_("Tools"), self) self.manager.add_toolbar(self.toolbar, "default") self.toolbar.setMovable(True) self.toolbar.setFloatable(True) self.addToolBar(Qt.TopToolBarArea, self.toolbar) frame = QFrame(self) self.setCentralWidget(frame) self.layout = QGridLayout() layout = QVBoxLayout(frame) frame.setLayout(layout) layout.addLayout(self.layout) self.frame = frame self.setWindowTitle(wintitle) self.setWindowIcon(get_icon("guiqwt.svg"))
def __init__(self, parent=None, show=True, off_screen=True): MainWindow.__init__(self, parent) self.frame = QFrame() vlayout = QVBoxLayout() self.vtk_widget = QtInteractor( parent=self.frame, off_screen=off_screen, stereo=False, ) vlayout.addWidget(self.vtk_widget.interactor) self.frame.setLayout(vlayout) self.setCentralWidget(self.frame) mainMenu = _create_menu_bar(parent=self) fileMenu = mainMenu.addMenu('File') self.exit_action = QAction('Exit', self) self.exit_action.setShortcut('Ctrl+Q') self.exit_action.triggered.connect(self.close) fileMenu.addAction(self.exit_action) meshMenu = mainMenu.addMenu('Mesh') self.add_sphere_action = QAction('Add Sphere', self) self.exit_action.setShortcut('Ctrl+A') self.add_sphere_action.triggered.connect(self.add_sphere) meshMenu.addAction(self.add_sphere_action) self.signal_close.connect(self.vtk_widget.close) if show: self.show()
def setup_ui(self): #create layout self._layout = QVBoxLayout() self.setLayout(self._layout) #give it a title lbl_title = QLabel("Infrastructure Monitoring System\n Building View") lbl_title.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Maximum) lbl_title.setMaximumHeight(35) lbl_title.setStyleSheet("\ QLabel {\ qproperty-alignment: AlignCenter;\ border: 1px solid #FF17365D;\ border-top-left-radius: 15px;\ border-top-right-radius: 15px;\ background-color: #FF17365D;\ padding: 5px 0px;\ color: rgb(255, 255, 255);\ max-height: 35px;\ font-size: 14px;\ }") self._layout.addWidget(lbl_title) self._layout.addStretch(1) self.frame = QFrame() self.frame.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Minimum) self.frame.setMinimumHeight(500) self.view = GraphicsView() self.view.setMouseTracking(True) self._layout.addWidget(self.view)
def __init__(self, parent=None): QDialog.__init__( self, parent, Qt.WindowStaysOnTopHint | Qt.X11BypassWindowManagerHint | Qt.FramelessWindowHint) self.setVisible(False) self.filter_items = {} layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) frame = QFrame() frame.setFrameStyle(QFrame.StyledPanel | QFrame.Raised) layout.addWidget(frame) self.__layout = QVBoxLayout() self.__layout.setSizeConstraint(QLayout.SetFixedSize) self.__layout.addWidget(QLabel("Filter by data type:")) self.addFilterItem("Summary", "summary") # self.addFilterItem("Block", "block") self.addFilterItem("Gen KW", "gen_kw") self.addFilterItem("Gen Data", "gen_data") self.addFilterItem("Custom KW", "custom_kw") # self.addFilterItem("Custom PCA", "custom_pca") frame.setLayout(self.__layout) self.setLayout(layout) self.adjustSize()
def __init__(self, item, parent_layout): super(TabGroupWidget, self).__init__(item, parent_layout) self.tabs = QTabWidget() items = item.item.group self.widgets = [] for item in items: if item.get_prop_value("display", parent_layout.instance, "hide", False): continue item.set_prop("display", embedded=True) widget = parent_layout.build_widget(item) frame = QFrame() label = widget.item.get_prop_value("display", "label") icon = widget.item.get_prop_value("display", "icon", None) if icon is not None: self.tabs.addTab(frame, get_icon(icon), label) else: self.tabs.addTab(frame, label) layout = QGridLayout() layout.setAlignment(Qt.AlignTop) frame.setLayout(layout) widget.place_on_grid(layout, 0, 0, 1) try: widget.get() except Exception: print("Error building item :", item.item._name) raise self.widgets.append(widget)
def __init__(self, slice_direction, default_view_key: str = 'Image', xlink=None, ylink=None, parent=None): super(ViewSelector, self).__init__(parent=parent) self.slice_direction = slice_direction self.view_widget = None self._data = None self._crosshair_pos = None self.setLayout(QVBoxLayout()) self.view_frame = QFrame() self.view_frame.setLayout(QVBoxLayout()) self.layout().addWidget(self.view_frame) self.selector = QComboBox() self.selector.addItems(self.view_options.keys()) self.selector.currentTextChanged.connect(self._set_view) self.layout().addWidget(self.selector) self.xlink = xlink self.ylink = ylink self.set_view(view_key=default_view_key)
def setup_ui(self): main_layout = QVBoxLayout() self.setLayout(main_layout) lbl_title = QLabel("Motor Parameters") lbl_title.setStyleSheet("\ QLabel {\ qproperty-alignment: AlignCenter;\ max-height: 25px;\ font-size: 14px;\ }") main_layout.addWidget(lbl_title) self.results_layout = QVBoxLayout() self.results_layout.setContentsMargins(0, 0, 0, 0) # Create a Frame to host the results of search self.frm_result = QFrame(parent=self) self.frm_result.setLayout(self.results_layout) # Create a ScrollArea so we can properly handle # many entries scroll_area = QScrollArea(parent=self) scroll_area.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) scroll_area.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) scroll_area.setWidgetResizable(True) # Add the Frame to the scroll area scroll_area.setWidget(self.frm_result) # Add the scroll area to the main layout main_layout.addWidget(scroll_area)
def __init__(self, parent, key_defs): QDialog.__init__( self, parent, Qt.WindowStaysOnTopHint | Qt.X11BypassWindowManagerHint | Qt.FramelessWindowHint, ) self.setVisible(False) self.filter_items = {} layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) frame = QFrame() frame.setFrameStyle(QFrame.StyledPanel | QFrame.Raised) layout.addWidget(frame) self.__layout = QVBoxLayout() self.__layout.setSizeConstraint(QLayout.SetFixedSize) self.__layout.addWidget(QLabel("Filter by data type:")) filters = {k["metadata"]["data_origin"] for k in key_defs} for f in filters: self.addFilterItem(f, f) frame.setLayout(self.__layout) self.setLayout(layout) self.adjustSize()
def __init__(self, model, *args, **kwargs): super().__init__(*args, **kwargs) self.model = model self.setOrientation(Qt.Vertical) self._frame_1 = QFrame(self) self._frame_2 = QFrame(self) self._frame_3 = QFrame(self) self._frame_4 = QFrame(self) self.addWidget(self._frame_1) self.addWidget(self._frame_2) self.addWidget(self._frame_3) self.addWidget(self._frame_4) self._running_plan = QtReRunningPlan(model) self._running_plan.monitor_mode = True self._plan_queue = QtRePlanQueue(model) self._plan_queue.monitor_mode = True self._plan_history = QtRePlanHistory(model) self._plan_history.monitor_mode = True self._console_monitor = QtReConsoleMonitor(model) vbox = QVBoxLayout() vbox.setContentsMargins(0, 0, 0, 0) vbox.addWidget(self._running_plan) self._frame_1.setLayout(vbox) vbox = QVBoxLayout() vbox.setContentsMargins(0, 0, 0, 0) vbox.addWidget(self._plan_queue) self._frame_2.setLayout(vbox) vbox = QVBoxLayout() vbox.setContentsMargins(0, 0, 0, 0) vbox.addWidget(self._plan_history) self._frame_3.setLayout(vbox) vbox = QVBoxLayout() vbox.setContentsMargins(0, 0, 0, 0) vbox.addWidget(self._console_monitor) self._frame_4.setLayout(vbox) h = self.sizeHint().height() self.setSizes([h, 2 * h, 2 * h, h])
def __init__(self, parent: QWidget, axis: int): super().__init__(parent=parent) self.axis = axis self.qt_dims = parent self.dims = parent.dims self.axis_label = None self.slider = None self.play_button = None self.curslice_label = QLineEdit(self) self.curslice_label.setToolTip(f'Current slice for axis {axis}') # if we set the QIntValidator to actually reflect the range of the data # then an invalid (i.e. too large) index doesn't actually trigger the # editingFinished event (the user is expected to change the value)... # which is confusing to the user, so instead we use an IntValidator # that makes sure the user can only enter integers, but we do our own # value validation in change_slice self.curslice_label.setValidator(QIntValidator(0, 999999)) def change_slice(): val = int(self.curslice_label.text()) max_allowed = self.dims.max_indices[self.axis] if val > max_allowed: val = max_allowed self.curslice_label.setText(str(val)) self.curslice_label.clearFocus() self.qt_dims.setFocus() self.dims.set_point(self.axis, val) self.curslice_label.editingFinished.connect(change_slice) self.totslice_label = QLabel(self) self.totslice_label.setToolTip(f'Total slices for axis {axis}') self.curslice_label.setObjectName('slice_label') self.totslice_label.setObjectName('slice_label') sep = QFrame(self) sep.setFixedSize(1, 14) sep.setObjectName('slice_label_sep') self._fps = 10 self._minframe = None self._maxframe = None self._loop_mode = LoopMode.LOOP layout = QHBoxLayout() self._create_axis_label_widget() self._create_range_slider_widget() self._create_play_button_widget() layout.addWidget(self.axis_label) layout.addWidget(self.play_button) layout.addWidget(self.slider, stretch=1) layout.addWidget(self.curslice_label) layout.addWidget(sep) layout.addWidget(self.totslice_label) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(2) self.setLayout(layout) self.dims.events.axis_labels.connect(self._pull_label)
def __init__(self, parent: QWidget, axis: int): super().__init__(parent=parent) self.axis = axis self.qt_dims = parent self.dims = parent.dims self.axis_label = None self.slider = None self.play_button = None self.curslice_label = QLineEdit(self) self.curslice_label.setToolTip( trans._('Current slice for axis {axis}', axis=axis)) # if we set the QIntValidator to actually reflect the range of the data # then an invalid (i.e. too large) index doesn't actually trigger the # editingFinished event (the user is expected to change the value)... # which is confusing to the user, so instead we use an IntValidator # that makes sure the user can only enter integers, but we do our own # value validation in self.change_slice self.curslice_label.setValidator(QIntValidator(0, 999999)) self.curslice_label.editingFinished.connect(self._set_slice_from_label) self.totslice_label = QLabel(self) self.totslice_label.setToolTip( trans._('Total slices for axis {axis}', axis=axis)) self.curslice_label.setObjectName('slice_label') self.totslice_label.setObjectName('slice_label') sep = QFrame(self) sep.setFixedSize(1, 14) sep.setObjectName('slice_label_sep') settings = get_settings() self._fps = settings.application.playback_fps connect_setattr_value(settings.application.events.playback_fps, self, "fps") self._minframe = None self._maxframe = None self._loop_mode = settings.application.playback_mode connect_setattr_value(settings.application.events.playback_mode, self, "loop_mode") layout = QHBoxLayout() self._create_axis_label_widget() self._create_range_slider_widget() self._create_play_button_widget() layout.addWidget(self.axis_label) layout.addWidget(self.play_button) layout.addWidget(self.slider, stretch=1) layout.addWidget(self.curslice_label) layout.addWidget(sep) layout.addWidget(self.totslice_label) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(2) layout.setAlignment(Qt.AlignVCenter) self.setLayout(layout) self.dims.events.axis_labels.connect(self._pull_label)
def __init__(self, parent=None, toggle_button=None): super().__init__(parent) self._toggleButton = toggle_button self.setObjectName('Activity') self.setMinimumWidth(self.MIN_WIDTH) self.setMinimumHeight(self.MIN_HEIGHT) self.setMaximumHeight(self.MIN_HEIGHT) self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) self.setWindowFlags(Qt.SubWindow | Qt.WindowStaysOnTopHint) self.setModal(False) opacityEffect = QGraphicsOpacityEffect(self) opacityEffect.setOpacity(0.8) self.setGraphicsEffect(opacityEffect) self._baseWidget = QWidget() self._activityLayout = QVBoxLayout() self._activityLayout.addStretch() self._baseWidget.setLayout(self._activityLayout) self._baseWidget.layout().setContentsMargins(0, 0, 0, 0) self._scrollArea = QScrollArea() self._scrollArea.setWidgetResizable(True) self._scrollArea.setWidget(self._baseWidget) self._titleBar = QLabel() title = QLabel('activity', self) title.setObjectName('QtCustomTitleLabel') title.setSizePolicy( QSizePolicy(QSizePolicy.Policy.Maximum, QSizePolicy.Policy.Maximum) ) line = QFrame(self) line.setObjectName("QtCustomTitleBarLine") titleLayout = QHBoxLayout() titleLayout.setSpacing(4) titleLayout.setContentsMargins(8, 1, 8, 0) line.setFixedHeight(1) titleLayout.addWidget(line) titleLayout.addWidget(title) self._titleBar.setLayout(titleLayout) self._baseLayout = QVBoxLayout() self._baseLayout.addWidget(self._titleBar) self._baseLayout.addWidget(self._scrollArea) self.setLayout(self._baseLayout) self.resize(520, self.MIN_HEIGHT) self.move_to_bottom_right() # TODO: what do we do with any existing progress objects in action? # connect callback to handle new progress objects being added/removed progress._all_instances.events.changed.connect( self.handle_progress_change )
def __init__(self, textedit, ancestor): super(KiteCallToAction, self).__init__(ancestor) self.textedit = textedit self.setFrameStyle(QFrame.StyledPanel | QFrame.Plain) self.setAutoFillBackground(True) self.setWindowFlags(Qt.SubWindow | Qt.FramelessWindowHint) self.setFocusPolicy(Qt.NoFocus) if is_dark_interface(): self.setObjectName("kite-call-to-action") self.setStyleSheet(self.styleSheet() + ( "#kite-call-to-action " "{{ border: 1px solid; " " border-color: {border_color}; " " border-radius: 4px;}} " "#kite-call-to-action:hover " "{{ border:1px solid {border}; }}" ).format(border_color=QStylePalette.COLOR_BACKGROUND_4, border=QStylePalette.COLOR_ACCENT_4)) # sub-layout: horizontally aligned links actions = QFrame(self) actions_layout = QHBoxLayout() actions_layout.setContentsMargins(5, 5, 5, 5) actions_layout.setSpacing(10) actions_layout.addStretch() actions.setLayout(actions_layout) self._install_button = QPushButton(_("Install Kite")) self._learn_button = QPushButton(_("Learn More")) self._dismiss_button = QPushButton(_("Dismiss Forever")) self._install_button.clicked.connect(self._install_kite) self._learn_button.clicked.connect(self._learn_more) self._dismiss_button.clicked.connect(self._dismiss_forever) actions_layout.addWidget(self._install_button) actions_layout.addWidget(self._learn_button) actions_layout.addWidget(self._dismiss_button) # main layout: message + horizontally aligned links main_layout = QVBoxLayout() main_layout.setContentsMargins(5, 5, 5, 5) self.setLayout(main_layout) self.label = QLabel(self) self.label.setWordWrap(True) main_layout.addWidget(self.label) main_layout.addWidget(actions) main_layout.addStretch() self._enabled = CONF.get('completions', 'kite_call_to_action') self._escaped = False self.hide() is_kite_installed, __ = check_if_kite_installed() if is_kite_installed: self._dismiss_forever()
def _create_content_box(self): content_box = QFrame() content_box_layout = QVBoxLayout() content_box_layout.setContentsMargins(9, 9, 9, 9) content_box_layout.addLayout(self._content_layout) content_box.setLayout(content_box_layout) content_box.setObjectName("contentBox") if self.isOpen is False: content_box.hide() return content_box
def __init__(self, parent): super().__init__(parent) self.setObjectName("QtModalPopup") self.setModal(False) # if False, then clicking anywhere else closes it self.setWindowFlags(Qt.Popup | Qt.FramelessWindowHint) self.setLayout(QVBoxLayout()) self.frame = QFrame() self.frame.setObjectName("QtPopupFrame") self.layout().addWidget(self.frame) self.layout().setContentsMargins(0, 0, 0, 0)
def __init__(self, layer): super().__init__(layer) self.layer.events.edge_width.connect(self._on_width_change) self.layer.events.length.connect(self._on_len_change) self.layer.events.edge_color.connect(self._on_edge_color_change) # vector color adjustment and widget edge_comboBox = QComboBox() colors = self.layer._colors for c in colors: edge_comboBox.addItem(c) edge_comboBox.activated[str].connect( lambda text=edge_comboBox: self.change_edge_color(text)) self.edgeComboBox = edge_comboBox self.edgeColorSwatch = QFrame() self.edgeColorSwatch.setObjectName('swatch') self.edgeColorSwatch.setToolTip('Edge color swatch') self._on_edge_color_change(None) # line width in pixels self.widthSpinBox = QDoubleSpinBox() self.widthSpinBox.setKeyboardTracking(False) self.widthSpinBox.setSingleStep(0.1) self.widthSpinBox.setMinimum(0.1) value = self.layer.edge_width self.widthSpinBox.setValue(value) self.widthSpinBox.valueChanged.connect(self.change_width) # line length self.lengthSpinBox = QDoubleSpinBox() self.lengthSpinBox.setKeyboardTracking(False) self.lengthSpinBox.setSingleStep(0.1) value = self.layer.length self.lengthSpinBox.setValue(value) self.lengthSpinBox.setMinimum(0.1) self.lengthSpinBox.valueChanged.connect(self.change_length) # grid_layout created in QtLayerControls # addWidget(widget, row, column, [row_span, column_span]) self.grid_layout.addWidget(QLabel('opacity:'), 0, 0) self.grid_layout.addWidget(self.opacitySilder, 0, 1, 1, 2) self.grid_layout.addWidget(QLabel('width:'), 1, 0) self.grid_layout.addWidget(self.widthSpinBox, 1, 1, 1, 2) self.grid_layout.addWidget(QLabel('length:'), 2, 0) self.grid_layout.addWidget(self.lengthSpinBox, 2, 1, 1, 2) self.grid_layout.addWidget(QLabel('blending:'), 3, 0) self.grid_layout.addWidget(self.blendComboBox, 3, 1, 1, 2) self.grid_layout.addWidget(QLabel('edge color:'), 4, 0) self.grid_layout.addWidget(self.edgeComboBox, 4, 2) self.grid_layout.addWidget(self.edgeColorSwatch, 4, 1) self.grid_layout.setRowStretch(5, 1) self.grid_layout.setColumnStretch(1, 1) self.grid_layout.setSpacing(4)
def get_gauge(self, parent, macros): aux = [] for k, v in macros.items(): aux.append('{}\t{}\n'.format(k, v)) tooltip = ''.join(aux) width = 320 height = 100 frame = QFrame(parent) frame.setGeometry(QRect(10, 10, width, height)) frame.setMinimumSize(width, height) frame.setFrameShape(QFrame.StyledPanel) frame.setFrameShadow(QFrame.Raised) frame.setObjectName("frame") brush = QBrush(QColor(180, 180, 180)) brush.setStyle(Qt.NoBrush) alarmRec = PyDMDrawingRectangle(frame) alarmRec.channel = "ca://{}".format(macros.get('ALARM', None)) alarmRec.setGeometry(QRect(0, 0, width, height)) alarmRec.setToolTip(tooltip) alarmRec.setProperty("alarmSensitiveContent", True) alarmRec.setProperty("brush", brush) alarmRec.setObjectName("alarmRec") # alarmRec.setStyleSheet("margin:5px; border:3px solid rgb(0, 0, 0);") lblName = QLabel(frame) lblName.setGeometry(QRect(width * 0.05, 50, width - width * 0.05, 20)) font = QFont() font.setPointSize(12) lblName.setFont(font) lblName.setAlignment(Qt.AlignCenter) lblName.setText("{}".format(macros.get('DISP', None))) lblName.setObjectName("lblName") lblName.setToolTip(tooltip) lblVal = PyDMLabel(frame) lblVal.setGeometry(QRect(width * 0.05, 10, width - width * 0.05, 30)) font = QFont() font.setPointSize(18) lblVal.setFont(font) lblVal.setToolTip(tooltip) lblVal.setAlignment(Qt.AlignCenter) lblVal.setProperty("showUnits", False) lblVal.setObjectName("lblVal") lblVal.channel = "ca://{}".format(macros.get('PV', None)) lblVal.precisionFromPV = False lblVal.precision = 2 if self.macros.get('FORMAT', '') == 'EXP': lblVal.displayFormat = PyDMLabel.DisplayFormat.Exponential return frame
def __init__(self, parent=None): super(MyTree, self).__init__(parent) data = MyData.init() frame = QFrame(); frame.setLayout( QHBoxLayout() ); treeViewModel = TreeViewModel(data) treeView = TreeView(treeViewModel) frame.layout().addWidget( treeView ); self.setCentralWidget(frame)
def __init__(self, item, parent_layout): super(GroupWidget, self).__init__(item, parent_layout) embedded = item.get_prop_value("display", "embedded", False) if not embedded: self.group = QGroupBox(item.get_prop_value("display", "label")) else: self.group = QFrame() self.layout = QGridLayout() EditLayoutClass = parent_layout.__class__ self.edit = EditLayoutClass(self.group, item.instance, self.layout, item.item.group) self.group.setLayout(self.layout)
def get_gauge(self, parent, pv_info: PVInfo): tooltip = "".join( [f"{key}\t{value}\n" for key, value in pv_info.__dict__.items()] ) width = 320 height = 100 frame = QFrame(parent) frame.setGeometry(QRect(10, 10, width, height)) frame.setMinimumSize(width, height) frame.setFrameShape(QFrame.StyledPanel) frame.setFrameShadow(QFrame.Raised) frame.setObjectName("frame") brush = QBrush(QColor(180, 180, 180)) brush.setStyle(Qt.NoBrush) alarmRec = PyDMDrawingRectangle(frame) alarmRec.channel = "ca://{}".format(pv_info.ALARM) alarmRec.setGeometry(QRect(0, 0, width, height)) alarmRec.setToolTip(tooltip) alarmRec.setProperty("alarmSensitiveContent", True) alarmRec.setProperty("brush", brush) alarmRec.setObjectName("alarmRec") # alarmRec.setStyleSheet("margin:5px; border:3px solid rgb(0, 0, 0);") lblName = QLabel(frame) lblName.setGeometry(QRect(width * 0.05, 50, width - width * 0.05, 20)) font = QFont() font.setPointSize(12) lblName.setFont(font) lblName.setAlignment(Qt.AlignCenter) lblName.setText("{}".format(pv_info.DISP)) lblName.setObjectName("lblName") lblName.setToolTip(tooltip) lblVal = PyDMLabel(frame) lblVal.setGeometry(QRect(width * 0.05, 10, width - width * 0.05, 30)) font = QFont() font.setPointSize(18) lblVal.setFont(font) lblVal.setToolTip(tooltip) lblVal.setAlignment(Qt.AlignCenter) lblVal.setProperty("showUnits", False) lblVal.setObjectName("lblVal") lblVal.channel = "ca://{}".format(pv_info.PV) lblVal.precisionFromPV = False lblVal.precision = 2 if self.macros().get("FORMAT", "") == "EXP": lblVal.displayFormat = PyDMLabel.DisplayFormat.Exponential return frame
def __init__(self, parent, title: str = '', vertical=False): super().__init__(parent) self.setObjectName("QtCustomTitleBar") self.setProperty('vertical', str(vertical)) self.vertical = vertical self.setToolTip(trans._('drag to move. double-click to float')) line = QFrame(self) line.setObjectName("QtCustomTitleBarLine") self.close_button = QPushButton(self) self.close_button.setToolTip(trans._('hide this panel')) self.close_button.setObjectName("QTitleBarCloseButton") self.close_button.setCursor(Qt.ArrowCursor) self.close_button.clicked.connect( lambda: self.parent().toggleViewAction().trigger() ) self.float_button = QPushButton(self) self.float_button.setToolTip(trans._('float this panel')) self.float_button.setObjectName("QTitleBarFloatButton") self.float_button.setCursor(Qt.ArrowCursor) self.float_button.clicked.connect( lambda: self.parent().setFloating(not self.parent().isFloating()) ) self.title = QLabel(title, self) self.title.setSizePolicy( QSizePolicy(QSizePolicy.Policy.Maximum, QSizePolicy.Policy.Maximum) ) if vertical: layout = QVBoxLayout() layout.setSpacing(4) layout.setContentsMargins(0, 8, 0, 8) line.setFixedWidth(1) layout.addWidget(self.close_button, 0, Qt.AlignHCenter) layout.addWidget(self.float_button, 0, Qt.AlignHCenter) layout.addWidget(line, 0, Qt.AlignHCenter) self.title.hide() else: layout = QHBoxLayout() layout.setSpacing(4) layout.setContentsMargins(8, 1, 8, 0) line.setFixedHeight(1) layout.addWidget(self.close_button) layout.addWidget(self.float_button) layout.addWidget(line) layout.addWidget(self.title) self.setLayout(layout) self.setCursor(Qt.OpenHandCursor)
def __init__(self, viewer): super().__init__() self.setProperty("emphasized", True) self.viewer = viewer self.setMouseTracking(True) self.empty_widget = QFrame() self.widgets = {} self.addWidget(self.empty_widget) self._display(None) self.viewer.layers.events.added.connect(self._add) self.viewer.layers.events.removed.connect(self._remove) self.viewer.events.active_layer.connect(self._display)
def __init__(self, arr, mgr): QMainWindow.__init__(self) self.arr = arr self.mgr = mgr self.main_widget = QWidget() self.layout = QGridLayout(self.main_widget) self.setCentralWidget(self.main_widget) self.label = ImageLabel(self, arr) self.label_container = QFrame() self.label_container.setFrameShape(QFrame.StyledPanel | QFrame.Sunken) self.label_container.setLineWidth(1) self.label_container.layout = QGridLayout(self.label_container) self.label_container.layout.setContentsMargins(0, 0, 0, 0) self.label_container.layout.addWidget(self.label, 0, 0) self.layout.addWidget(self.label_container, 0, 0) self.mgr.add_window(self) self.main_widget.show() self.setWindowTitle('Skivi - The skimage viewer.') self.mixer_panel = MixerPanel(self.arr) self.layout.addWidget(self.mixer_panel, 0, 2) self.mixer_panel.show() self.mixer_panel.set_callback(self.refresh_image) self.rgbv_hist = QuadHistogram(self.arr) self.layout.addWidget(self.rgbv_hist, 0, 1) self.rgbv_hist.show() self.rgb_hsv_disp = RGBHSVDisplay() self.layout.addWidget(self.rgb_hsv_disp, 1, 0) self.rgb_hsv_disp.show() self.layout.setColumnStretch(0, 1) self.layout.setRowStretch(0, 1) self.save_file = QtWidgets.QPushButton('Save to File') self.save_file.clicked.connect(self.save_to_file) self.save_stack = QtWidgets.QPushButton('Save to Stack') self.save_stack.clicked.connect(self.save_to_stack) self.save_file.show() self.save_stack.show() self.layout.addWidget(self.save_stack, 1, 1) self.layout.addWidget(self.save_file, 1, 2)