def __init__(self, parent=None): QWidget.__init__(self) self.tfPlot = TransferFunctionPlot() self.modelCombo = QComboBox() self.modelCombo.addItems(AvailableModels) self.quantityCombo = QComboBox() self.quantityCombo.addItems(['Impedance', 'Admittance']) self.fMinSb = QDoubleSpinBox() self.fMinSb.setRange(0.1, 1E6) self.fMaxSb = QDoubleSpinBox() self.fMaxSb.setRange(10, 1E6) self.fMinSb.setKeyboardTracking(False) self.fMaxSb.setKeyboardTracking(False) self.fMinSb.valueChanged.connect(self.fMinSb.setMinimum) self.fMaxSb.valueChanged.connect(self.fMaxSb.setMaximum) self.fMinSb.setValue(1) self.fMaxSb.setValue(250E3) self.shuntSb = QDoubleSpinBox() self.shuntSb.setDecimals(4) self.shuntSb.setKeyboardTracking(False) self.shuntSb.setRange(0.010, 10) self.shuntSb.setSuffix(u' m\u03A9') self.shuntSb.setValue(0.257) l = QFormLayout() l.addRow('Model', self.modelCombo) l.addRow('Quantity', self.quantityCombo) l.addRow('f (min)', self.fMinSb) l.addRow('f (max)', self.fMaxSb) l.addRow('Shunt resistance', self.shuntSb) self.setLayout(l)
def __init__(self, parent, start, stop): super().__init__(parent) self.setWindowTitle("Crop data") vbox = QVBoxLayout(self) grid = QGridLayout() self.start_checkbox = QCheckBox("Start time:") self.start_checkbox.setChecked(True) self.start_checkbox.stateChanged.connect(self.toggle_start) grid.addWidget(self.start_checkbox, 0, 0) self._start = QDoubleSpinBox() self._start.setMaximum(999999) self._start.setValue(start) self._start.setDecimals(2) self._start.setSuffix(" s") grid.addWidget(self._start, 0, 1) self.stop_checkbox = QCheckBox("Stop time:") self.stop_checkbox.setChecked(True) self.stop_checkbox.stateChanged.connect(self.toggle_stop) grid.addWidget(self.stop_checkbox, 1, 0) self._stop = QDoubleSpinBox() self._stop.setMaximum(999999) self._stop.setValue(stop) self._stop.setDecimals(2) self._stop.setSuffix(" s") grid.addWidget(self._stop, 1, 1) vbox.addLayout(grid) buttonbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) vbox.addWidget(buttonbox) buttonbox.accepted.connect(self.accept) buttonbox.rejected.connect(self.reject) vbox.setSizeConstraint(QVBoxLayout.SetFixedSize)
def __init__(self, settings: ViewSettings, start_name: str): if start_name == "": raise ValueError( "ChannelProperty should have non empty start_name") super().__init__() self.current_name = start_name self.current_channel = 0 self._settings = settings self.widget_dict: typing.Dict[str, ColorComboBoxGroup] = {} self.minimum_value = CustomSpinBox(self) self.minimum_value.setRange(-(10**6), 10**6) self.minimum_value.valueChanged.connect(self.range_changed) self.maximum_value = CustomSpinBox(self) self.maximum_value.setRange(-(10**6), 10**6) self.maximum_value.valueChanged.connect(self.range_changed) self.fixed = QCheckBox("Fix range") self.fixed.stateChanged.connect(self.lock_channel) self.use_filter = QEnumComboBox(enum_class=NoiseFilterType) self.use_filter.setToolTip("Only current channel") self.filter_radius = QDoubleSpinBox() self.filter_radius.setSingleStep(0.1) self.filter_radius.valueChanged.connect(self.gauss_radius_changed) self.use_filter.currentIndexChanged.connect(self.gauss_use_changed) self.gamma_value = QDoubleSpinBox() self.gamma_value.setRange(0.01, 100) self.gamma_value.setSingleStep(0.1) self.gamma_value.valueChanged.connect(self.gamma_value_changed) self.collapse_widget = CollapseCheckbox("Channel property") self.collapse_widget.add_hide_element(self.minimum_value) self.collapse_widget.add_hide_element(self.maximum_value) self.collapse_widget.add_hide_element(self.fixed) self.collapse_widget.add_hide_element(self.use_filter) self.collapse_widget.add_hide_element(self.filter_radius) self.collapse_widget.add_hide_element(self.gamma_value) layout = QGridLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.collapse_widget, 0, 0, 1, 4) label1 = QLabel("Min bright:") layout.addWidget(label1, 1, 0) layout.addWidget(self.minimum_value, 1, 1) label2 = QLabel("Max bright:") layout.addWidget(label2, 2, 0) layout.addWidget(self.maximum_value, 2, 1) layout.addWidget(self.fixed, 1, 2, 1, 2) label3 = QLabel("Filter:") layout.addWidget(label3, 3, 0, 1, 1) layout.addWidget(self.use_filter, 3, 1, 1, 1) layout.addWidget(self.filter_radius, 3, 2, 1, 1) label4 = QLabel("Gamma:") layout.addWidget(label4, 4, 0, 1, 1) layout.addWidget(self.gamma_value, 4, 1, 1, 1) self.setLayout(layout) self.collapse_widget.add_hide_element(label1) self.collapse_widget.add_hide_element(label2) self.collapse_widget.add_hide_element(label3) self.collapse_widget.add_hide_element(label4)
def __init__(self, line_style_set=STYLESET_DEFAULT): QWidget.__init__(self) self._style = PlotStyle("StyleChooser internal style") self._styles = (STYLES["default"] if line_style_set not in STYLES else STYLES[line_style_set]) self.setMinimumWidth(140) self.setMaximumHeight(25) layout = QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(2) self.line_chooser = QComboBox() self.line_chooser.setToolTip("Select line style.") for style in self._styles: self.line_chooser.addItem(*style) self.marker_chooser = QComboBox() self.marker_chooser.setToolTip("Select marker style.") for marker in MARKERS: self.marker_chooser.addItem(*marker) self.thickness_spinner = QDoubleSpinBox() self.thickness_spinner.setToolTip("Line thickness") self.thickness_spinner.setMinimum(0.1) self.thickness_spinner.setDecimals(1) self.thickness_spinner.setSingleStep(0.1) self.size_spinner = QDoubleSpinBox() self.size_spinner.setToolTip("Marker size") self.size_spinner.setMinimum(0.1) self.size_spinner.setDecimals(1) self.size_spinner.setSingleStep(0.1) # the text content of the spinner varies, but shouldn't push the control # out of boundaries self.line_chooser.setMinimumWidth(110) layout.addWidget(self.line_chooser) layout.addWidget(self.thickness_spinner) layout.addWidget(self.marker_chooser) layout.addWidget(self.size_spinner) self.setLayout(layout) self.line_chooser.currentIndexChanged.connect(self._updateStyle) self.marker_chooser.currentIndexChanged.connect(self._updateStyle) self.thickness_spinner.valueChanged.connect(self._updateStyle) self.size_spinner.valueChanged.connect(self._updateStyle) self._updateLineStyleAndMarker( self._style.line_style, self._style.marker, self._style.width, self._style.size, ) self._layout = layout
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 __init__(self, parent, events): super().__init__(parent) self.setWindowTitle("Create Epochs") grid = QGridLayout(self) label = QLabel("Events:") label.setAlignment(Qt.AlignTop) grid.addWidget(label, 0, 0, 1, 1) self.events = QListWidget() self.events.insertItems(0, unique(events[:, 2]).astype(str)) self.events.setSelectionMode(QListWidget.ExtendedSelection) grid.addWidget(self.events, 0, 1, 1, 2) grid.addWidget(QLabel("Interval around events:"), 1, 0, 1, 1) self.tmin = QDoubleSpinBox() self.tmin.setMinimum(-10000) self.tmin.setValue(-0.2) self.tmin.setSingleStep(0.1) self.tmin.setAlignment(Qt.AlignRight) self.tmax = QDoubleSpinBox() self.tmax.setMinimum(-10000) self.tmax.setValue(0.5) self.tmax.setSingleStep(0.1) self.tmax.setAlignment(Qt.AlignRight) grid.addWidget(self.tmin, 1, 1, 1, 1) grid.addWidget(self.tmax, 1, 2, 1, 1) self.baseline = QCheckBox("Baseline Correction:") self.baseline.setChecked(True) self.baseline.stateChanged.connect(self.toggle_baseline) grid.addWidget(self.baseline, 2, 0, 1, 1) self.a = QDoubleSpinBox() self.a.setMinimum(-10000) self.a.setValue(-0.2) self.a.setSingleStep(0.1) self.a.setAlignment(Qt.AlignRight) self.b = QDoubleSpinBox() self.b.setMinimum(-10000) self.b.setValue(0) self.b.setSingleStep(0.1) self.b.setAlignment(Qt.AlignRight) grid.addWidget(self.a, 2, 1, 1, 1) grid.addWidget(self.b, 2, 2, 1, 1) self.buttonbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.buttonbox.accepted.connect(self.accept) self.buttonbox.rejected.connect(self.reject) grid.addWidget(self.buttonbox, 3, 0, 1, -1) self.events.itemSelectionChanged.connect(self.toggle_ok) self.toggle_ok() grid.setSizeConstraint(QGridLayout.SetFixedSize)
def __init__(self, layer): super().__init__(layer) self.layer.events.averaging.connect(self._on_avg_change) self.layer.events.width.connect(self._on_width_change) self.layer.events.length.connect(self._on_len_change) # vector color adjustment and widget face_comboBox = QComboBox() colors = self.layer._colors for c in colors: face_comboBox.addItem(c) index = face_comboBox.findText(self.layer.color, Qt.MatchFixedString) if index >= 0: face_comboBox.setCurrentIndex(index) face_comboBox.activated[str].connect( lambda text=face_comboBox: self.change_face_color(text)) self.grid_layout.addWidget(QLabel('color:'), 3, 0) self.grid_layout.addWidget(face_comboBox, 3, 1) # line width in pixels self.width_field = QDoubleSpinBox() self.width_field.setSingleStep(0.1) self.width_field.setMinimum(0.1) value = self.layer.width self.width_field.setValue(value) self.width_field.valueChanged.connect(self.change_width) self.grid_layout.addWidget(QLabel('width:'), 4, 0) self.grid_layout.addWidget(self.width_field, 4, 1) # averaging spinbox self.averaging_spinbox = QSpinBox() self.averaging_spinbox.setSingleStep(1) self.averaging_spinbox.setValue(1) self.averaging_spinbox.setMinimum(1) self.averaging_spinbox.valueChanged.connect(self.change_average_type) self.grid_layout.addWidget(QLabel('avg kernel'), 5, 0) self.grid_layout.addWidget(self.averaging_spinbox, 5, 1) # line length self.length_field = QDoubleSpinBox() self.length_field.setSingleStep(0.1) value = self.layer.length self.length_field.setValue(value) self.length_field.setMinimum(0.1) self.length_field.valueChanged.connect(self.change_length) self.grid_layout.addWidget(QLabel('length:'), 6, 0) self.grid_layout.addWidget(self.length_field, 6, 1) self.setExpanded(False)
def __init__(self, settings: PartSettings, channel_property: ChannelProperty, name: str): super().__init__(settings, channel_property, name) self._channel_control_top = True self.only_border = QCheckBox("") self._set_border_from_settings() self.only_border.stateChanged.connect(self._set_border) self.opacity = QDoubleSpinBox() self.opacity.setRange(0, 1) self.opacity.setSingleStep(0.1) self._set_opacity_from_settings() self.opacity.valueChanged.connect(self._set_opacity) self.opacity.setMinimumWidth(500) self.channel_control_index = self.btn_layout.indexOf(self.channel_control) self.label1 = QLabel("Borders:") self.label2 = QLabel("Opacity:") self.roi_alternative_select = QComboBox() self.roi_alternative_select.currentTextChanged.connect(self._set_roi_alternative_version) self.stretch = None self.btn_layout.insertWidget(self.channel_control_index + 1, self.label1) self.btn_layout.insertWidget(self.channel_control_index + 2, self.only_border) self.btn_layout.insertWidget(self.channel_control_index + 3, self.label2) self.btn_layout.insertWidget(self.channel_control_index + 4, self.opacity) self.btn_layout.insertWidget(self.channel_control_index + 1, self.roi_alternative_select) self.channel_control_index = self.btn_layout.indexOf(self.channel_control) self.label1.setVisible(False) self.label2.setVisible(False) self.opacity.setVisible(False) self.only_border.setVisible(False) self.roi_alternative_select.setVisible(False) self.settings.connect_to_profile(f"{self.name}.image_state.only_border", self._set_border_from_settings) self.settings.connect_to_profile(f"{self.name}.image_state.opacity", self._set_opacity_from_settings)
def __init__(self, layout_dir: str, title: str, initial_value: Union[int, float], unit: str = '', val_range: Tuple[Union[float, int], Union[float, int]] = (None, None), step: int = 1): super().__init__(layout_dir) self.on_check_callback = None self.prefix = QLabel(text=title) entryLayout = QHBoxLayout() entryLayout.setContentsMargins(0, 0, 0, 0) self.min, self.max = val_range self.step = step if isinstance(self.min, int) and isinstance(self.max, int) and isinstance(self.step, int) \ and isinstance(initial_value, int): self.ctrl = QSpinBox() else: self.ctrl = QDoubleSpinBox() self.ctrl.valueChanged.connect(self.on_value_changed) self.postfix = QLabel(text=unit) # self.central_layout.addWidget(self.prefix) self.central_layout.addLayout(entryLayout) entryLayout.addWidget(self.prefix) entryLayout.addWidget(self.ctrl) entryLayout.addWidget(self.postfix) if self.min is not None: self.ctrl.setMinimum(self.min) if self.max is not None: self.ctrl.setMaximum(self.max) self.ctrl.setSingleStep(step) self.accury = initial_value self.set_value(initial_value)
def create_widget(self): """ Create the underlying QDoubleSpinBox widget. """ widget = QDoubleSpinBox(self.parent_widget()) widget.setKeyboardTracking(False) self.widget = widget
def __clean_and_load_bookings__(self, working_date: str=None): """ Cleans booking table when switch working day. :param working_date: :return: """ row = 0 t: QTableWidget = self.ui.table_bookings clean_table(t) bookings = list() if working_date is not None: bookings = self.time_capture_service.load_bookings(working_date) else: bookings = self.__convert_entities_to_bookings__() for b in bookings: t.insertRow(row) qcb = QCheckBox(self.ui.table_bookings) qcb.setChecked(b[bk.BOOKED]) t.setCellWidget(row, B_BOOKED, qcb) qcb = QCheckBox(self.ui.table_bookings) qcb.setChecked(b[bk.LOGGED]) t.setCellWidget(row, B_LOGGED, qcb) qdsb = QDoubleSpinBox(self.ui.table_bookings) qdsb.setValue(b[bk.HOURS]) t.setCellWidget(row, B_HOURS, qdsb) t.setItem(row, B_ORDER, QTableWidgetItem(b[bk.ORDER])) t.setItem(row, B_COMMENT, QTableWidgetItem(b[bk.COMMENT])) t.resizeRowsToContents() row += 1
def __init__(self, parent=None): super(OffsetsDialog, self).__init__(parent=parent) self.info = Info() self.log = Log axis_list = self.info.getAxisList() self.axis_combo = QComboBox() for axis in axis_list: self.axis_combo.addItem(axis.upper(), axis) coords_msg = QLabel("Coordinate relative to workpiece:") system_msg = QLabel("Coordinate System:") self.coords_input = QDoubleSpinBox() self.coords_input.setRange(-999999, 999999) self.system_combo = QComboBox() coord_systems = { "P0": "P0 Current", "P1": "P1 G54", "P2": "P2 G55", "P3": "P3 G56", "P4": "P4 G57", "P5": "P5 G58", "P6": "P6 G59", "P7": "P7 G59.1", "P8": "P8 G59.1", "P9": "P9 G59.3" } for key, value in OrderedDict( sorted(coord_systems.items(), key=lambda t: t[0])).items(): self.system_combo.addItem(value, key) close_button = QPushButton("Close") set_button = QPushButton("Set") main_layout = QVBoxLayout() button_layout = QHBoxLayout() button_layout.addWidget(close_button) button_layout.addWidget(set_button) main_layout.addWidget(self.axis_combo, alignment=Qt.AlignTop) main_layout.addWidget(coords_msg, alignment=Qt.AlignLeft | Qt.AlignTop) main_layout.addWidget(self.coords_input, alignment=Qt.AlignTop) main_layout.addWidget(system_msg, alignment=Qt.AlignLeft | Qt.AlignTop) main_layout.addWidget(self.system_combo, alignment=Qt.AlignBottom) main_layout.addLayout(button_layout) self.setLayout(main_layout) self.setWindowTitle("Regular Offsets") set_button.clicked.connect(self.set_method) close_button.clicked.connect(self.close_method) self.setWindowFlags(Qt.Popup)
def _dock_add_spin_box(self, name, value, rng, callback, *, compact=True, double=True, step=None, tooltip=None, layout=None): layout = self._dock_named_layout(name=name, layout=layout, compact=compact) value = value if double else int(value) widget = QDoubleSpinBox() if double else QSpinBox() _set_widget_tooltip(widget, tooltip) widget.setAlignment(Qt.AlignCenter) widget.setMinimum(rng[0]) widget.setMaximum(rng[1]) widget.setKeyboardTracking(False) if step is None: inc = (rng[1] - rng[0]) / 20. inc = max(int(round(inc)), 1) if not double else inc widget.setSingleStep(inc) else: widget.setSingleStep(step) widget.setValue(value) widget.valueChanged.connect(callback) self._layout_add_widget(layout, widget) return _QtWidget(widget)
def __init__(self, parent: MainWindowBase): super(_LinkLengthDialog, self).__init__(parent) self.setWindowTitle("Set Link Length") self.main_layout = QVBoxLayout(self) layout = QHBoxLayout() self.leader = QComboBox(self) self.follower = QComboBox(self) self.length = QDoubleSpinBox(self) layout.addWidget(self.leader) layout.addWidget(self.follower) layout.addWidget(self.length) self.main_layout.addLayout(layout) self.vpoints = parent.vpoint_list self.vlinks = { vlink.name: frozenset(vlink.points) for vlink in parent.vlink_list } self.leader.currentTextChanged.connect(self.__set_follower) self.follower.currentTextChanged.connect(self.__set_length) self.leader.addItems([f"P{i}" for i in range(len(self.vpoints))]) self.leader.setCurrentIndex(0) self.length.setMaximum(100000) button_box = QDialogButtonBox(self) button_box.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) button_box.accepted.connect(self.accept) button_box.rejected.connect(self.reject) button_box.button(QDialogButtonBox.Ok).setEnabled( bool(parent.vpoint_list)) self.main_layout.addWidget(button_box)
def __init__(self, parent=None, emphasized=False): super().__init__(parent) self.setProperty('emphasized', emphasized) self.tab1 = QWidget() self.tab1.setProperty('emphasized', emphasized) self.tab2 = QWidget() self.tab2.setProperty('emphasized', emphasized) self.addTab(self.tab1, "Tab 1") self.addTab(self.tab2, "Tab 2") layout = QFormLayout() layout.addRow("Height", QSpinBox()) layout.addRow("Weight", QDoubleSpinBox()) self.setTabText(0, "Tab 1") self.tab1.setLayout(layout) layout2 = QFormLayout() sex = QHBoxLayout() sex.addWidget(QRadioButton("Male")) sex.addWidget(QRadioButton("Female")) layout2.addRow(QLabel("Sex"), sex) layout2.addRow("Date of Birth", QLineEdit()) self.setTabText(1, "Tab 2") self.tab2.setLayout(layout2) self.setWindowTitle("tab demo")
def __init__(self, *args): """Type name: "DXF module".""" super(DxfOutputDialog, self).__init__(*args) # DXF version option version_label = QLabel("DXF version:", self) self.version_option = QComboBox(self) self.version_option.addItems( sorted((f"{name} - {DXF_VERSIONS_MAP[name]}" for name in DXF_VERSIONS), key=lambda v: v.split()[-1])) self.version_option.setCurrentIndex(self.version_option.count() - 1) self.version_option.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) layout = QHBoxLayout() layout.addWidget(version_label) layout.addWidget(self.version_option) self.main_layout.insertLayout(3, layout) # Parts interval self.use_interval = QCheckBox("Parts interval:", self) self.use_interval.setCheckState(Qt.Checked) self.use_interval.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred) self.interval_option = QDoubleSpinBox(self) self.interval_option.setValue(10) self.use_interval.stateChanged.connect(self.interval_option.setEnabled) layout = QHBoxLayout() layout.addWidget(self.use_interval) layout.addWidget(self.interval_option) layout.addItem( QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Preferred)) self.assembly_layout.insertLayout(2, layout)
def create_widgets(self): """creates the display window""" # Text Size model_name = self.model_name self.nodes_label = QLabel("Nodes:") self.nodes_edit = QNodeEdit(self, model_name, pick_style='area', tab_to_next=False) self.elements_label = QLabel("Elements:") self.elements_edit = QElementEdit(self, model_name, pick_style='area', tab_to_next=False) #----------------------------------------------------------------------- # Highlight Color self.highlight_opacity_label = QLabel("Highlight Opacity:") self.highlight_opacity_edit = QDoubleSpinBox(self) self.highlight_opacity_edit.setValue(self._highlight_opacity) self.highlight_opacity_edit.setRange(0.1, 1.0) self.highlight_opacity_edit.setDecimals(1) self.highlight_opacity_edit.setSingleStep(0.1) self.highlight_opacity_button = QPushButton("Default") # Text Color self.highlight_color_label = QLabel("Highlight Color:") self.highlight_color_edit = QPushButtonColor(self.highlight_color_int) #----------------------------------------------------------------------- # closing self.show_button = QPushButton("Show") self.clear_button = QPushButton("Clear") self.close_button = QPushButton("Close")
def __init__(self, *args): """Type name: "DXF module".""" super(DxfOutputDialog, self).__init__("DXF", "dxf.png", "The part sketchs will including in the file.", "There is only wire frame will be generated.", *args) # DXF version option. version_label = QLabel("DXF version:", self) self.version_option = QComboBox(self) self.version_option.addItems( sorted((f"{name} - {DXF_VERSIONS_MAP[name]}" for name in DXF_VERSIONS), key=lambda v: v.split()[-1])) self.version_option.setCurrentIndex(self.version_option.count() - 1) self.version_option.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)) dxf_version_layout = QHBoxLayout() dxf_version_layout.addWidget(version_label) dxf_version_layout.addWidget(self.version_option) self.main_layout.insertLayout(3, dxf_version_layout) # Parts interval. self.interval_enable = QCheckBox("Parts interval:", self) self.interval_enable.setCheckState(Qt.Checked) self.interval_option = QDoubleSpinBox(self) self.interval_option.setValue(10) self.interval_enable.stateChanged.connect( self.interval_option.setEnabled) dxf_interval_layout = QHBoxLayout() dxf_interval_layout.addWidget(self.interval_enable) dxf_interval_layout.addItem( QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)) dxf_interval_layout.addWidget(self.interval_option) self.assembly_layout.insertLayout(2, dxf_interval_layout)
def _get_actor_widget(actor: vtkActor) -> QWidget: widget = QWidget() layout = QVBoxLayout() prop = actor.GetProperty() # visibility visibility = QCheckBox("Visibility") visibility.setChecked(actor.GetVisibility()) visibility.toggled.connect(actor.SetVisibility) layout.addWidget(visibility) if prop is not None: # opacity tmp_layout = QHBoxLayout() opacity = QDoubleSpinBox() opacity.setMaximum(1.0) opacity.setValue(prop.GetOpacity()) opacity.valueChanged.connect(prop.SetOpacity) tmp_layout.addWidget(QLabel("Opacity")) tmp_layout.addWidget(opacity) layout.addLayout(tmp_layout) widget.setLayout(layout) return widget
def __init__(self, settings: ViewSettings): super().__init__() self.settings = settings self.color_picker = QColorDialog() self.color_picker.setWindowFlag(Qt.Widget) self.color_picker.setOptions(QColorDialog.DontUseNativeDialog | QColorDialog.NoButtons) self.opacity_spin = QDoubleSpinBox() self.opacity_spin.setRange(0, 1) self.opacity_spin.setSingleStep(0.1) self.opacity_spin.setDecimals(2) self.change_mask_color_btn = QPushButton("Change mask color") self.current_mask_color_preview = ColorShow( self.settings.get_from_profile("mask_presentation_color", [255, 255, 255])) self.opacity_spin.setValue( self.settings.get_from_profile("mask_presentation_opacity", 1)) self.current_mask_color_preview.setAutoFillBackground(True) self.change_mask_color_btn.clicked.connect(self.change_color) self.opacity_spin.valueChanged.connect(self.change_opacity) layout = QVBoxLayout() layout.addWidget(self.color_picker) layout2 = QHBoxLayout() layout2.addWidget(self.change_mask_color_btn) layout2.addWidget(self.current_mask_color_preview, 1) layout2.addWidget(QLabel("Mask opacity")) layout2.addWidget(self.opacity_spin) layout.addLayout(layout2) self.setLayout(layout)
def __init__( self, parent: MainWindow, callback: Any, minimum: float = 0.0, maximum: float = 20.0, value: float = 1.0, ) -> None: """Initialize the range widget.""" super(RangeGroup, self).__init__(parent) self.slider = DoubleSlider(QtCore.Qt.Horizontal) self.slider.setTickInterval(0.1) self.slider.setMinimum(minimum) self.slider.setMaximum(maximum) self.slider.setValue(value) self.minimum = minimum self.maximum = maximum self.spinbox = QDoubleSpinBox(value=value, minimum=minimum, maximum=maximum, decimals=4) self.addWidget(self.slider) self.addWidget(self.spinbox) # Connect slider to spinbox self.slider.valueChanged.connect(self.update_spinbox) self.spinbox.valueChanged.connect(self.update_value) self.spinbox.valueChanged.connect(callback) return None
def __init__(self, dim_info, number=0, state=State.NONE, parent=None): # hack in a number_of_bins for MDEventWorkspace dim_info['number_of_bins'] = 1000 dim_info['width'] = (dim_info['maximum'] - dim_info['minimum']) / 1000 self.spinBins = QSpinBox() self.spinBins.setRange(2, 9999) self.spinBins.setValue(100) self.spinBins.hide() self.spinBins.setMinimumWidth(110) self.spinThick = QDoubleSpinBox() self.spinThick.setRange(0.001, 999) self.spinThick.setValue(0.1) self.spinThick.setSingleStep(0.1) self.spinThick.setDecimals(3) self.spinThick.setMinimumWidth(110) self.rebinLabel = QLabel("thick") self.rebinLabel.setMinimumWidth(44) super().__init__(dim_info, number, state, parent) self.spinBins.valueChanged.connect(self.binningChanged) self.spinThick.valueChanged.connect(self.valueChanged) self.layout.addWidget(self.spinBins) self.layout.addWidget(self.spinThick) self.layout.addWidget(self.rebinLabel)
def __init__(self, parent: MainWindowBase): super(_ScaleDialog, self).__init__(parent) self.setWindowTitle("Scale Mechanism") self.main_layout = QVBoxLayout(self) self.enlarge = QDoubleSpinBox(self) self.shrink = QDoubleSpinBox(self) self.__add_option("Enlarge", self.enlarge) self.__add_option("Shrink", self.shrink) button_box = QDialogButtonBox(self) button_box.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) button_box.accepted.connect(self.accept) button_box.rejected.connect(self.reject) button_box.button(QDialogButtonBox.Ok).setEnabled( bool(parent.vpoint_list)) self.main_layout.addWidget(button_box)
def createEditor(self, parent, option, index): """Override. Create and editor based on the cell type """ editor = QDoubleSpinBox(parent) editor.setDecimals(5) return editor
def create_controls(self): """ Create UI controls. """ vbox = QVBoxLayout() form = QFormLayout() self.num_angle = QDoubleSpinBox() self.num_angle.setValue(0.0) self.num_angle.setMinimum(-360) self.num_angle.setMaximum(360) form.addRow(tr("Angle:"), self.num_angle) vbox.addLayout(form) self.gbo_preview = QGroupBox(tr("Preview")) self.gbo_preview.setCheckable(True) self.gbo_preview.setChecked(False) gbo_vbox = QVBoxLayout() self.chk_grid = QCheckBox(tr("Grid")) self.chk_grid.setChecked(False) self.num_grid = QSpinBox() self.num_grid.setValue(4) self.num_grid.setMinimum(1) self.num_grid.setEnabled(False) self.chk_grid.toggled[bool].connect(self.num_grid.setEnabled) gbo_vbox.addWidget(self.chk_grid) gbo_vbox.addWidget(self.num_grid) self.gbo_preview.setLayout(gbo_vbox) vbox.addWidget(self.gbo_preview) self.gbo_preview.toggled[bool].connect(self.set_preview) self.gbo_output = QGroupBox(tr("Output")) self.opt_new = QRadioButton(tr("New signal")) self.opt_replace = QRadioButton(tr("In place")) self.opt_new.setChecked(True) gbo_vbox2 = QVBoxLayout() gbo_vbox2.addWidget(self.opt_new) gbo_vbox2.addWidget(self.opt_replace) self.gbo_output.setLayout(gbo_vbox2) vbox.addWidget(self.gbo_output) self.chk_reshape = QCheckBox(tr("Resize to fit")) self.chk_reshape.setChecked(False) vbox.addWidget(self.chk_reshape) self.btn_ok = QPushButton(tr("&OK")) self.btn_ok.setDefault(True) self.btn_ok.clicked.connect(self.accept) self.btn_cancel = QPushButton(tr("&Cancel")) self.btn_cancel.clicked.connect(self.reject) hbox = QHBoxLayout() hbox.addWidget(self.btn_ok) hbox.addWidget(self.btn_cancel) vbox.addLayout(hbox) vbox.addStretch(1) self.setLayout(vbox)
def __init__(self, dim_info, number=0, state=State.NONE, parent=None): super().__init__(parent) self.minimum = dim_info['minimum'] self.nbins = dim_info['number_of_bins'] self.width = dim_info['width'] self.number = number self.layout = QHBoxLayout(self) self.layout.setContentsMargins(0, 2, 0, 0) self.name = QLabel(dim_info['name']) self.units = QLabel(dim_info['units']) self.x = QPushButton('X') self.x.setCheckable(True) self.x.clicked.connect(self.x_clicked) # square button based on height. Default sizeHint is too large self.x.setFixedWidth(self.x.sizeHint().height()) self.x.setToolTip("Swap X and Y axes") self.y = QPushButton('Y') self.y.setCheckable(True) self.y.clicked.connect(self.y_clicked) self.y.setFixedWidth(self.y.sizeHint().height()) self.y.setToolTip("Swap X and Y axes") self.slider = QSlider(Qt.Horizontal) self.slider.setRange(0, self.nbins - 1) self.slider.valueChanged.connect(self.slider_changed) self.update_value_from_slider = True self.spinbox = QDoubleSpinBox() self.spinbox.setDecimals(3) self.spinbox.setRange(self.get_bin_center(0), self.get_bin_center(self.nbins - 1)) self.spinbox.setSingleStep(self.width) self.set_value(self.spinbox.minimum()) self.update_spinbox( ) # not updated with set_value unless instance of DimensionNonIntegrated self.spinbox.editingFinished.connect(self.spinbox_changed) self.layout.addWidget(self.name) self.button_layout = QHBoxLayout() self.button_layout.setContentsMargins(0, 0, 0, 0) self.button_layout.setSpacing(0) self.button_layout.addWidget(self.x) self.button_layout.addWidget(self.y) self.layout.addLayout(self.button_layout) self.layout.addWidget(self.slider, stretch=1) self.layout.addStretch(0) self.layout.addWidget(self.spinbox) self.layout.addWidget(self.units) if self.nbins < 2: state = State.DISABLE self.set_state(state)
def create_widgets(self): """creates the display window""" # Text Size model_name = self.model_name self.nodes_label = QLabel('Nodes:') self.nodes_edit = QNodeEdit(self, model_name, pick_style='area', cleanup=True, tab_to_next=False) self.elements_label = QLabel('Elements:') self.elements_edit = QElementEdit(self, model_name, pick_style='area', cleanup=True, tab_to_next=False) #----------------------------------------------------------------------- # Highlight Color if self.menu_type == 'highlight': self.highlight_opacity_label = QLabel('Highlight Opacity:') self.highlight_opacity_edit = QDoubleSpinBox(self) self.highlight_opacity_edit.setValue(self._highlight_opacity) self.highlight_opacity_edit.setRange(0.1, 1.0) self.highlight_opacity_edit.setDecimals(1) self.highlight_opacity_edit.setSingleStep(0.1) self.highlight_opacity_button = QPushButton('Default') # Text Color self.highlight_color_label = QLabel('Highlight Color:') self.highlight_color_edit = QPushButtonColor( self.highlight_color_int) self.point_size_label = QLabel('Point Size:') self.point_size_edit = QSpinBox(self) self.point_size_edit.setValue(self._point_size) self.point_size_edit.setRange(7, 30) #self.point_size_button = QPushButton("Default") elif self.menu_type == 'mark': self.label_size_label = QLabel('Label Size:') self.label_size_edit = QSpinBox(self) self.label_size_edit.setValue(self._default_annotation_size) self.label_size_edit.setRange(7, 30) #self.label_size_button = QPushButton("Default") else: raise NotImplementedError(self.menu_type) #----------------------------------------------------------------------- # closing #if self.menu_type == 'highlight': self.show_button = QPushButton('Show') #elif self.menu_type == 'mark': #self.mark_button = QCheckBox('Mark') #else: #raise NotImplementedError(self.menu_type) self.clear_button = QPushButton('Clear') self.close_button = QPushButton('Close')
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) # vector color adjustment and widget face_comboBox = QComboBox() colors = self.layer._colors for c in colors: face_comboBox.addItem(c) index = face_comboBox.findText(self.layer.edge_color, Qt.MatchFixedString) if index >= 0: face_comboBox.setCurrentIndex(index) face_comboBox.activated[str].connect( lambda text=face_comboBox: self.change_edge_color(text)) row = self.grid_layout.rowCount() self.grid_layout.addWidget(QLabel('color:'), row, self.name_column) self.grid_layout.addWidget(face_comboBox, row, self.property_column) # line width in pixels self.width_field = QDoubleSpinBox() self.width_field.setSingleStep(0.1) self.width_field.setMinimum(0.1) value = self.layer.edge_width self.width_field.setValue(value) self.width_field.valueChanged.connect(self.change_width) row = self.grid_layout.rowCount() self.grid_layout.addWidget(QLabel('width:'), row, self.name_column) self.grid_layout.addWidget(self.width_field, row, self.property_column) # line length self.length_field = QDoubleSpinBox() self.length_field.setSingleStep(0.1) value = self.layer.length self.length_field.setValue(value) self.length_field.setMinimum(0.1) self.length_field.valueChanged.connect(self.change_length) row = self.grid_layout.rowCount() self.grid_layout.addWidget(QLabel('length:'), row, self.name_column) self.grid_layout.addWidget(self.length_field, row, self.property_column) self.setExpanded(False)
def createEditor(self, parent, option, index): # ToDo: set dec placed for IN and MM machines col = self._columns[index.column()] if col == 'R': editor = QLineEdit(parent) editor.setFrame(False) margins = editor.textMargins() padding = editor.fontMetrics().width(self._padding) + 1 margins.setLeft(margins.left() + padding) editor.setTextMargins(margins) return editor elif col in 'TPQ': editor = QSpinBox(parent) editor.setFrame(False) editor.setAlignment(Qt.AlignCenter) if col == 'Q': editor.setMaximum(9) else: editor.setMaximum(99999) return editor elif col in 'XYZABCUVWD': editor = QDoubleSpinBox(parent) editor.setFrame(False) editor.setAlignment(Qt.AlignCenter) editor.setDecimals(4) # editor.setStepType(QSpinBox.AdaptiveDecimalStepType) editor.setProperty('stepType', 1) # stepType was added in 5.12 editor.setRange(-1000, 1000) return editor elif col in 'IJ': editor = QDoubleSpinBox(parent) editor.setFrame(False) editor.setAlignment(Qt.AlignCenter) editor.setMaximum(360.0) editor.setMinimum(0.0) editor.setDecimals(4) # editor.setStepType(QSpinBox.AdaptiveDecimalStepType) editor.setProperty('stepType', 1) # stepType was added in 5.12 return editor return None
def __init__(self, spacing, *args, **kwargs): super().__init__(*args, **kwargs) min_val = min(spacing) start_value = [x / min_val for x in spacing] info_label = QLabel() info_label.setText( "This operation cannot be undone,\nit also update image spacing") self.start_value = start_value self.spacing = spacing self.x_spacing = QDoubleSpinBox() self.x_spacing.setRange(0, 100) self.x_spacing.setSingleStep(0.1) self.x_spacing.setDecimals(2) self.x_spacing.setValue(start_value[-1]) self.y_spacing = QDoubleSpinBox() self.y_spacing.setRange(0, 100) self.y_spacing.setSingleStep(0.1) self.y_spacing.setDecimals(2) self.y_spacing.setValue(start_value[-2]) self.z_spacing = QDoubleSpinBox() self.z_spacing.setRange(0, 100) self.z_spacing.setSingleStep(0.1) self.z_spacing.setDecimals(2) if len(start_value) == 3: self.z_spacing.setValue(start_value[0]) else: self.z_spacing.setDisabled(True) self.accept_button = QPushButton("Interpolate") self.accept_button.clicked.connect(self.accept) self.cancel_button = QPushButton("Cancel") self.cancel_button.clicked.connect(self.reject) layout = QGridLayout() layout.addWidget(info_label, 0, 0, 1, 2) layout.addWidget(QLabel("x scale"), 1, 0) layout.addWidget(self.x_spacing, 1, 1) layout.addWidget(QLabel("y scale"), 2, 0) layout.addWidget(self.y_spacing, 2, 1) if len(start_value) == 3: layout.addWidget(QLabel("z scale"), 3, 0) layout.addWidget(self.z_spacing, 3, 1) layout.addWidget(self.accept_button, 4, 0) layout.addWidget(self.cancel_button, 4, 1) self.setLayout(layout)