def __init__(self, layer): super().__init__(layer) self.layer.events.mode.connect(self.set_mode) self.layer.events.n_dimensional.connect(self._on_n_dim_change) self.layer.events.symbol.connect(self._on_symbol_change) self.layer.events.size.connect(self._on_size_change) self.layer.events.current_edge_color.connect( self._on_edge_color_change) self.layer.events.current_face_color.connect( self._on_face_color_change) self.layer.events.editable.connect(self._on_editable_change) sld = QSlider(Qt.Horizontal) sld.setFocusPolicy(Qt.NoFocus) sld.setMinimum(1) sld.setMaximum(100) sld.setSingleStep(1) value = self.layer.current_size sld.setValue(int(value)) sld.valueChanged.connect(self.changeSize) self.sizeSlider = sld face_comboBox = QComboBox() face_comboBox.addItems(self.layer._colors) face_comboBox.activated[str].connect(self.changeFaceColor) self.faceComboBox = face_comboBox self.faceColorSwatch = QFrame() self.faceColorSwatch.setObjectName('swatch') self.faceColorSwatch.setToolTip('Face color swatch') self._on_face_color_change() edge_comboBox = QComboBox() edge_comboBox.addItems(self.layer._colors) edge_comboBox.activated[str].connect(self.changeEdgeColor) self.edgeComboBox = edge_comboBox self.edgeColorSwatch = QFrame() self.edgeColorSwatch.setObjectName('swatch') self.edgeColorSwatch.setToolTip('Edge color swatch') self._on_edge_color_change() symbol_comboBox = QComboBox() symbol_comboBox.addItems([str(s) for s in Symbol]) index = symbol_comboBox.findText(self.layer.symbol, Qt.MatchFixedString) symbol_comboBox.setCurrentIndex(index) symbol_comboBox.activated[str].connect(self.changeSymbol) self.symbolComboBox = symbol_comboBox ndim_cb = QCheckBox() ndim_cb.setToolTip('N-dimensional points') ndim_cb.setChecked(self.layer.n_dimensional) ndim_cb.stateChanged.connect(self.change_ndim) self.ndimCheckBox = ndim_cb self.select_button = QtModeRadioButton(layer, 'select_points', Mode.SELECT, tooltip='Select points') self.addition_button = QtModeRadioButton(layer, 'add_points', Mode.ADD, tooltip='Add points') self.panzoom_button = QtModeRadioButton(layer, 'pan_zoom', Mode.PAN_ZOOM, tooltip='Pan/zoom', checked=True) self.delete_button = QtModePushButton( layer, 'delete_shape', slot=self.layer.remove_selected, tooltip='Delete selected points', ) self.button_group = QButtonGroup(self) self.button_group.addButton(self.select_button) self.button_group.addButton(self.addition_button) self.button_group.addButton(self.panzoom_button) button_row = QHBoxLayout() button_row.addWidget(self.delete_button) button_row.addWidget(self.addition_button) button_row.addWidget(self.select_button) button_row.addWidget(self.panzoom_button) button_row.addStretch(1) button_row.setSpacing(4) # grid_layout created in QtLayerControls # addWidget(widget, row, column, [row_span, column_span]) self.grid_layout.addLayout(button_row, 0, 1, 1, 2) self.grid_layout.addWidget(QLabel('opacity:'), 1, 0) self.grid_layout.addWidget(self.opacitySlider, 1, 1, 1, 2) self.grid_layout.addWidget(QLabel('point size:'), 2, 0) self.grid_layout.addWidget(self.sizeSlider, 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('symbol:'), 4, 0) self.grid_layout.addWidget(self.symbolComboBox, 4, 1, 1, 2) self.grid_layout.addWidget(QLabel('face color:'), 5, 0) self.grid_layout.addWidget(self.faceComboBox, 5, 2) self.grid_layout.addWidget(self.faceColorSwatch, 5, 1) self.grid_layout.addWidget(QLabel('edge color:'), 6, 0) self.grid_layout.addWidget(self.edgeComboBox, 6, 2) self.grid_layout.addWidget(self.edgeColorSwatch, 6, 1) self.grid_layout.addWidget(QLabel('n-dim:'), 7, 0) self.grid_layout.addWidget(self.ndimCheckBox, 7, 1) self.grid_layout.setRowStretch(8, 1) self.grid_layout.setColumnStretch(1, 1) self.grid_layout.setSpacing(4)
def create_layout(self): cancel_box = QHBoxLayout() cancel_box.addWidget(self.close_button) grid1 = QGridLayout() grid2 = QGridLayout() #----------------------------------------- # setup self.radio_rectangular = QRadioButton('Rectangular') self.radio_cylindrical = QRadioButton('Cylindrical') self.radio_spherical = QRadioButton('Spherical') coord_type_layout = QHBoxLayout() coord_type_layout.addWidget(self.radio_rectangular) coord_type_layout.addWidget(self.radio_cylindrical) coord_type_layout.addWidget(self.radio_spherical) checkboxs = QButtonGroup(self) checkboxs.addButton(self.checkbox_region_all) checkboxs.addButton(self.checkbox_region_ids) vbox1 = QVBoxLayout() vbox1.addWidget(self.checkbox_region_all) vbox1.addWidget(self.checkbox_region_ids) #vbox1.addLayout(checkboxs) #----------------------------------------- irow = 0 grid2.addWidget(self.name, irow, 0) grid2.addWidget(self.name_edit, irow, 1) irow += 1 #grid2.addWidget(self.name, irow, 0) grid2.addWidget(self.description_edit, irow, 1) irow += 1 grid2.addWidget(self.location_x, irow, 0) grid2.addWidget(self.location_x_edit, irow, 1) irow += 1 grid2.addWidget(self.location_y, irow, 0) grid2.addWidget(self.location_y_edit, irow, 1) irow += 1 grid2.addWidget(self.location_z, irow, 0) grid2.addWidget(self.location_z_edit, irow, 1) irow += 1 #| Name EngineInlet | #| RegionMode * RegionID | #| * All | #| | #| AllowedRegions: | #| Region ID 3 | #| | #| PickMode * All | #| Pick Mode x On/Off | #| Pick Angle 20 deg | #| | #| Revert | #| RenumberRegions | #| Close | grid2.addWidget(self.region_id, irow, 0) grid2.addWidget(self.region_id_edit, irow, 1) irow += 1 #grid2.addWidget(self.pick_mode, irow, 0) grid2.addWidget(self.checkbox_pick_mode, irow, 0) irow += 1 grid2.addWidget(self.pick_angle, irow, 0) grid2.addWidget(self.pick_angle_edit, irow, 1) irow += 1 #grid2.addWidget(self.pi, irow, 0) #grid2.addLayout(coord_type_layout, irow, 1) #irow += 1 #grid2.addWidget(self.location, irow, 0) #grid2.addLayout(location_layout, irow, 1) #irow += 1 #------------------------------------ vbox = QVBoxLayout() vbox.addLayout(grid1) #vbox.addLayout(vbox1) #vbox.addStretch() vbox.addWidget(self.table) vbox.addLayout(grid2) vbox.addStretch() #vbox.addWidget(self.check_apply) vbox.addLayout(cancel_box) self.setLayout(vbox)
def __init__(self, layer): super().__init__() self.layer = layer self.layer.events.mode.connect(self.set_mode) self.select_button = QtModeButton(layer, 'select', Mode.SELECT, 'Select mode') self.direct_button = QtModeButton(layer, 'direct', Mode.DIRECT, 'Direct select mode') self.panzoom_button = QtModeButton(layer, 'zoom', Mode.PAN_ZOOM, 'Pan/zoom mode') self.rectangle_button = QtModeButton(layer, 'rectangle', Mode.ADD_RECTANGLE, 'Add rectangles') self.ellipse_button = QtModeButton(layer, 'ellipse', Mode.ADD_ELLIPSE, 'Add ellipses') self.line_button = QtModeButton(layer, 'line', Mode.ADD_LINE, 'Add lines') self.path_button = QtModeButton(layer, 'path', Mode.ADD_PATH, 'Add paths') self.polygon_button = QtModeButton(layer, 'polygon', Mode.ADD_POLYGON, 'Add polygons') self.vertex_insert_button = QtModeButton(layer, 'vertex_insert', Mode.VERTEX_INSERT, 'Insert vertex') self.vertex_remove_button = QtModeButton(layer, 'vertex_remove', Mode.VERTEX_REMOVE, 'Remove vertex') self.move_front_button = QtMoveFrontButton(layer) self.move_back_button = QtMoveBackButton(layer) self.delete_button = QtDeleteShapeButton(layer) self.button_group = QButtonGroup(self) self.button_group.addButton(self.select_button) self.button_group.addButton(self.direct_button) self.button_group.addButton(self.panzoom_button) self.button_group.addButton(self.rectangle_button) self.button_group.addButton(self.ellipse_button) self.button_group.addButton(self.line_button) self.button_group.addButton(self.path_button) self.button_group.addButton(self.polygon_button) self.button_group.addButton(self.vertex_insert_button) self.button_group.addButton(self.vertex_remove_button) layout = QVBoxLayout() layout.setContentsMargins(12, 20, 10, 10) layout.addWidget(self.panzoom_button) layout.addWidget(self.select_button) layout.addWidget(self.direct_button) layout.addWidget(self.vertex_insert_button) layout.addWidget(self.vertex_remove_button) layout.addWidget(self.rectangle_button) layout.addWidget(self.ellipse_button) layout.addWidget(self.line_button) layout.addWidget(self.path_button) layout.addWidget(self.polygon_button) layout.addWidget(self.move_front_button) layout.addWidget(self.move_back_button) layout.addWidget(self.delete_button) layout.addStretch(0) self.setLayout(layout) self.setMouseTracking(True) self.panzoom_button.setChecked(True)
def __init__(self, layer): super().__init__(layer) self.layer.events.mode.connect(self.set_mode) self.layer.events.edge_width.connect(self._on_edge_width_change) self.layer.events.current_edge_color.connect( self._on_edge_color_change ) self.layer.events.current_face_color.connect( self._on_face_color_change ) self.layer.events.editable.connect(self._on_editable_change) sld = QSlider(Qt.Horizontal) sld.setFocusPolicy(Qt.NoFocus) sld.setMinimum(0) sld.setMaximum(40) sld.setSingleStep(1) value = self.layer.current_edge_width if isinstance(value, Iterable): if isinstance(value, list): value = np.asarray(value) value = value.mean() sld.setValue(int(value)) sld.valueChanged.connect(self.changeWidth) self.widthSlider = sld self.select_button = QtModeRadioButton( layer, 'select', Mode.SELECT, tooltip='Select shapes' ) self.direct_button = QtModeRadioButton( layer, 'direct', Mode.DIRECT, tooltip='Select vertices' ) self.panzoom_button = QtModeRadioButton( layer, 'zoom', Mode.PAN_ZOOM, tooltip='Pan/zoom', checked=True ) self.rectangle_button = QtModeRadioButton( layer, 'rectangle', Mode.ADD_RECTANGLE, tooltip='Add rectangles' ) self.ellipse_button = QtModeRadioButton( layer, 'ellipse', Mode.ADD_ELLIPSE, tooltip='Add ellipses' ) self.line_button = QtModeRadioButton( layer, 'line', Mode.ADD_LINE, tooltip='Add lines' ) self.path_button = QtModeRadioButton( layer, 'path', Mode.ADD_PATH, tooltip='Add paths' ) self.polygon_button = QtModeRadioButton( layer, 'polygon', Mode.ADD_POLYGON, tooltip='Add polygons' ) self.vertex_insert_button = QtModeRadioButton( layer, 'vertex_insert', Mode.VERTEX_INSERT, tooltip='Insert vertex' ) self.vertex_remove_button = QtModeRadioButton( layer, 'vertex_remove', Mode.VERTEX_REMOVE, tooltip='Remove vertex' ) self.move_front_button = QtModePushButton( layer, 'move_front', slot=self.layer.move_to_front, tooltip='Move to front', ) self.move_back_button = QtModePushButton( layer, 'move_back', slot=self.layer.move_to_back, tooltip='Move to back', ) self.delete_button = QtModePushButton( layer, 'delete_shape', slot=self.layer.remove_selected, tooltip='Delete selected shapes', ) self.button_group = QButtonGroup(self) self.button_group.addButton(self.select_button) self.button_group.addButton(self.direct_button) self.button_group.addButton(self.panzoom_button) self.button_group.addButton(self.rectangle_button) self.button_group.addButton(self.ellipse_button) self.button_group.addButton(self.line_button) self.button_group.addButton(self.path_button) self.button_group.addButton(self.polygon_button) self.button_group.addButton(self.vertex_insert_button) self.button_group.addButton(self.vertex_remove_button) button_grid = QGridLayout() button_grid.addWidget(self.vertex_remove_button, 0, 2) button_grid.addWidget(self.vertex_insert_button, 0, 3) button_grid.addWidget(self.delete_button, 0, 4) button_grid.addWidget(self.direct_button, 0, 5) button_grid.addWidget(self.select_button, 0, 6) button_grid.addWidget(self.panzoom_button, 0, 7) button_grid.addWidget(self.move_back_button, 1, 1) button_grid.addWidget(self.move_front_button, 1, 2) button_grid.addWidget(self.ellipse_button, 1, 3) button_grid.addWidget(self.rectangle_button, 1, 4) button_grid.addWidget(self.polygon_button, 1, 5) button_grid.addWidget(self.line_button, 1, 6) button_grid.addWidget(self.path_button, 1, 7) button_grid.setContentsMargins(5, 0, 0, 5) button_grid.setColumnStretch(0, 1) button_grid.setSpacing(4) self.faceColorEdit = QColorSwatchEdit( initial_color=self.layer.current_face_color, tooltip='click to set current face color', ) self._on_face_color_change() self.edgeColorEdit = QColorSwatchEdit( initial_color=self.layer.current_edge_color, tooltip='click to set current edge color', ) self._on_edge_color_change() self.faceColorEdit.color_changed.connect(self.changeFaceColor) self.edgeColorEdit.color_changed.connect(self.changeEdgeColor) # grid_layout created in QtLayerControls # addWidget(widget, row, column, [row_span, column_span]) self.grid_layout.addLayout(button_grid, 0, 0, 1, 2) self.grid_layout.addWidget(QLabel('opacity:'), 1, 0) self.grid_layout.addWidget(self.opacitySlider, 1, 1) self.grid_layout.addWidget(QLabel('edge width:'), 2, 0) self.grid_layout.addWidget(self.widthSlider, 2, 1) self.grid_layout.addWidget(QLabel('blending:'), 3, 0) self.grid_layout.addWidget(self.blendComboBox, 3, 1) self.grid_layout.addWidget(QLabel('face color:'), 4, 0) self.grid_layout.addWidget(self.faceColorEdit, 4, 1) self.grid_layout.addWidget(QLabel('edge color:'), 5, 0) self.grid_layout.addWidget(self.edgeColorEdit, 5, 1) self.grid_layout.setRowStretch(6, 1) self.grid_layout.setColumnStretch(1, 1) self.grid_layout.setSpacing(4)
def create_widgets(self): """creates the menu objects""" icase_max = 1000 # TODO: update 1000 self.icase_fringe = QLabel("iCase:") self.icase_fringe_edit = QSpinBox(self) self.icase_fringe_edit.setRange(1, icase_max) self.icase_fringe_edit.setSingleStep(1) self.icase_fringe_edit.setValue(self._icase_fringe) self.icase_fringe_edit.setToolTip( 'Case Number for the Scale/Phase Animation Type.\n' 'Defaults to the result you had shown when you clicked "Create Animation".\n' 'iCase can be seen by clicking "Apply" on a result.') self.scale = QLabel("True Scale:") self.scale_edit = QLineEdit(str(self._scale)) self.scale_button = QPushButton("Default") self.scale_edit.setToolTip('Scale factor of the "deflection"') self.scale_button.setToolTip('Sets the scale factor of the gif to %s' % self._scale) self.arrow_scale = QLabel("Arrow Scale:") self.arrow_scale_edit = QLineEdit(str(self._scale)) self.arrow_scale_button = QPushButton("Default") self.arrow_scale_edit.setToolTip('Scale factor of the "arrows"') self.arrow_scale_button.setToolTip( 'Sets the arrow scale factor of the gif to %s' % self._arrow_scale) self.arrow_scale.setVisible(False) self.arrow_scale_edit.setVisible(False) self.arrow_scale_button.setVisible(False) self.time = QLabel("Total Time (sec):") self.time_edit = QDoubleSpinBox(self) self.time_edit.setValue(self._default_time) self.time_edit.setRange(0.1, 10.0) self.time_edit.setDecimals(2) self.time_edit.setSingleStep(0.1) self.time_button = QPushButton("Default") self.time_edit.setToolTip("Total time of the gif") self.time_button.setToolTip('Sets the total time of the gif to %.2f' % self._default_time) self.fps = QLabel("Frames/Second:") self.fps_edit = QSpinBox(self) self.fps_edit.setRange(1, 60) self.fps_edit.setSingleStep(1) self.fps_edit.setValue(self._default_fps) self.fps_button = QPushButton("Default") self.fps_edit.setToolTip( "A higher FPS is smoother, but may not play well for large gifs") self.fps_button.setToolTip('Sets the FPS to %s' % self._default_fps) self.resolution = QLabel("Resolution Scale:") self.resolution_edit = QSpinBox(self) self.resolution_edit.setRange(1, 5) self.resolution_edit.setSingleStep(1) self.resolution_edit.setValue(self._default_resolution) self.resolution_button = QPushButton("Default") self.resolution_edit.setToolTip( 'Scales the window resolution by an integer factor') self.resolution_button.setToolTip('Sets the resolution to %s' % self._default_resolution) #----------------- # Time plot self.icase_start = QLabel("iCase Start:") self.icase_start_edit = QSpinBox(self) self.icase_start_edit.setRange(0, icase_max) self.icase_start_edit.setSingleStep(1) self.icase_start_edit.setValue(self._icase_fringe) self.icase_start_button = QPushButton("Default") self.icase_end = QLabel("iCase End:") self.icase_end_edit = QSpinBox(self) self.icase_end_edit.setRange(0, icase_max) self.icase_end_edit.setSingleStep(1) self.icase_end_edit.setValue(self._icase_fringe) self.icase_end_button = QPushButton("Default") self.icase_delta = QLabel("iCase Delta:") self.icase_delta_edit = QSpinBox(self) self.icase_delta_edit.setRange(1, icase_max) self.icase_delta_edit.setSingleStep(1) self.icase_delta_edit.setValue(1) self.icase_delta_button = QPushButton("Default") self.min_value_enable = QCheckBox() self.min_value = QLabel("Min Value:") self.min_value_edit = QLineEdit('') #self.min_value_edit.setRange(1, 1000) #self.min_value_edit.setSingleStep(1) #self.min_value_edit.setValue(1) self.min_value_button = QPushButton("Default") self.max_value_enable = QCheckBox() self.max_value = QLabel("Max Value:") self.max_value_edit = QLineEdit('') #self.min_value_edit.setRange(1, 1000) # TODO: update 1000 #self.min_value_edit.setSingleStep(1) #self.min_value_edit.setValue(1) self.max_value_button = QPushButton("Default") # TODO: enable this (uncomment) ------------------------------------------ #self.min_value_enable.hide() #self.min_value.hide() #self.min_value_edit.hide() #self.min_value_button.hide() #self.max_value_enable.hide() #self.max_value.hide() #self.max_value_edit.hide() #self.max_value_button.hide() # TODO: enable this (uncomment) ------------------------------------------ self.icase_start_edit.setToolTip('The first frame of the animation') self.icase_end_edit.setToolTip( 'The last frame of the animation\n' 'Assumes icase_start + nframes * icase_delta = icase_end') self.icase_delta_edit.setToolTip( 'The frame step size (to skip non-consecutive results).\n' 'Frame skipping can be used to:\n' " - skip across results that you don't want to plot\n" ' - adjust the FPS') self.min_value_edit.setToolTip( 'Min value of the legend (not supported)') self.max_value_edit.setToolTip( 'Max value of the legend (not supported)') #'time' : 0., #'default_time' : 0, #'icase_start' : 10, #'icase_delta' : 3, #'min_value' : 0., #'max_value' : 1000., self.browse_folder = QLabel('Output Directory:') self.browse_folder_edit = QLineEdit(str(self._default_dirname)) self.browse_folder_button = QPushButton('Browse') self.browse_folder_edit.setToolTip( 'Location to save the png/gif files') self.gif = QLabel("Gif Filename:") self.gif_edit = QLineEdit(str(self._default_name + '.gif')) self.gif_button = QPushButton('Default') self.gif_edit.setToolTip('Name of the gif') self.gif_button.setToolTip('Sets the name of the gif to %s.gif' % self._default_name) # scale / phase self.animate_scale_radio = QRadioButton("Animate Scale") self.animate_phase_radio = QRadioButton("Animate Phase") self.animate_time_radio = QRadioButton("Animate Time") self.animate_freq_sweeep_radio = QRadioButton( "Animate Frequency Sweep") self.animate_scale_radio.setToolTip( 'Animates the scale factor based on the "Animation Type"') self.animate_time_radio.setToolTip('Animates the time/load/mode step') self.animate_scale_radio.setChecked(self._default_is_scale) self.animate_phase_radio.setChecked(not self._default_is_scale) self.animate_time_radio.setChecked(False) msg = 'Scale : Animates the scale factor based on the "Animation Profile"\n' if self._default_phase is None: self.animate_phase_radio.setDisabled(True) self.animate_phase_radio.setToolTip('Animates the phase angle ' '(only for complex results)') msg += 'Phase : Animates the phase angle (only for complex results)\n' else: self.animate_phase_radio.setToolTip("Animates the phase angle") msg += 'Phase : Animates the phase angle\n' msg += ( 'Time : Animates the time/load/mode step\n' 'Freq Sweep : Animates a complex result across a range of frequencies ' '(not supported)\n') self.animate_freq_sweeep_radio.setDisabled(True) self.animate_freq_sweeep_radio.setToolTip( 'Animates a complex result across a range of frequencies (not supported)' ) self.animation_type = QLabel("Animation Type:") animation_type = OrderedDict() #scale_msg = 'Scale\n' #phase_msg = 'Phase\n' #time_msg = 'Time\n' #animation_types = [ #('Animate Scale', scale_msg), #('Animate Phase', phase_msg), #('Animate Time', time_msg), ##'Animate Frequency Sweep' #] if self._phase is not None: self.animation_types.append('Animate Phase') self.animation_types.append('Animate Time') self.animation_profile = QLabel("Animation Profile:") self.animation_profile_edit = QComboBox() for animation_profile in ANIMATION_PROFILES: self.animation_profile_edit.addItem(animation_profile) self.animation_profile_edit.setToolTip('The profile for a scaled GIF') self.animation_type_edit = QComboBox() # TODO: add a tooltip for each item for animation_type in self.animation_types: self.animation_type_edit.addItem(animation_type) #self.animation_type_edit.setToolTip('The profile for a scaled GIF') self.animation_type_edit.setToolTip(msg) self.csv_profile = QLabel("CSV profile:") self.csv_profile_edit = QLineEdit() self.csv_profile_browse_button = QPushButton('Browse') self.csv_profile_edit.setToolTip( 'The path to the CSV file of (Scale1, Scale2, Scale3, ...)') widget = QWidget(self) horizontal_vertical_group = QButtonGroup(widget) horizontal_vertical_group.addButton(self.animate_scale_radio) horizontal_vertical_group.addButton(self.animate_phase_radio) horizontal_vertical_group.addButton(self.animate_time_radio) horizontal_vertical_group.addButton(self.animate_freq_sweeep_radio) # animate in gui self.animate_in_gui_checkbox = QCheckBox("Animate In GUI?") self.animate_in_gui_checkbox.setChecked(True) # make images self.make_images_checkbox = QCheckBox("Make images?") self.make_images_checkbox.setChecked(True) # make images self.overwrite_images_checkbox = QCheckBox("Overwrite images?") self.overwrite_images_checkbox.setChecked(True) # delete images when finished self.delete_images_checkbox = QCheckBox("Delete images when finished?") self.delete_images_checkbox.setChecked(True) # endless loop self.repeat_checkbox = QCheckBox("Repeat?") self.repeat_checkbox.setChecked(True) self.repeat_checkbox.setToolTip( "Repeating creates an infinitely looping gif") # endless loop self.make_gif_checkbox = QCheckBox("Make Gif?") if IS_IMAGEIO: self.make_gif_checkbox.setChecked(True) else: self.make_gif_checkbox.setChecked(False) self.make_gif_checkbox.setEnabled(False) self.make_gif_checkbox.setToolTip( 'imageio is not available; install it') # bottom buttons self.step_button = QPushButton("Step") self.wipe_button = QPushButton("Wipe Deformed Shape") self.stop_button = QPushButton("Stop") self.run_button = QPushButton("Run All") self.step_button.setToolTip( 'Steps through the animation (for testing)') self.wipe_button.setToolTip( 'Removes the existing "deflecton" from the animation') self.stop_button.setToolTip('Stops the animation') self.run_button.setToolTip('Creates the animation') self.wipe_button.setEnabled(False) #self.wipe_button.hide() self.stop_button.setEnabled(False) #self.apply_button = QPushButton("Apply") #self.ok_button = QPushButton("OK") self.cancel_button = QPushButton("Close") #self.set_grid_time(enabled=False) #self.set_grid_scale(enabled=self._default_is_scale) if self._default_phase: self.on_animate_phase(force=True) else: self.on_animate_scale(force=True)
def __init__(self, settings: QSettings, parent: Optional[QObject] = None): # noinspection PyArgumentList super(NappingDialog, self).__init__(parent) checked_selection_mode = NappingDialog.SelectionMode( int( settings.value( self.SELECTION_MODE_SETTING, defaultValue=self.DEFAULT_SELECTION_MODE.value))) self._file_selection_mode_button = QRadioButton( 'Single file pair', self) self._file_selection_mode_button.setChecked( checked_selection_mode == NappingDialog.SelectionMode.FILE) self._dir_selection_mode_button = QRadioButton( 'Directories (multiple file pairs)', self) self._dir_selection_mode_button.setChecked( checked_selection_mode == NappingDialog.SelectionMode.DIR) self._selection_mode_buttons_group = QButtonGroup(self) self._selection_mode_buttons_group.addButton( self._file_selection_mode_button, NappingDialog.SelectionMode.FILE) self._selection_mode_buttons_group.addButton( self._dir_selection_mode_button, NappingDialog.SelectionMode.DIR) # noinspection PyUnresolvedReferences self._selection_mode_buttons_group.buttonClicked.connect( lambda _: self.refresh()) matching_strategy_combo_box_current_text = str( settings.value(self.MATCHING_STRATEGY_SETTING, defaultValue=self.DEFAULT_MATCHING_STRATEGY.value)) self._matching_strategy_combo_box = QComboBox(self) self._matching_strategy_combo_box.addItems( [x.value for x in NappingDialog.MatchingStrategy]) self._matching_strategy_combo_box.setCurrentText( matching_strategy_combo_box_current_text) # noinspection PyUnresolvedReferences self._matching_strategy_combo_box.currentIndexChanged.connect( lambda _: self.refresh()) source_images_file_line_edit_text = str( settings.value(self.SOURCE_IMAGES_SETTING, defaultValue=self.DEFAULT_SOURCE_IMAGES)) self._source_images_file_line_edit = FileLineEdit(check_exists=True, parent=self) self._source_images_file_line_edit.file_dialog.setWindowTitle( 'Select source image(s)') self._source_images_file_line_edit.setText( source_images_file_line_edit_text) # noinspection PyUnresolvedReferences self._source_images_file_line_edit.textChanged.connect( lambda text: self.refresh(text)) source_regex_line_edit_text = str( settings.value(self.SOURCE_REGEX_SETTING, defaultValue=self.DEFAULT_SOURCE_REGEX)) self._source_regex_label = QLabel(' RegEx:') self._source_regex_line_edit = QLineEdit(self) self._source_regex_line_edit.setText(source_regex_line_edit_text) # noinspection PyUnresolvedReferences self._source_regex_line_edit.textChanged.connect( lambda _: self.refresh()) target_images_file_line_edit_text = str( settings.value(self.TARGET_IMAGES_SETTING, defaultValue=self.DEFAULT_TARGET_IMAGES)) self._target_images_file_line_edit = FileLineEdit(check_exists=True, parent=self) self._target_images_file_line_edit.file_dialog.setWindowTitle( 'Select target image(s)') self._target_images_file_line_edit.setText( target_images_file_line_edit_text) # noinspection PyUnresolvedReferences self._target_images_file_line_edit.textChanged.connect( lambda text: self.refresh(text)) target_regex_line_edit_text = str( settings.value(self.TARGET_REGEX_SETTING, defaultValue=self.DEFAULT_TARGET_REGEX)) self._target_regex_label = QLabel(' RegEx:') self._target_regex_line_edit = QLineEdit(self) self._target_regex_line_edit.setText(target_regex_line_edit_text) # noinspection PyUnresolvedReferences self._target_regex_line_edit.textChanged.connect( lambda _: self.refresh()) control_points_dest_file_line_edit_text = str( settings.value(self.CONTROL_POINTS_DEST_SETTING, defaultValue=self.DEFAULT_CONTROL_POINTS_DEST)) self._control_points_dest_file_line_edit = FileLineEdit(parent=self) self._control_points_dest_file_line_edit.file_dialog.setWindowTitle( 'Select control points destination') self._control_points_dest_file_line_edit.setText( control_points_dest_file_line_edit_text) # noinspection PyUnresolvedReferences self._control_points_dest_file_line_edit.textChanged.connect( lambda text: self.refresh(text)) joint_transform_dest_file_line_edit_text = str( settings.value(self.JOINT_TRANSFORM_DEST_SETTING, defaultValue=self.DEFAULT_JOINT_TRANSFORM_DEST)) self._joint_transform_dest_file_line_edit = FileLineEdit(parent=self) self._joint_transform_dest_file_line_edit.file_dialog.setWindowTitle( 'Select joint transform destination') self._joint_transform_dest_file_line_edit.setText( joint_transform_dest_file_line_edit_text) # noinspection PyUnresolvedReferences self._joint_transform_dest_file_line_edit.textChanged.connect( lambda text: self.refresh(text)) transform_type_combo_box_current_text = str( settings.value(self.TRANSFORM_TYPE_SETTING, defaultValue=self.DEFAULT_TRANSFORM_TYPE)) self._transform_type_combo_box = QComboBox(self) self._transform_type_combo_box.addItems( [x.value for x in NappingDialog.TransformType]) self._transform_type_combo_box.setCurrentText( transform_type_combo_box_current_text) # noinspection PyUnresolvedReferences self._transform_type_combo_box.currentIndexChanged.connect( lambda _: self.refresh()) source_coords_file_line_edit_text = str( settings.value(self.SOURCE_COORDS_SETTING, defaultValue=self.DEFAULT_SOURCE_COORDS)) self._source_coords_file_line_edit = FileLineEdit(check_exists=True, parent=self) self._source_coords_file_line_edit.file_dialog.setWindowTitle( 'Select source coordinates') self._source_coords_file_line_edit.setText( source_coords_file_line_edit_text) # noinspection PyUnresolvedReferences self._source_coords_file_line_edit.textChanged.connect( lambda text: self.refresh(text)) source_coords_regex_line_edit_text = str( settings.value(self.SOURCE_COORDS_REGEX_SETTING, defaultValue=self.DEFAULT_SOURCE_COORDS_REGEX)) self._source_coords_regex_label = QLabel(' RegEx:') self._source_coords_regex_line_edit = QLineEdit(self) self._source_coords_regex_line_edit.setText( source_coords_regex_line_edit_text) # noinspection PyUnresolvedReferences self._source_coords_regex_line_edit.textChanged.connect( lambda _: self.refresh()) transformed_coords_dest_file_line_edit_text = str( settings.value(self.TRANSFORMED_COORDS_DEST_SETTING, defaultValue=self.DEFAULT_TRANSFORMED_COORDS_DEST)) self._transformed_coords_dest_file_line_edit = FileLineEdit( parent=self) self._transformed_coords_dest_file_line_edit.file_dialog.setWindowTitle( 'Select transformed coordinates destination') self._transformed_coords_dest_file_line_edit.setText( transformed_coords_dest_file_line_edit_text) # noinspection PyUnresolvedReferences self._transformed_coords_dest_file_line_edit.textChanged.connect( lambda text: self.refresh(text)) pre_transform_file_line_edit_text = str( settings.value(self.PRE_TRANSFORM_SETTING, defaultValue=self.DEFAULT_PRE_TRANSFORM)) self._pre_transform_file_line_edit = FileLineEdit(parent=self) self._pre_transform_file_line_edit.file_dialog.setWindowTitle( 'Select pre-transform') self._pre_transform_file_line_edit.setText( pre_transform_file_line_edit_text) self._pre_transform_file_line_edit.file_dialog.setFileMode( QFileDialog.ExistingFile) self._pre_transform_file_line_edit.file_dialog.setNameFilter( 'Numpy files (*.npy)') # noinspection PyUnresolvedReferences self._pre_transform_file_line_edit.textChanged.connect( lambda text: self.refresh(text)) post_transform_file_line_edit_text = str( settings.value(self.POST_TRANSFORM_SETTING, defaultValue=self.DEFAULT_POST_TRANSFORM)) self._post_transform_file_line_edit = FileLineEdit(parent=self) self._post_transform_file_line_edit.file_dialog.setWindowTitle( 'Select post-transform') self._post_transform_file_line_edit.file_dialog.setFileMode( QFileDialog.ExistingFile) self._post_transform_file_line_edit.file_dialog.setNameFilter( 'Numpy files (*.npy)') self._post_transform_file_line_edit.setText( post_transform_file_line_edit_text) # noinspection PyUnresolvedReferences self._post_transform_file_line_edit.textChanged.connect( lambda text: self.refresh(text)) self._button_box = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self) # noinspection PyUnresolvedReferences self._button_box.rejected.connect(self.reject) # noinspection PyUnresolvedReferences @self._button_box.accepted.connect def on_button_box_accepted(): settings.setValue(self.SELECTION_MODE_SETTING, self.selection_mode.value) settings.setValue(self.SOURCE_IMAGES_SETTING, str(self.source_images_path)) settings.setValue(self.SOURCE_REGEX_SETTING, self.source_regex) settings.setValue(self.TARGET_IMAGES_SETTING, str(self.target_images_path)) settings.setValue(self.TARGET_REGEX_SETTING, self.target_regex) settings.setValue(self.CONTROL_POINTS_DEST_SETTING, str(self.control_points_dest_path)) settings.setValue(self.JOINT_TRANSFORM_DEST_SETTING, str(self.joint_transform_dest_path)) settings.setValue(self.TRANSFORM_TYPE_SETTING, self.transform_type.value) settings.setValue(self.MATCHING_STRATEGY_SETTING, self.matching_strategy.value) settings.setValue(self.SOURCE_COORDS_SETTING, str(self.source_coords_path or '')) settings.setValue(self.SOURCE_COORDS_REGEX_SETTING, self.source_coords_regex) settings.setValue(self.TRANSFORMED_COORDS_DEST_SETTING, str(self.transformed_coords_dest_path or '')) settings.setValue(self.PRE_TRANSFORM_SETTING, str(self.pre_transform_path or '')) settings.setValue(self.POST_TRANSFORM_SETTING, str(self.post_transform_path or '')) settings.sync() self.accept() required_group_box = QGroupBox(self) required_group_box_layout = QFormLayout() required_group_box_layout.setLabelAlignment(Qt.AlignLeft) required_group_box_layout.setRowWrapPolicy(QFormLayout.DontWrapRows) required_group_box_layout.setFieldGrowthPolicy( QFormLayout.AllNonFixedFieldsGrow) required_group_box_layout.addRow('Source image(s):', self._source_images_file_line_edit) required_group_box_layout.addRow(self._source_regex_label, self._source_regex_line_edit) required_group_box_layout.addRow('Target image(s):', self._target_images_file_line_edit) required_group_box_layout.addRow(self._target_regex_label, self._target_regex_line_edit) required_group_box_layout.addRow( 'Control points dest.:', self._control_points_dest_file_line_edit) required_group_box_layout.addRow( 'Joint transform dest.:', self._joint_transform_dest_file_line_edit) required_group_box_layout.addRow('Transform type:', self._transform_type_combo_box) required_group_box.setLayout(required_group_box_layout) optional_group_box = QGroupBox(self) optional_group_box_layout = QFormLayout() optional_group_box_layout.setLabelAlignment(Qt.AlignLeft) optional_group_box_layout.setRowWrapPolicy(QFormLayout.DontWrapRows) optional_group_box_layout.setFieldGrowthPolicy( QFormLayout.AllNonFixedFieldsGrow) optional_group_box_layout.addRow('Source coordinates:', self._source_coords_file_line_edit) optional_group_box_layout.addRow(self._source_coords_regex_label, self._source_coords_regex_line_edit) optional_group_box_layout.addRow( 'Transformed coord. dest.:', self._transformed_coords_dest_file_line_edit) optional_group_box_layout.addRow('Pre-transform:', self._pre_transform_file_line_edit) optional_group_box_layout.addRow('Post-transform:', self._post_transform_file_line_edit) optional_group_box.setLayout(optional_group_box_layout) layout = QVBoxLayout() mode_layout = QHBoxLayout() # noinspection PyArgumentList mode_layout.addWidget(self._file_selection_mode_button) # noinspection PyArgumentList mode_layout.addWidget(self._dir_selection_mode_button) # noinspection PyArgumentList mode_layout.addWidget(self._matching_strategy_combo_box) mode_layout.addStretch() layout.addLayout(mode_layout) # noinspection PyArgumentList layout.addWidget(required_group_box) # noinspection PyArgumentList layout.addWidget(optional_group_box) # noinspection PyArgumentList layout.addWidget(self._button_box) self.setLayout(layout) self.setWindowTitle('Control point matching') self.setMinimumWidth(600) self.refresh()
def setup_page(self): about_label = QLabel( _("The following are the default options for " "running files.These options may be overriden " "using the <b>Configuration per file</b> entry " "of the <b>Run</b> menu.")) about_label.setWordWrap(True) interpreter_group = QGroupBox(_("Console")) interpreter_bg = QButtonGroup(interpreter_group) self.current_radio = self.create_radiobutton( CURRENT_INTERPRETER, CURRENT_INTERPRETER_OPTION, True, button_group=interpreter_bg) self.dedicated_radio = self.create_radiobutton( DEDICATED_INTERPRETER, DEDICATED_INTERPRETER_OPTION, False, button_group=interpreter_bg) self.systerm_radio = self.create_radiobutton( SYSTERM_INTERPRETER, SYSTERM_INTERPRETER_OPTION, False, button_group=interpreter_bg) interpreter_layout = QVBoxLayout() interpreter_group.setLayout(interpreter_layout) interpreter_layout.addWidget(self.current_radio) interpreter_layout.addWidget(self.dedicated_radio) interpreter_layout.addWidget(self.systerm_radio) general_group = QGroupBox(_("General settings")) post_mortem = self.create_checkbox(POST_MORTEM, 'post_mortem', False) clear_variables = self.create_checkbox(CLEAR_ALL_VARIABLES, 'clear_namespace', False) general_layout = QVBoxLayout() general_layout.addWidget(clear_variables) general_layout.addWidget(post_mortem) general_group.setLayout(general_layout) wdir_group = QGroupBox(_("Working Directory settings")) wdir_bg = QButtonGroup(wdir_group) wdir_label = QLabel(_("Default working directory is:")) wdir_label.setWordWrap(True) dirname_radio = self.create_radiobutton(FILE_DIR, WDIR_USE_SCRIPT_DIR_OPTION, True, button_group=wdir_bg) cwd_radio = self.create_radiobutton(CW_DIR, WDIR_USE_CWD_DIR_OPTION, False, button_group=wdir_bg) thisdir_radio = self.create_radiobutton(FIXED_DIR, WDIR_USE_FIXED_DIR_OPTION, False, button_group=wdir_bg) thisdir_bd = self.create_browsedir("", WDIR_FIXED_DIR_OPTION, getcwd()) thisdir_radio.toggled.connect(thisdir_bd.setEnabled) dirname_radio.toggled.connect(thisdir_bd.setDisabled) cwd_radio.toggled.connect(thisdir_bd.setDisabled) thisdir_layout = QHBoxLayout() thisdir_layout.addWidget(thisdir_radio) thisdir_layout.addWidget(thisdir_bd) wdir_layout = QVBoxLayout() wdir_layout.addWidget(wdir_label) wdir_layout.addWidget(dirname_radio) wdir_layout.addWidget(cwd_radio) wdir_layout.addLayout(thisdir_layout) wdir_group.setLayout(wdir_layout) external_group = QGroupBox(_("External system terminal")) interact_after = self.create_checkbox(INTERACT, 'interact', False) external_layout = QVBoxLayout() external_layout.addWidget(interact_after) external_group.setLayout(external_layout) firstrun_cb = self.create_checkbox( ALWAYS_OPEN_FIRST_RUN % _("Run Settings dialog"), ALWAYS_OPEN_FIRST_RUN_OPTION, False) vlayout = QVBoxLayout() vlayout.addWidget(about_label) vlayout.addSpacing(10) vlayout.addWidget(interpreter_group) vlayout.addWidget(general_group) vlayout.addWidget(wdir_group) vlayout.addWidget(external_group) vlayout.addWidget(firstrun_cb) vlayout.addStretch(1) self.setLayout(vlayout)
def setup_page(self): run_dlg = _("Run Settings") run_menu = _("Run") about_label = QLabel(_("The following are the default <i>%s</i>. "\ "These options may be overriden using the "\ "<b>%s</b> dialog box (see the <b>%s</b> menu)"\ ) % (run_dlg, run_dlg, run_menu)) about_label.setWordWrap(True) interpreter_group = QGroupBox(_("Console")) interpreter_bg = QButtonGroup(interpreter_group) self.current_radio = self.create_radiobutton(CURRENT_INTERPRETER, CURRENT_INTERPRETER_OPTION, True, button_group=interpreter_bg) self.dedicated_radio = self.create_radiobutton(DEDICATED_INTERPRETER, DEDICATED_INTERPRETER_OPTION, False, button_group=interpreter_bg) self.systerm_radio = self.create_radiobutton(SYSTERM_INTERPRETER, SYSTERM_INTERPRETER_OPTION, False, button_group=interpreter_bg) interpreter_layout = QVBoxLayout() interpreter_group.setLayout(interpreter_layout) interpreter_layout.addWidget(self.current_radio) interpreter_layout.addWidget(self.dedicated_radio) interpreter_layout.addWidget(self.systerm_radio) general_group = QGroupBox(_("General settings")) wdir_bg = QButtonGroup(general_group) wdir_label = QLabel(_("Default working directory is:")) wdir_label.setWordWrap(True) dirname_radio = self.create_radiobutton(_("the script directory"), WDIR_USE_SCRIPT_DIR_OPTION, True, button_group=wdir_bg) thisdir_radio = self.create_radiobutton(_("the following directory:"), WDIR_USE_FIXED_DIR_OPTION, False, button_group=wdir_bg) thisdir_bd = self.create_browsedir("", WDIR_FIXED_DIR_OPTION, getcwd()) thisdir_radio.toggled.connect(thisdir_bd.setEnabled) dirname_radio.toggled.connect(thisdir_bd.setDisabled) thisdir_layout = QHBoxLayout() thisdir_layout.addWidget(thisdir_radio) thisdir_layout.addWidget(thisdir_bd) post_mortem = self.create_checkbox( _("Enter debugging mode when errors appear during execution"), 'post_mortem', False) clear_variables = self.create_checkbox(CLEAR_ALL_VARIABLES, 'clear_namespace', False) general_layout = QVBoxLayout() general_layout.addWidget(clear_variables) general_layout.addWidget(wdir_label) general_layout.addWidget(dirname_radio) general_layout.addLayout(thisdir_layout) general_layout.addWidget(post_mortem) general_group.setLayout(general_layout) dedicated_group = QGroupBox(_("Dedicated Python console")) interact_after = self.create_checkbox( _("Interact with the Python console after execution"), 'interact', False) show_warning = self.create_checkbox( _("Show warning when killing running processes"), 'show_kill_warning', True) dedicated_layout = QVBoxLayout() dedicated_layout.addWidget(interact_after) dedicated_layout.addWidget(show_warning) dedicated_group.setLayout(dedicated_layout) firstrun_cb = self.create_checkbox( ALWAYS_OPEN_FIRST_RUN % _("Run Settings dialog"), ALWAYS_OPEN_FIRST_RUN_OPTION, False) vlayout = QVBoxLayout() vlayout.addWidget(about_label) vlayout.addSpacing(10) vlayout.addWidget(interpreter_group) vlayout.addWidget(general_group) vlayout.addWidget(dedicated_group) vlayout.addWidget(firstrun_cb) vlayout.addStretch(1) self.setLayout(vlayout)
def __init__(self, settings): BaseWidget.__init__(self, settings=settings) inf = float('inf') def set_spin(spin, minVal=-inf, maxVal=+inf, decimals=3): spin.setRange(minVal, maxVal) spin.setDecimals(decimals) spin.setSingleStep(0.01) def tip(widget, text): if text: widget.setToolTip(text) return widget def setEnabled(widget, *widgets): """enables widget, when value of all widgets evaluates to true""" def setEnabled(): widget.setEnabled(all(w.isChecked() for w in widgets)) for w in widgets: w.toggled.connect(setEnabled) return widget def DoubleEdit(): edit = SmallQLineEdit() edit.setValidator(QDoubleValidator()) return edit # ui data elements self.prefix = tip(QLineEdit(), self.TIP_prefix) self.dataDir = tip(QLineEdit(), self.TIP_dataDir) self.saveDir = tip(QLineEdit(), self.TIP_saveDir) self.vanRuns = tip(QLineEdit(), self.TIP_vanRuns) self.vanCmnt = tip(QLineEdit(), self.TIP_vanCmnt) self.vanTemp = tip(DoubleEdit(), self.TIP_vanTemp) self.ecRuns = tip(SmallQLineEdit(), self.TIP_ecRuns) self.ecTemp = tip(DoubleEdit(), self.TIP_ecTemp) self.ecFactor = tip(QDoubleSpinBox(), self.TIP_ecFactor) set_spin(self.ecFactor, 0, 1) self.binEon = tip(QCheckBox(), self.TIP_binEon) self.binEstart = setEnabled(tip(QDoubleSpinBox(), self.TIP_binEstart), self.binEon) self.binEstep = setEnabled(tip(QDoubleSpinBox(), self.TIP_binEstep), self.binEon) self.binEend = setEnabled(tip(QDoubleSpinBox(), self.TIP_binEend), self.binEon) set_spin(self.binEstart) set_spin(self.binEstep, decimals=4) set_spin(self.binEend) self.binQon = setEnabled(tip(QCheckBox(), self.TIP_binQon), self.binEon) self.binQstart = setEnabled(tip(QDoubleSpinBox(), self.TIP_binQstart), self.binEon, self.binQon) self.binQstep = setEnabled(tip(QDoubleSpinBox(), self.TIP_binQstep), self.binEon, self.binQon) self.binQend = setEnabled(tip(QDoubleSpinBox(), self.TIP_binQend), self.binEon, self.binQon) set_spin(self.binQstart) set_spin(self.binQstep) set_spin(self.binQend) self.maskDetectors = tip(QLineEdit(), self.TIP_maskDetectors) headers = ('Data runs', 'Comment', 'T (K)') self.dataRunsView = tip( DataTableView(self, headers, TOFTOFSetupWidget.TofTofDataTableModel), self.TIP_dataRunsView) self.dataRunsView.horizontalHeader().setStretchLastSection(True) self.dataRunsView.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) self.runDataModel = self.dataRunsView.model() # ui controls self.btnDataDir = tip(QPushButton('Browse'), self.TIP_btnDataDir) self.btnSaveDir = tip(QPushButton('Browse'), self.TIP_btnSaveDir) self.chkSubtractECVan = tip( QCheckBox('Subtract empty can from vanadium'), self.TIP_chkSubtractECVan) self.vanEcFactor = setEnabled( tip(QDoubleSpinBox(), self.TIP_vanEcFactor), self.chkSubtractECVan) set_spin(self.vanEcFactor, 0, 1) self.chkReplaceNaNs = setEnabled( tip(QCheckBox(u'Replace special values in S(Q, ω) with 0'), self.TIP_chkReplaceNaNs), self.binEon) self.chkCreateDiff = setEnabled( tip(QCheckBox('Create diffractograms'), self.TIP_chkCreateDiff), self.binEon) self.chkKeepSteps = tip(QCheckBox('Keep intermediate steps'), self.TIP_chkKeepSteps) self.chkSofTWNxspe = setEnabled( tip(QCheckBox('NXSPE'), self.TIP_chkNxspe), self.binEon) self.chkSofTWNexus = tip(QCheckBox('NeXus'), self.TIP_chkNexus) self.chkSofTWAscii = tip(QCheckBox('Ascii'), self.TIP_chkAscii) self.chkSofQWNexus = setEnabled( tip(QCheckBox('NeXus'), self.TIP_chkNexus), self.binEon, self.binQon) self.chkSofQWAscii = setEnabled( tip(QCheckBox('Ascii'), self.TIP_chkAscii), self.binEon, self.binQon) self.rbtNormaliseNone = tip(QRadioButton('none'), self.TIP_rbtNormaliseNone) self.rbtNormaliseMonitor = tip(QRadioButton('to monitor'), self.TIP_rbtNormaliseMonitor) self.rbtNormaliseTime = tip(QRadioButton('to time'), self.TIP_rbtNormaliseTime) self.rbtCorrectTOFNone = tip(QRadioButton('none'), self.TIP_rbtCorrectTOFNone) self.rbtCorrectTOFVan = tip(QRadioButton('vanadium'), self.TIP_rbtCorrectTOFVan) self.rbtCorrectTOFSample = tip(QRadioButton('sample'), self.TIP_rbtCorrectTOFSample) # ui layout def _box(cls, widgets): box = cls() for wgt in widgets: if isinstance(wgt, QLayout): box.addLayout(wgt) elif isinstance(wgt, QWidget): box.addWidget(wgt) else: box.addStretch(wgt) return box def hbox(*widgets): return _box(QHBoxLayout, widgets) def vbox(*widgets): return _box(QVBoxLayout, widgets) def label(text, tip): label = QLabel(text) if tip: label.setToolTip(tip) return label self.gbSave = QGroupBox('Save reduced data') self.gbSave.setCheckable(True) gbDataDir = QGroupBox('Data search directory') gbPrefix = QGroupBox('Workspace prefix') gbOptions = QGroupBox('Options') gbInputs = QGroupBox('Inputs') gbBinning = QGroupBox('Binning') gbData = QGroupBox('Data') box = QVBoxLayout() self._layout.addLayout(box) box.addLayout( hbox(vbox(gbDataDir, gbInputs, gbBinning, gbOptions, 1), vbox(gbPrefix, gbData, self.gbSave))) gbDataDir.setLayout(hbox(self.dataDir, self.btnDataDir)) gbPrefix.setLayout(hbox(self.prefix, )) grid = QGridLayout() grid.addWidget(self.chkSubtractECVan, 0, 0, 1, 4) grid.addWidget(label('Normalise', 'tip'), 1, 0) grid.addWidget(self.rbtNormaliseNone, 1, 1) grid.addWidget(self.rbtNormaliseMonitor, 1, 2) grid.addWidget(self.rbtNormaliseTime, 1, 3) grid.addWidget(QLabel('Correct TOF'), 2, 0) grid.addWidget(self.rbtCorrectTOFNone, 2, 1) grid.addWidget(self.rbtCorrectTOFVan, 2, 2) grid.addWidget(self.rbtCorrectTOFSample, 2, 3) grid.addWidget(self.chkReplaceNaNs, 3, 0, 1, 4) grid.addWidget(self.chkCreateDiff, 4, 0, 1, 4) grid.addWidget(self.chkKeepSteps, 5, 0, 1, 4) grid.setColumnStretch(4, 1) gbOptions.setLayout(grid) btnGroup = QButtonGroup(self) btnGroup.addButton(self.rbtNormaliseNone) btnGroup.addButton(self.rbtNormaliseMonitor) btnGroup.addButton(self.rbtNormaliseTime) btnGroup = QButtonGroup(self) btnGroup.addButton(self.rbtCorrectTOFNone) btnGroup.addButton(self.rbtCorrectTOFVan) btnGroup.addButton(self.rbtCorrectTOFSample) grid = QGridLayout() grid.addWidget(QLabel('Vanadium runs'), 0, 0) grid.addWidget(self.vanRuns, 0, 1, 1, 3) grid.addWidget(QLabel('Van. comment'), 1, 0) grid.addWidget(self.vanCmnt, 1, 1, 1, 1) grid.addLayout(hbox(QLabel('EC factor'), self.vanEcFactor), 1, 2, 1, 1) grid.addLayout(hbox(QLabel('T (K)'), self.vanTemp), 1, 3) grid.addWidget(QLabel('Empty can runs'), 2, 0) grid.addWidget(self.ecRuns, 2, 1, 1, 1) grid.addLayout(hbox(QLabel('EC factor'), self.ecFactor), 2, 2, 1, 1) grid.addLayout(hbox(QLabel('T (K)'), self.ecTemp), 2, 3) grid.addWidget(QLabel('Mask detectors'), 3, 0) grid.addWidget(self.maskDetectors, 3, 1, 1, 3) gbInputs.setLayout(grid) grid = QGridLayout() grid.addWidget(QLabel('on'), 0, 1) grid.addWidget(QLabel('start'), 0, 2) grid.addWidget(QLabel('step'), 0, 3) grid.addWidget(QLabel('end'), 0, 4) grid.addWidget(QLabel('Energy'), 1, 0) grid.addWidget(self.binEon, 1, 1) grid.addWidget(self.binEstart, 1, 2) grid.addWidget(self.binEstep, 1, 3) grid.addWidget(self.binEend, 1, 4) grid.addWidget(QLabel('Q'), 2, 0) grid.addWidget(self.binQon, 2, 1) grid.addWidget(self.binQstart, 2, 2) grid.addWidget(self.binQstep, 2, 3) grid.addWidget(self.binQend, 2, 4) for col in (0, 2, 3, 4): grid.setColumnStretch(col, 1) gbBinning.setLayout(grid) gbData.setLayout(hbox(self.dataRunsView)) grid = QGridLayout() saveDirGroup = hbox(self.saveDir, self.btnSaveDir) grid.addWidget(QLabel('Directory'), 0, 0) grid.addLayout(saveDirGroup, 0, 1, 1, 4) grid.addWidget(setEnabled(QLabel(u'S(Q, ω):'), self.binEon), 1, 0) grid.addWidget(self.chkSofQWNexus, 1, 1) grid.addWidget(self.chkSofQWAscii, 1, 2) grid.addItem(QSpacerItem(5, 5, hPolicy=QSizePolicy.Expanding), 1, 4) grid.addWidget(QLabel(u'S(2θ, ω):'), 2, 0) grid.addWidget(self.chkSofTWNexus, 2, 1) grid.addWidget(self.chkSofTWAscii, 2, 2) grid.addWidget(self.chkSofTWNxspe, 2, 3) self.gbSave.setLayout(grid) # handle signals self.btnDataDir.clicked.connect(self._onDataDir) self.btnSaveDir.clicked.connect(self._onSaveDir) self.runDataModel.selectCell.connect(self._onSelectedCell)
def __init__(self, layer): super().__init__(layer) self.layer.events.mode.connect(self.set_mode) self.layer.events.edge_width.connect(self._on_edge_width_change) self.layer.events.edge_color.connect(self._on_edge_color_change) self.layer.events.face_color.connect(self._on_face_color_change) self.layer.events.editable.connect(self._on_editable_change) sld = QSlider(Qt.Horizontal) sld.setFocusPolicy(Qt.NoFocus) sld.setMinimum(0) sld.setMaximum(40) sld.setSingleStep(1) value = self.layer.edge_width if isinstance(value, Iterable): if isinstance(value, list): value = np.asarray(value) value = value.mean() sld.setValue(int(value)) sld.valueChanged[int].connect( lambda value=sld: self.changeWidth(value) ) self.widthSlider = sld face_comboBox = QComboBox() colors = self.layer._colors for c in colors: face_comboBox.addItem(c) face_comboBox.activated[str].connect( lambda text=face_comboBox: self.changeFaceColor(text) ) self.faceComboBox = face_comboBox self.faceColorSwatch = QFrame() self.faceColorSwatch.setObjectName('swatch') self.faceColorSwatch.setToolTip('Face color swatch') self._on_face_color_change(None) 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.changeEdgeColor(text) ) self.edgeComboBox = edge_comboBox self.edgeColorSwatch = QFrame() self.edgeColorSwatch.setObjectName('swatch') self.edgeColorSwatch.setToolTip('Edge color swatch') self._on_edge_color_change(None) self.select_button = QtModeButton( layer, 'select', Mode.SELECT, 'Select shapes' ) self.direct_button = QtModeButton( layer, 'direct', Mode.DIRECT, 'Select vertices' ) self.panzoom_button = QtModeButton( layer, 'zoom', Mode.PAN_ZOOM, 'Pan/zoom' ) self.rectangle_button = QtModeButton( layer, 'rectangle', Mode.ADD_RECTANGLE, 'Add rectangles' ) self.ellipse_button = QtModeButton( layer, 'ellipse', Mode.ADD_ELLIPSE, 'Add ellipses' ) self.line_button = QtModeButton( layer, 'line', Mode.ADD_LINE, 'Add lines' ) self.path_button = QtModeButton( layer, 'path', Mode.ADD_PATH, 'Add paths' ) self.polygon_button = QtModeButton( layer, 'polygon', Mode.ADD_POLYGON, 'Add polygons' ) self.vertex_insert_button = QtModeButton( layer, 'vertex_insert', Mode.VERTEX_INSERT, 'Insert vertex' ) self.vertex_remove_button = QtModeButton( layer, 'vertex_remove', Mode.VERTEX_REMOVE, 'Remove vertex' ) self.move_front_button = QtMoveFrontButton(layer) self.move_back_button = QtMoveBackButton(layer) self.delete_button = QtDeleteShapeButton(layer) self.panzoom_button.setChecked(True) self.button_group = QButtonGroup(self) self.button_group.addButton(self.select_button) self.button_group.addButton(self.direct_button) self.button_group.addButton(self.panzoom_button) self.button_group.addButton(self.rectangle_button) self.button_group.addButton(self.ellipse_button) self.button_group.addButton(self.line_button) self.button_group.addButton(self.path_button) self.button_group.addButton(self.polygon_button) self.button_group.addButton(self.vertex_insert_button) self.button_group.addButton(self.vertex_remove_button) # grid_layout created in QtLayerControls # addWidget(widget, row, column, [row_span, column_span]) self.grid_layout.addWidget(self.panzoom_button, 0, 6) self.grid_layout.addWidget(self.select_button, 0, 5) self.grid_layout.addWidget(self.direct_button, 0, 4) self.grid_layout.addWidget(self.delete_button, 1, 1) self.grid_layout.addWidget(self.vertex_insert_button, 0, 3) self.grid_layout.addWidget(self.vertex_remove_button, 0, 2) self.grid_layout.addWidget(self.move_front_button, 0, 1) self.grid_layout.addWidget(self.move_back_button, 0, 0) self.grid_layout.addWidget(self.rectangle_button, 1, 2) self.grid_layout.addWidget(self.ellipse_button, 1, 3) self.grid_layout.addWidget(self.line_button, 1, 4) self.grid_layout.addWidget(self.path_button, 1, 5) self.grid_layout.addWidget(self.polygon_button, 1, 6) self.grid_layout.addWidget(QLabel('opacity:'), 2, 0, 1, 3) self.grid_layout.addWidget(self.opacitySilder, 2, 3, 1, 4) self.grid_layout.addWidget(QLabel('edge width:'), 3, 0, 1, 3) self.grid_layout.addWidget(self.widthSlider, 3, 3, 1, 4) self.grid_layout.addWidget(QLabel('blending:'), 4, 0, 1, 3) self.grid_layout.addWidget(self.blendComboBox, 4, 3, 1, 4) self.grid_layout.addWidget(QLabel('face color:'), 5, 0, 1, 3) self.grid_layout.addWidget(self.faceComboBox, 5, 3, 1, 3) self.grid_layout.addWidget(self.faceColorSwatch, 5, 6) self.grid_layout.addWidget(QLabel('edge color:'), 6, 0, 1, 3) self.grid_layout.addWidget(self.edgeComboBox, 6, 3, 1, 3) self.grid_layout.addWidget(self.edgeColorSwatch, 6, 6) self.grid_layout.setRowStretch(7, 1) self.grid_layout.setVerticalSpacing(4)
def create_layout(self): cancel_box = QHBoxLayout() cancel_box.addWidget(self.close_button) grid1 = QGridLayout() grid2 = QGridLayout() #----------------------------------------- # setup self.radio_rectangular = QRadioButton('Rectangular') self.radio_cylindrical = QRadioButton('Cylindrical') self.radio_spherical = QRadioButton('Spherical') coord_type_layout = QHBoxLayout() coord_type_layout.addWidget(self.radio_rectangular) coord_type_layout.addWidget(self.radio_cylindrical) coord_type_layout.addWidget(self.radio_spherical) location_layout = QHBoxLayout() location_layout.addWidget(self.location_x_edit) location_layout.addWidget(self.location_y_edit) location_layout.addWidget(self.location_z_edit) checkboxs = QButtonGroup(self) checkboxs.addButton(self.checkbox_show) checkboxs.addButton(self.checkbox_hide) vbox1 = QVBoxLayout() vbox1.addWidget(self.checkbox_show) vbox1.addWidget(self.checkbox_hide) #vbox1.addLayout(checkboxs) #----------------------------------------- irow = 0 grid1.addWidget(self.all_nodes_header, irow, 0) irow += 1 grid1.addWidget(self.color, irow, 0) grid1.addWidget(self.color_edit, irow, 1) irow += 1 grid1.addWidget(self.opacity, irow, 0) grid1.addWidget(self.opacity_edit, irow, 1) irow += 1 grid1.addWidget(self.point_size, irow, 0) grid1.addWidget(self.point_size_edit, irow, 1) irow += 1 #----------------------------------------- irow = 0 grid2.addWidget(self.nodes_header, irow, 0) irow += 1 grid2.addWidget(self.name, irow, 0) grid2.addWidget(self.name_edit, irow, 1) irow += 1 grid2.addWidget(self.description, irow, 0) grid2.addWidget(self.description_edit, irow, 1) irow += 1 #| All Nodes: | #| Color red | #| PointSize 3 | #| Opacity 0.3 | #| Show/Hide | #| | #| Name LEwingTip | #| Location X Y Z | #| Coord 0 | #| CoordType R, C, S | #| | #| Previous Next | grid2.addWidget(self.coord, irow, 0) grid2.addWidget(self.coord_edit, irow, 1) irow += 1 grid2.addWidget(self.coord_type, irow, 0) grid2.addLayout(coord_type_layout, irow, 1) irow += 1 grid2.addWidget(self.location, irow, 0) grid2.addLayout(location_layout, irow, 1) irow += 1 #------------------------------------ vbox = QVBoxLayout() vbox.addLayout(grid1) vbox.addLayout(vbox1) vbox.addStretch() vbox.addWidget(self.table) vbox.addLayout(grid2) vbox.addStretch() #vbox.addWidget(self.check_apply) vbox.addLayout(cancel_box) self.setLayout(vbox)
def _setup_views(self): """Creates the UI widgets.""" self.central_splitter = QSplitter(self, orientation=Qt.Vertical) layout = create_plugin_layout(self.tools_layout, self.central_splitter) self.setLayout(layout) # Tree widget self.obj_tree = ToggleColumnTreeView( dataframe_format=self._dataframe_format) self.obj_tree.setAlternatingRowColors(True) self.obj_tree.setModel(self._proxy_tree_model) self.obj_tree.setSelectionBehavior(QAbstractItemView.SelectRows) self.obj_tree.setUniformRowHeights(True) self.obj_tree.setAnimated(True) self.obj_tree.add_header_context_menu() self.obj_tree.sig_option_changed.connect(self.sig_option_changed.emit) # Stretch last column? # It doesn't play nice when columns are hidden and then shown again. obj_tree_header = self.obj_tree.header() obj_tree_header.setSectionsMovable(True) obj_tree_header.setStretchLastSection(False) add_actions(self.show_cols_submenu, self.obj_tree.toggle_column_actions_group.actions()) self.central_splitter.addWidget(self.obj_tree) # Bottom pane bottom_pane_widget = QWidget() bottom_layout = QHBoxLayout() bottom_layout.setSpacing(0) bottom_layout.setContentsMargins(5, 5, 5, 5) # left top right bottom bottom_pane_widget.setLayout(bottom_layout) self.central_splitter.addWidget(bottom_pane_widget) group_box = QGroupBox(_("Details")) bottom_layout.addWidget(group_box) v_group_layout = QVBoxLayout() h_group_layout = QHBoxLayout() h_group_layout.setContentsMargins(2, 2, 2, 2) # left top right bottom group_box.setLayout(v_group_layout) v_group_layout.addLayout(h_group_layout) # Radio buttons radio_widget = QWidget() radio_layout = QVBoxLayout() radio_layout.setContentsMargins(0, 0, 0, 0) # left top right bottom radio_widget.setLayout(radio_layout) self.button_group = QButtonGroup(self) for button_id, attr_detail in enumerate(self._attr_details): radio_button = QRadioButton(attr_detail.name) radio_layout.addWidget(radio_button) self.button_group.addButton(radio_button, button_id) self.button_group.buttonClicked[int].connect( self._change_details_field) self.button_group.button(0).setChecked(True) radio_layout.addStretch(1) h_group_layout.addWidget(radio_widget) # Editor widget self.editor = CodeEditor(self) self.editor.setReadOnly(True) h_group_layout.addWidget(self.editor) # Warining label about repr repr_label = QLabel(_("(*) Some objects have very large repr's, " "which can freeze Spyder. Please use this " "with care.")) v_group_layout.addWidget(repr_label) # Save and close buttons btn_layout = QHBoxLayout() btn_layout.addStretch() if not self.readonly: self.btn_save_and_close = QPushButton(_('Save and Close')) self.btn_save_and_close.setDisabled(True) self.btn_save_and_close.clicked.connect(self.accept) btn_layout.addWidget(self.btn_save_and_close) self.btn_close = QPushButton(_('Close')) self.btn_close.setAutoDefault(True) self.btn_close.setDefault(True) self.btn_close.clicked.connect(self.reject) btn_layout.addWidget(self.btn_close) v_group_layout.addLayout(btn_layout) # Splitter parameters self.central_splitter.setCollapsible(0, False) self.central_splitter.setCollapsible(1, True) self.central_splitter.setSizes([500, 320]) self.central_splitter.setStretchFactor(0, 10) self.central_splitter.setStretchFactor(1, 0) # Connect signals # Keep a temporary reference of the selection_model to prevent # segfault in PySide. # See http://permalink.gmane.org/gmane.comp.lib.qt.pyside.devel/222 selection_model = self.obj_tree.selectionModel() selection_model.currentChanged.connect(self._update_details) # Check if the values of the model have been changed self._proxy_tree_model.sig_setting_data.connect( self.save_and_close_enable) self._proxy_tree_model.sig_update_details.connect( self._update_details_for_item)
def __init__(self): QDialog.__init__(self) # matplotlib self._figure = figure.Figure() self._canvas = FigureCanvas(self._figure) self._toolbar = NavigationToolbar2QT(self._canvas, self) # comboboxes self._combo_sample = QComboBox() self._combo_sample.addItem("--- choose sample ---", None) self._combo_sample.addItem("SubstrateSample", SubstrateSample) self._combo_sample.addItem("InclusionSample", InclusionSample) self._combo_sample.addItem("HLayerSample", HorizontalLayerSample) self._combo_sample.addItem("VLayerSample", VerticalLayerSample) self._combo_sample.addItem("SphereSample", SphereSample) self._combo_sample.currentIndexChanged.connect(self.plot) self._combo_beam = QComboBox() self._combo_beam.addItem("--- choose beam ---", None) self._combo_beam.addItem("GaussianBeam", GaussianBeam) self._combo_beam.currentIndexChanged.connect(self.plot) self._combo_trajectory = QComboBox() self._combo_trajectory.addItem("--- choose trajectory ---", None) self._combo_trajectory.currentIndexChanged.connect(self.plot) # slider self._slider_tilt_deg = QSlider(Qt.Horizontal) self._slider_tilt_deg.setMinimum(-180) self._slider_tilt_deg.setMaximum(180) self._slider_tilt_deg.setValue(0) self._slider_tilt_deg.sliderReleased.connect(self.plot) self._slider_rotation_deg = QSlider(Qt.Horizontal) self._slider_rotation_deg.setMinimum(-180) self._slider_rotation_deg.setMaximum(180) self._slider_rotation_deg.setValue(0) self._slider_rotation_deg.sliderReleased.connect(self.plot) self._slider_rotation_deg.setDisabled(True) # radio buttons self._radio_xz = QRadioButton("XZ") self.radio_yz = QRadioButton("YZ") self.radio_xy = QRadioButton("XY") self._radio_xz.setChecked(True) self._radio_perspective = QButtonGroup() self._radio_perspective.addButton(self._radio_xz) self._radio_perspective.addButton(self.radio_yz) self._radio_perspective.addButton(self.radio_xy) self._radio_perspective.buttonClicked.connect(self.plot) # layout sublayout_combo = QHBoxLayout() sublayout_combo.addWidget(self._combo_sample) sublayout_combo.addWidget(self._combo_beam) sublayout_combo.addWidget(self._combo_trajectory) sublayout_perspective = QGridLayout() sublayout_perspective.addWidget(self._radio_xz, 1, 1) sublayout_perspective.addWidget(self.radio_yz, 2, 1) sublayout_perspective.addWidget(self.radio_xy, 3, 1) sublayout_perspective.addWidget(QLabel("tilt"), 1, 2) sublayout_perspective.addWidget(QLabel("rotation"), 2, 2) sublayout_perspective.addWidget(self._slider_tilt_deg, 1, 3) sublayout_perspective.addWidget(self._slider_rotation_deg, 2, 3) layout = QVBoxLayout() layout.addWidget(self._toolbar) layout.addWidget(self._canvas) layout.addLayout(sublayout_combo) layout.addLayout(sublayout_perspective) self.setLayout(layout) self.plot()
def __init__(self, model, *args, **kwargs): self.model = model super().__init__(*args, **kwargs) self.setLayout(QFormLayout()) # Radiobuttons to quickly select default time period self.all_widget = QRadioButton("All") self.year_widget = QRadioButton("1 Year") self.month_widget = QRadioButton("30 Days") self.week_widget = QRadioButton("1 Week") self.today_widget = QRadioButton("24 Hours") self.hour_widget = QRadioButton("1 Hour") self.radio_button_group = QButtonGroup() self.radio_button_group.addButton(self.all_widget) self.radio_button_group.addButton(self.year_widget) self.radio_button_group.addButton(self.month_widget) self.radio_button_group.addButton(self.week_widget) self.radio_button_group.addButton(self.today_widget) self.radio_button_group.addButton(self.hour_widget) default_period_layout = QGridLayout() default_period_layout.setHorizontalSpacing(85) default_period_layout.setVerticalSpacing(10) default_period_layout.addWidget(self.all_widget, 0, 0, 1, 2) default_period_layout.addWidget(self.year_widget, 1, 0, 1, 2) default_period_layout.addWidget(self.month_widget, 0, 1, 1, 2) default_period_layout.addWidget(self.week_widget, 1, 1, 1, 2) default_period_layout.addWidget(self.today_widget, 0, 2, 1, 2) default_period_layout.addWidget(self.hour_widget, 1, 2, 1, 2) self.layout().addRow("When:", default_period_layout) # TODO: rethink if restriction to acceptable timedelta values is required # from ..models.search.search_input import SearchInput # self.allowed = {timedelta(days=-1), timedelta(days=-30), timedelta(minutes=-60), timedelta(days=-7), # timedelta(days=-365)} # def time_validator(since=None, until=None): # """ # Enforce that since and until are values that a UI can represent. # This is an example similar to what will be used in the Qt UI. # """ # now = timedelta() # if isinstance(since, timedelta): # if not (until is None or until == now): # raise ValueError( # "This UI cannot express since=timedelta(...) unless until " # "is timedelta() or None." # ) # for item in allowed: # if since == item: # break # else: # # No matches # raise ValueError( # "This UI can only express since as a timedelta if it is " # f"one of {allowed}. The value {since} is not allowed" # ) # s = SearchInput() # s.time_validator = time_validator self.date_selection_row = QHBoxLayout(self) self.layout().addRow(self.date_selection_row) # "Since: <datetime picker>" self.since_widget = QDateTimeEdit() self.since_widget.setCalendarPopup(True) self.since_widget.setDisplayFormat("yyyy-MM-dd HH:mm") self.date_selection_row.addWidget(QLabel("Date range:", self), 0) self.date_selection_row.addWidget(self.since_widget, 1) # "Until: <datetime picker>" self.until_widget = QDateTimeEdit() self.until_widget.setCalendarPopup(True) self.until_widget.setDisplayFormat("yyyy-MM-dd HH:mm") self.date_selection_row.addWidget(QLabel(" \u2013 ", self), 0) self.date_selection_row.addWidget(self.until_widget, 1) # Field search self.field_text_edit = {} for field in self.model.fields: self.field_text_edit[field] = QLineEdit("") self.field_text_edit[field].textChanged.connect( self.on_field_search_view_changed) self.model.events.field_search_updated.connect( self.on_field_search_model_changed) self.layout().addRow(f"{field}:", self.field_text_edit[field]) # Text Search if model.text_search_supported: self.text_search_input = QLineEdit("") self.text_search_input.textChanged.connect( self.on_text_view_changed) self.model.events.text.connect(self.on_text_model_changed) self.layout().addRow("Full Text Search:", self.text_search_input) # Refresh Button self.refresh_button = QPushButton("Refresh") self.layout().addWidget(self.refresh_button) # Changes to the GUI update the model. self.since_widget.dateTimeChanged.connect(self.on_since_view_changed) self.until_widget.dateTimeChanged.connect(self.on_until_view_changed) self.refresh_button.clicked.connect(self.model.request_reload) self.model.events.reload.connect(self.on_reload) self.model.events.query.connect(self.on_reload) # Changes to the model update the GUI. self.model.events.since.connect(self.on_since_model_changed) self.model.events.until.connect(self.on_until_model_changed) # connect QRadioButtons and change date dropdowns (since/until widgets) accordingly self.hour_widget.toggled.connect(self.on_toggle_hour) self.today_widget.toggled.connect(self.on_toggle_24h) self.week_widget.toggled.connect(self.on_toggle_week) self.month_widget.toggled.connect(self.on_toggle_month) self.year_widget.toggled.connect(self.on_toggle_year) self.all_widget.toggled.connect(self.on_toggle_all) self.all_widget.setChecked(True)
def setup_page(self): interface_group = QGroupBox(_("Interface")) newcb = self.create_checkbox singletab_box = newcb(_("One tab per script"), 'single_tab') showtime_box = newcb(_("Show elapsed time"), 'show_elapsed_time') icontext_box = newcb(_("Show icons and text"), 'show_icontext') # Interface Group interface_layout = QVBoxLayout() interface_layout.addWidget(singletab_box) interface_layout.addWidget(showtime_box) interface_layout.addWidget(icontext_box) interface_group.setLayout(interface_layout) # Source Code Group display_group = QGroupBox(_("Source code")) buffer_spin = self.create_spinbox(_("Buffer: "), _(" lines"), 'max_line_count', min_=0, max_=1000000, step=100, tip=_("Set maximum line count")) wrap_mode_box = newcb(_("Wrap lines"), 'wrap') merge_channels_box = newcb( _("Merge process standard output/error channels"), 'merge_output_channels', tip=_("Merging the output channels of the process means that\n" "the standard error won't be written in red anymore,\n" "but this has the effect of speeding up display.")) colorize_sys_stderr_box = newcb( _("Colorize standard error channel using ANSI escape codes"), 'colorize_sys_stderr', tip=_("This method is the only way to have colorized standard\n" "error channel when the output channels have been " "merged.")) merge_channels_box.toggled.connect(colorize_sys_stderr_box.setEnabled) merge_channels_box.toggled.connect(colorize_sys_stderr_box.setChecked) colorize_sys_stderr_box.setEnabled( self.get_option('merge_output_channels')) display_layout = QVBoxLayout() display_layout.addWidget(buffer_spin) display_layout.addWidget(wrap_mode_box) display_layout.addWidget(merge_channels_box) display_layout.addWidget(colorize_sys_stderr_box) display_group.setLayout(display_layout) # Background Color Group bg_group = QGroupBox(_("Background color")) bg_label = QLabel( _("This option will be applied the next time " "a Python console or a terminal is opened.")) bg_label.setWordWrap(True) lightbg_box = newcb(_("Light background (white color)"), 'light_background') bg_layout = QVBoxLayout() bg_layout.addWidget(bg_label) bg_layout.addWidget(lightbg_box) bg_group.setLayout(bg_layout) # Advanced settings source_group = QGroupBox(_("Source code")) completion_box = newcb(_("Automatic code completion"), 'codecompletion/auto') case_comp_box = newcb(_("Case sensitive code completion"), 'codecompletion/case_sensitive') comp_enter_box = newcb(_("Enter key selects completion"), 'codecompletion/enter_key') calltips_box = newcb(_("Display balloon tips"), 'calltips') source_layout = QVBoxLayout() source_layout.addWidget(completion_box) source_layout.addWidget(case_comp_box) source_layout.addWidget(comp_enter_box) source_layout.addWidget(calltips_box) source_group.setLayout(source_layout) # PYTHONSTARTUP replacement pystartup_group = QGroupBox(_("PYTHONSTARTUP replacement")) pystartup_bg = QButtonGroup(pystartup_group) pystartup_label = QLabel( _("This option will override the " "PYTHONSTARTUP environment variable which\n" "defines the script to be executed during " "the Python console startup.")) def_startup_radio = self.create_radiobutton( _("Default PYTHONSTARTUP script"), 'pythonstartup/default', button_group=pystartup_bg) cus_startup_radio = self.create_radiobutton( _("Use the following startup script:"), 'pythonstartup/custom', button_group=pystartup_bg) pystartup_file = self.create_browsefile('', 'pythonstartup', '', filters=_("Python scripts")+\ " (*.py)") def_startup_radio.toggled.connect(pystartup_file.setDisabled) cus_startup_radio.toggled.connect(pystartup_file.setEnabled) pystartup_layout = QVBoxLayout() pystartup_layout.addWidget(pystartup_label) pystartup_layout.addWidget(def_startup_radio) pystartup_layout.addWidget(cus_startup_radio) pystartup_layout.addWidget(pystartup_file) pystartup_group.setLayout(pystartup_layout) # Monitor Group monitor_group = QGroupBox(_("Monitor")) monitor_label = QLabel( _("The monitor provides introspection " "features to console: code completion, " "calltips and variable explorer. " "Because it relies on several modules, " "disabling the monitor may be useful " "to accelerate console startup.")) monitor_label.setWordWrap(True) monitor_box = newcb(_("Enable monitor"), 'monitor/enabled') for obj in (completion_box, case_comp_box, comp_enter_box, calltips_box): monitor_box.toggled.connect(obj.setEnabled) obj.setEnabled(self.get_option('monitor/enabled')) monitor_layout = QVBoxLayout() monitor_layout.addWidget(monitor_label) monitor_layout.addWidget(monitor_box) monitor_group.setLayout(monitor_layout) # Qt Group opts = [ (_("Default library"), 'default'), ('PyQt5', 'pyqt5'), ('PyQt4', 'pyqt'), ('PySide', 'pyside'), ] qt_group = QGroupBox(_("Qt-Python Bindings")) qt_setapi_box = self.create_combobox( _("Library:") + " ", opts, 'qt/api', default='default', tip=_("This option will act on<br> " "libraries such as Matplotlib, guidata " "or ETS")) qt_layout = QVBoxLayout() qt_layout.addWidget(qt_setapi_box) qt_group.setLayout(qt_layout) # Matplotlib Group mpl_group = QGroupBox(_("Graphics")) mpl_label = QLabel( _("Decide which backend to use to display graphics. " "If unsure, please select the <b>Automatic</b> " "backend.<br><br>" "<b>Note:</b> We support a very limited number " "of backends in our Python consoles. If you " "prefer to work with a different one, please use " "an IPython console.")) mpl_label.setWordWrap(True) backends = [(_("Automatic"), 0), (_("None"), 1)] if not os.name == 'nt' and programs.is_module_installed('_tkinter'): backends.append(("Tkinter", 2)) backends = tuple(backends) mpl_backend_box = self.create_combobox( _("Backend:") + " ", backends, 'matplotlib/backend/value', tip=_("This option will be applied the " "next time a console is opened.")) mpl_installed = programs.is_module_installed('matplotlib') mpl_layout = QVBoxLayout() mpl_layout.addWidget(mpl_label) mpl_layout.addWidget(mpl_backend_box) mpl_group.setLayout(mpl_layout) mpl_group.setEnabled(mpl_installed) # ETS Group ets_group = QGroupBox(_("Enthought Tool Suite")) ets_label = QLabel( _("Enthought Tool Suite (ETS) supports " "PyQt4 (qt4) and wxPython (wx) graphical " "user interfaces.")) ets_label.setWordWrap(True) ets_edit = self.create_lineedit(_("ETS_TOOLKIT:"), 'ets_backend', alignment=Qt.Horizontal) ets_layout = QVBoxLayout() ets_layout.addWidget(ets_label) ets_layout.addWidget(ets_edit) ets_group.setLayout(ets_layout) if CONF.get('main_interpreter', 'default'): interpreter = get_python_executable() else: interpreter = CONF.get('main_interpreter', 'executable') ets_group.setEnabled( programs.is_module_installed("enthought.etsconfig.api", interpreter=interpreter)) tabs = QTabWidget() tabs.addTab(self.create_tab(interface_group, display_group, bg_group), _("Display")) tabs.addTab(self.create_tab(monitor_group, source_group), _("Introspection")) tabs.addTab(self.create_tab(pystartup_group), _("Advanced settings")) tabs.addTab(self.create_tab(qt_group, mpl_group, ets_group), _("External modules")) vlayout = QVBoxLayout() vlayout.addWidget(tabs) self.setLayout(vlayout)
def setup_page(self): about_label = QLabel( _("The <b>global working directory</b> is " "the working directory for newly opened <i>consoles</i> " "(Python/IPython consoles and terminals), for the " "<i>file explorer</i>, for the <i>find in files</i> " "plugin and for new files created in the <i>editor</i>.")) about_label.setWordWrap(True) startup_group = QGroupBox(_("Startup")) startup_bg = QButtonGroup(startup_group) startup_label = QLabel( _("At startup, the global working " "directory is:")) startup_label.setWordWrap(True) lastdir_radio = self.create_radiobutton( _("the same as in last session"), 'startup/use_last_directory', True, _("At startup, Spyder will restore the " "global directory from last session"), button_group=startup_bg) thisdir_radio = self.create_radiobutton( _("the following directory:"), 'startup/use_fixed_directory', False, _("At startup, the global working " "directory will be the specified path"), button_group=startup_bg) thisdir_bd = self.create_browsedir("", 'startup/fixed_directory', getcwd()) thisdir_radio.toggled.connect(thisdir_bd.setEnabled) lastdir_radio.toggled.connect(thisdir_bd.setDisabled) thisdir_layout = QHBoxLayout() thisdir_layout.addWidget(thisdir_radio) thisdir_layout.addWidget(thisdir_bd) editor_o_group = QGroupBox(_("Open file")) editor_o_label = QLabel(_("Files are opened from:")) editor_o_label.setWordWrap(True) editor_o_bg = QButtonGroup(editor_o_group) editor_o_radio1 = self.create_radiobutton( _("the current file directory"), 'editor/open/browse_scriptdir', button_group=editor_o_bg) editor_o_radio2 = self.create_radiobutton( _("the global working directory"), 'editor/open/browse_workdir', button_group=editor_o_bg) editor_n_group = QGroupBox(_("New file")) editor_n_label = QLabel(_("Files are created in:")) editor_n_label.setWordWrap(True) editor_n_bg = QButtonGroup(editor_n_group) editor_n_radio1 = self.create_radiobutton( _("the current file directory"), 'editor/new/browse_scriptdir', button_group=editor_n_bg) editor_n_radio2 = self.create_radiobutton( _("the global working directory"), 'editor/new/browse_workdir', button_group=editor_n_bg) # Note: default values for the options above are set in plugin's # constructor (see below) other_group = QGroupBox(_("Change to file base directory")) newcb = self.create_checkbox open_box = newcb(_("When opening a file"), 'editor/open/auto_set_to_basedir') save_box = newcb(_("When saving a file"), 'editor/save/auto_set_to_basedir') startup_layout = QVBoxLayout() startup_layout.addWidget(startup_label) startup_layout.addWidget(lastdir_radio) startup_layout.addLayout(thisdir_layout) startup_group.setLayout(startup_layout) editor_o_layout = QVBoxLayout() editor_o_layout.addWidget(editor_o_label) editor_o_layout.addWidget(editor_o_radio1) editor_o_layout.addWidget(editor_o_radio2) editor_o_group.setLayout(editor_o_layout) editor_n_layout = QVBoxLayout() editor_n_layout.addWidget(editor_n_label) editor_n_layout.addWidget(editor_n_radio1) editor_n_layout.addWidget(editor_n_radio2) editor_n_group.setLayout(editor_n_layout) other_layout = QVBoxLayout() other_layout.addWidget(open_box) other_layout.addWidget(save_box) other_group.setLayout(other_layout) vlayout = QVBoxLayout() vlayout.addWidget(about_label) vlayout.addSpacing(10) vlayout.addWidget(startup_group) vlayout.addWidget(editor_o_group) vlayout.addWidget(editor_n_group) vlayout.addWidget(other_group) vlayout.addStretch(1) self.setLayout(vlayout)
def __init__(self, layer): super().__init__(layer) self.layer.events.mode.connect(self._on_mode_change) self.layer.events.out_of_slice_display.connect( self._on_out_of_slice_display_change) self.layer.events.symbol.connect(self._on_symbol_change) self.layer.events.size.connect(self._on_size_change) self.layer.events.current_edge_color.connect( self._on_current_edge_color_change) self.layer._edge.events.current_color.connect( self._on_current_edge_color_change) self.layer.events.current_face_color.connect( self._on_current_face_color_change) self.layer._face.events.current_color.connect( self._on_current_face_color_change) self.layer.events.editable.connect(self._on_editable_change) self.layer.text.events.visible.connect(self._on_text_visibility_change) sld = QSlider(Qt.Horizontal) sld.setFocusPolicy(Qt.NoFocus) sld.setMinimum(1) sld.setMaximum(100) sld.setSingleStep(1) value = self.layer.current_size sld.setValue(int(value)) sld.valueChanged.connect(self.changeSize) self.sizeSlider = sld self.faceColorEdit = QColorSwatchEdit( initial_color=self.layer.current_face_color, tooltip=trans._('click to set current face color'), ) self.edgeColorEdit = QColorSwatchEdit( initial_color=self.layer.current_edge_color, tooltip=trans._('click to set current edge color'), ) self.faceColorEdit.color_changed.connect(self.changeFaceColor) self.edgeColorEdit.color_changed.connect(self.changeEdgeColor) symbol_comboBox = QComboBox() current_index = 0 for index, (data, text) in enumerate(SYMBOL_TRANSLATION.items()): data = data.value symbol_comboBox.addItem(text, data) if data == self.layer.symbol: current_index = index symbol_comboBox.setCurrentIndex(current_index) symbol_comboBox.activated[str].connect(self.changeSymbol) self.symbolComboBox = symbol_comboBox out_of_slice_cb = QCheckBox() out_of_slice_cb.setToolTip(trans._('Out of slice display')) out_of_slice_cb.setChecked(self.layer.out_of_slice_display) out_of_slice_cb.stateChanged.connect(self.change_out_of_slice) self.outOfSliceCheckBox = out_of_slice_cb self.select_button = QtModeRadioButton( layer, 'select_points', Mode.SELECT, ) action_manager.bind_button('napari:activate_points_select_mode', self.select_button) self.addition_button = QtModeRadioButton(layer, 'add_points', Mode.ADD) action_manager.bind_button('napari:activate_points_add_mode', self.addition_button) self.panzoom_button = QtModeRadioButton( layer, 'pan_zoom', Mode.PAN_ZOOM, checked=True, ) action_manager.bind_button('napari:activate_points_pan_zoom_mode', self.panzoom_button) self.delete_button = QtModePushButton( layer, 'delete_shape', ) action_manager.bind_button('napari:delete_selected_points', self.delete_button) text_disp_cb = QCheckBox() text_disp_cb.setToolTip(trans._('toggle text visibility')) text_disp_cb.setChecked(self.layer.text.visible) text_disp_cb.stateChanged.connect(self.change_text_visibility) self.textDispCheckBox = text_disp_cb self.button_group = QButtonGroup(self) self.button_group.addButton(self.select_button) self.button_group.addButton(self.addition_button) self.button_group.addButton(self.panzoom_button) button_row = QHBoxLayout() button_row.addStretch(1) button_row.addWidget(self.delete_button) button_row.addWidget(self.addition_button) button_row.addWidget(self.select_button) button_row.addWidget(self.panzoom_button) button_row.setContentsMargins(0, 0, 0, 5) button_row.setSpacing(4) # grid_layout created in QtLayerControls # addWidget(widget, row, column, [row_span, column_span]) self.grid_layout.addLayout(button_row, 0, 1) self.grid_layout.addWidget(QLabel(trans._('opacity:')), 1, 0) self.grid_layout.addWidget(self.opacitySlider, 1, 1) self.grid_layout.addWidget(QLabel(trans._('point size:')), 2, 0) self.grid_layout.addWidget(self.sizeSlider, 2, 1) self.grid_layout.addWidget(QLabel(trans._('blending:')), 3, 0) self.grid_layout.addWidget(self.blendComboBox, 3, 1) self.grid_layout.addWidget(QLabel(trans._('symbol:')), 4, 0) self.grid_layout.addWidget(self.symbolComboBox, 4, 1) self.grid_layout.addWidget(QLabel(trans._('face color:')), 5, 0) self.grid_layout.addWidget(self.faceColorEdit, 5, 1) self.grid_layout.addWidget(QLabel(trans._('edge color:')), 6, 0) self.grid_layout.addWidget(self.edgeColorEdit, 6, 1) self.grid_layout.addWidget(QLabel(trans._('display text:')), 7, 0) self.grid_layout.addWidget(self.textDispCheckBox, 7, 1) self.grid_layout.addWidget(QLabel(trans._('out of slice:')), 8, 0) self.grid_layout.addWidget(self.outOfSliceCheckBox, 8, 1) self.grid_layout.setRowStretch(9, 1) self.grid_layout.setColumnStretch(1, 1) self.grid_layout.setSpacing(4)
def __init__(self, layer): super().__init__(layer) self.layer.events.mode.connect(self._on_mode_change) self.layer.events.selected_label.connect( self._on_selected_label_change) self.layer.events.brush_size.connect(self._on_brush_size_change) self.layer.events.contiguous.connect(self._on_contiguous_change) self.layer.events.n_edit_dimensions.connect( self._on_n_edit_dimensions_change) self.layer.events.contour.connect(self._on_contour_change) self.layer.events.editable.connect(self._on_editable_change) self.layer.events.preserve_labels.connect( self._on_preserve_labels_change) self.layer.events.color_mode.connect(self._on_color_mode_change) # selection spinbox self.selectionSpinBox = QtLargeIntSpinBox(self.layer.data.dtype) self.selectionSpinBox.setKeyboardTracking(False) self.selectionSpinBox.setMinimum(0) self.selectionSpinBox.valueChanged.connect(self.changeSelection) self.selectionSpinBox.setAlignment(Qt.AlignCenter) self._on_selected_label_change() sld = QSlider(Qt.Horizontal) sld.setFocusPolicy(Qt.NoFocus) sld.setMinimum(1) sld.setMaximum(40) sld.setSingleStep(1) sld.valueChanged.connect(self.changeSize) self.brushSizeSlider = sld self._on_brush_size_change() contig_cb = QCheckBox() contig_cb.setToolTip(trans._('contiguous editing')) contig_cb.stateChanged.connect(self.change_contig) self.contigCheckBox = contig_cb self._on_contiguous_change() ndim_sb = QSpinBox() self.ndimSpinBox = ndim_sb ndim_sb.setToolTip(trans._('number of dimensions for label editing')) ndim_sb.valueChanged.connect(self.change_n_edit_dim) ndim_sb.setMinimum(2) ndim_sb.setMaximum(self.layer.ndim) ndim_sb.setSingleStep(1) ndim_sb.setAlignment(Qt.AlignCenter) self._on_n_edit_dimensions_change() contour_sb = QtLargeIntSpinBox(self.layer.data.dtype) contour_sb.setToolTip(trans._('display contours of labels')) contour_sb.valueChanged.connect(self.change_contour) self.contourSpinBox = contour_sb self.contourSpinBox.setKeyboardTracking(False) self.contourSpinBox.setSingleStep(1) self.contourSpinBox.setMinimum(0) self.contourSpinBox.setAlignment(Qt.AlignCenter) self._on_contour_change() preserve_labels_cb = QCheckBox() preserve_labels_cb.setToolTip( trans._('preserve existing labels while painting')) preserve_labels_cb.stateChanged.connect(self.change_preserve_labels) self.preserveLabelsCheckBox = preserve_labels_cb self._on_preserve_labels_change() selectedColorCheckbox = QCheckBox() selectedColorCheckbox.setToolTip( trans._("Display only selected label")) selectedColorCheckbox.stateChanged.connect(self.toggle_selected_mode) self.selectedColorCheckbox = selectedColorCheckbox # shuffle colormap button self.colormapUpdate = QtModePushButton( None, 'shuffle', slot=self.changeColor, tooltip=trans._('shuffle colors'), ) self.panzoom_button = QtModeRadioButton( layer, 'zoom', Mode.PAN_ZOOM, tooltip=trans._('Pan/zoom mode (Space)'), checked=True, ) self.pick_button = QtModeRadioButton(layer, 'picker', Mode.PICK, tooltip=trans._('Pick mode (L)')) self.paint_button = QtModeRadioButton( layer, 'paint', Mode.PAINT, tooltip=trans._('Paint mode (P)')) self.fill_button = QtModeRadioButton( layer, 'fill', Mode.FILL, tooltip=trans._( "Fill mode (F) \nToggle with {shortcut}", shortcut=Shortcut("Control"), ), ) self.erase_button = QtModeRadioButton( layer, 'erase', Mode.ERASE, tooltip=trans._( "Erase mode (E) \nToggle with {shortcut}", shortcut=Shortcut("Alt"), ), ) self.button_group = QButtonGroup(self) self.button_group.addButton(self.panzoom_button) self.button_group.addButton(self.paint_button) self.button_group.addButton(self.pick_button) self.button_group.addButton(self.fill_button) self.button_group.addButton(self.erase_button) self._on_editable_change() button_row = QHBoxLayout() button_row.addStretch(1) button_row.addWidget(self.colormapUpdate) button_row.addWidget(self.erase_button) button_row.addWidget(self.fill_button) button_row.addWidget(self.paint_button) button_row.addWidget(self.pick_button) button_row.addWidget(self.panzoom_button) button_row.setSpacing(4) button_row.setContentsMargins(0, 0, 0, 5) color_mode_comboBox = QComboBox(self) for index, (data, text) in enumerate(LABEL_COLOR_MODE_TRANSLATIONS.items()): data = data.value color_mode_comboBox.addItem(text, data) if self.layer.color_mode == data: color_mode_comboBox.setCurrentIndex(index) color_mode_comboBox.activated[str].connect(self.change_color_mode) self.colorModeComboBox = color_mode_comboBox self._on_color_mode_change() color_layout = QHBoxLayout() self.colorBox = QtColorBox(layer) color_layout.addWidget(self.colorBox) color_layout.addWidget(self.selectionSpinBox) # grid_layout created in QtLayerControls # addWidget(widget, row, column, [row_span, column_span]) self.grid_layout.addLayout(button_row, 0, 0, 1, 4) self.grid_layout.addWidget(QLabel(trans._('label:')), 1, 0, 1, 1) self.grid_layout.addLayout(color_layout, 1, 1, 1, 3) self.grid_layout.addWidget(QLabel(trans._('opacity:')), 2, 0, 1, 1) self.grid_layout.addWidget(self.opacitySlider, 2, 1, 1, 3) self.grid_layout.addWidget(QLabel(trans._('brush size:')), 3, 0, 1, 1) self.grid_layout.addWidget(self.brushSizeSlider, 3, 1, 1, 3) self.grid_layout.addWidget(QLabel(trans._('blending:')), 5, 0, 1, 1) self.grid_layout.addWidget(self.blendComboBox, 5, 1, 1, 3) self.grid_layout.addWidget(QLabel(trans._('color mode:')), 6, 0, 1, 1) self.grid_layout.addWidget(self.colorModeComboBox, 6, 1, 1, 3) self.grid_layout.addWidget(QLabel(trans._('contour:')), 7, 0, 1, 1) self.grid_layout.addWidget(self.contourSpinBox, 7, 1, 1, 1) self.grid_layout.addWidget(QLabel(trans._('n edit dim:')), 8, 0, 1, 1) self.grid_layout.addWidget(self.ndimSpinBox, 8, 1, 1, 1) self.grid_layout.addWidget(QLabel(trans._('contiguous:')), 9, 0, 1, 1) self.grid_layout.addWidget(self.contigCheckBox, 9, 1, 1, 1) self.grid_layout.addWidget(QLabel(trans._('preserve labels:')), 10, 0, 1, 2) self.grid_layout.addWidget(self.preserveLabelsCheckBox, 10, 1, 1, 1) self.grid_layout.addWidget(QLabel(trans._('show selected:')), 10, 2, 1, 1) self.grid_layout.addWidget(self.selectedColorCheckbox, 10, 3, 1, 1) self.grid_layout.setRowStretch(10, 1) self.grid_layout.setColumnStretch(1, 1) self.grid_layout.setSpacing(4)
def __init__(self, appdata: CnaData): QDialog.__init__(self) self.setWindowTitle("Clipboard calculator") self.appdata = appdata self.layout = QVBoxLayout() l1 = QHBoxLayout() self.left = QVBoxLayout() self.l1 = QRadioButton("Current values") self.l2 = QRadioButton("Clipboard values") h1 = QHBoxLayout() self.l3 = QRadioButton() self.left_value = QLineEdit("0") h1.addWidget(self.l3) h1.addWidget(self.left_value) self.lqb = QButtonGroup() self.lqb.addButton(self.l1) self.l1.setChecked(True) self.lqb.addButton(self.l2) self.lqb.addButton(self.l3) self.left.addWidget(self.l1) self.left.addWidget(self.l2) self.left.addItem(h1) op = QVBoxLayout() self.op = QComboBox() self.op.insertItem(1, "+") self.op.insertItem(2, "-") self.op.insertItem(3, "*") self.op.insertItem(4, "\\") op.addWidget(self.op) self.right = QVBoxLayout() self.r1 = QRadioButton("Current values") self.r2 = QRadioButton("Clipboard values") h2 = QHBoxLayout() self.r3 = QRadioButton() self.right_value = QLineEdit("0") h2.addWidget(self.r3) h2.addWidget(self.right_value) self.rqb = QButtonGroup() self.rqb.addButton(self.r1) self.r1.setChecked(True) self.rqb.addButton(self.r2) self.rqb.addButton(self.r3) self.right.addWidget(self.r1) self.right.addWidget(self.r2) self.right.addItem(h2) l1.addItem(self.left) l1.addItem(op) l1.addItem(self.right) self.layout.addItem(l1) l2 = QHBoxLayout() self.button = QPushButton("Compute") self.cancel = QPushButton("Cancel") l2.addWidget(self.button) l2.addWidget(self.cancel) self.layout.addItem(l2) self.setLayout(self.layout) # Connecting the signal self.cancel.clicked.connect(self.reject) self.button.clicked.connect(self.compute)
def _setup_views(self): """Creates the UI widgets.""" layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) layout.addLayout(self.tools_layout) self.central_splitter = QSplitter(self, orientation=Qt.Vertical) layout.addWidget(self.central_splitter) self.setLayout(layout) # Stretch last column? # It doesn't play nice when columns are hidden and then shown again. obj_tree_header = self.obj_tree.header() obj_tree_header.setSectionsMovable(True) obj_tree_header.setStretchLastSection(False) add_actions(self.show_cols_submenu, self.obj_tree.toggle_column_actions_group.actions()) self.central_splitter.addWidget(self.obj_tree) # Bottom pane bottom_pane_widget = QWidget() bottom_layout = QHBoxLayout() bottom_layout.setSpacing(0) bottom_layout.setContentsMargins(5, 5, 5, 5) # left top right bottom bottom_pane_widget.setLayout(bottom_layout) self.central_splitter.addWidget(bottom_pane_widget) group_box = QGroupBox(_("Details")) bottom_layout.addWidget(group_box) v_group_layout = QVBoxLayout() h_group_layout = QHBoxLayout() h_group_layout.setContentsMargins(2, 2, 2, 2) # left top right bottom group_box.setLayout(v_group_layout) v_group_layout.addLayout(h_group_layout) # Radio buttons radio_widget = QWidget() radio_layout = QVBoxLayout() radio_layout.setContentsMargins(0, 0, 0, 0) # left top right bottom radio_widget.setLayout(radio_layout) self.button_group = QButtonGroup(self) for button_id, attr_detail in enumerate(self._attr_details): radio_button = QRadioButton(attr_detail.name) radio_layout.addWidget(radio_button) self.button_group.addButton(radio_button, button_id) self.button_group.buttonClicked[int].connect( self._change_details_field) self.button_group.button(0).setChecked(True) radio_layout.addStretch(1) h_group_layout.addWidget(radio_widget) # Editor widget self.editor = SimpleCodeEditor(self) self.editor.setReadOnly(True) h_group_layout.addWidget(self.editor) # Save and close buttons btn_layout = QHBoxLayout() btn_layout.setContentsMargins(4, 8, 8, 16) btn_layout.setSpacing(5) btn_layout.addStretch() if not self.readonly: self.btn_save_and_close = QPushButton(_('Save and Close')) self.btn_save_and_close.setDisabled(True) self.btn_save_and_close.clicked.connect(self.accept) btn_layout.addWidget(self.btn_save_and_close) self.btn_close = QPushButton(_('Close')) self.btn_close.setAutoDefault(True) self.btn_close.setDefault(True) self.btn_close.clicked.connect(self.reject) btn_layout.addWidget(self.btn_close) layout.addLayout(btn_layout) # Splitter parameters self.central_splitter.setCollapsible(0, False) self.central_splitter.setCollapsible(1, True) self.central_splitter.setSizes([500, 320]) # Connect signals # Keep a temporary reference of the selection_model to prevent # segfault in PySide. # See http://permalink.gmane.org/gmane.comp.lib.qt.pyside.devel/222 selection_model = self.obj_tree.selectionModel() selection_model.currentChanged.connect(self._update_details) # Check if the values of the model have been changed self._proxy_tree_model.sig_setting_data.connect( self.save_and_close_enable) self._proxy_tree_model.sig_update_details.connect( self._update_details_for_item)
def setup_page(self): self.ICON = ima.icon('genprefs') newcb = self.create_checkbox # --- Interface general_group = QGroupBox(_("General")) # Remove disabled languages language_codes = LANGUAGE_CODES.copy() for lang in DISABLED_LANGUAGES: language_codes.pop(lang) languages = language_codes.items() language_choices = sorted([(val, key) for key, val in languages]) language_combo = self.create_combobox(_('Language:'), language_choices, 'interface_language', restart=True) opengl_options = ['Automatic', 'Desktop', 'Software', 'GLES'] opengl_choices = list( zip(opengl_options, [c.lower() for c in opengl_options])) opengl_combo = self.create_combobox(_('Rendering engine:'), opengl_choices, 'opengl', restart=True) single_instance_box = newcb(_("Use a single instance"), 'single_instance', tip=_("Set this to open external<br> " "Python files in an already running " "instance (Requires a restart)")) prompt_box = newcb(_("Prompt when exiting"), 'prompt_on_exit') popup_console_box = newcb( _("Show internal Spyder errors to report " "them to Github"), 'show_internal_errors') check_updates = newcb(_("Check for updates on startup"), 'check_updates_on_startup') # Decide if it's possible to activate or not single instance mode if running_in_mac_app(): self.set_option("single_instance", True) single_instance_box.setEnabled(False) comboboxes_advanced_layout = QHBoxLayout() cbs_adv_grid = QGridLayout() cbs_adv_grid.addWidget(language_combo.label, 0, 0) cbs_adv_grid.addWidget(language_combo.combobox, 0, 1) cbs_adv_grid.addWidget(opengl_combo.label, 1, 0) cbs_adv_grid.addWidget(opengl_combo.combobox, 1, 1) comboboxes_advanced_layout.addLayout(cbs_adv_grid) comboboxes_advanced_layout.addStretch(1) general_layout = QVBoxLayout() general_layout.addLayout(comboboxes_advanced_layout) general_layout.addWidget(single_instance_box) general_layout.addWidget(prompt_box) general_layout.addWidget(popup_console_box) general_layout.addWidget(check_updates) general_group.setLayout(general_layout) # --- Theme interface_group = QGroupBox(_("Interface")) verttabs_box = newcb(_("Vertical tabs in panes"), 'vertical_tabs') margin_box = newcb(_("Custom margin for panes:"), 'use_custom_margin') margin_spin = self.create_spinbox("", _("pixels"), 'custom_margin', default=0, min_=0, max_=30) margin_box.toggled.connect(margin_spin.spinbox.setEnabled) margin_box.toggled.connect(margin_spin.slabel.setEnabled) margin_spin.spinbox.setEnabled(self.get_option('use_custom_margin')) margin_spin.slabel.setEnabled(self.get_option('use_custom_margin')) cursor_box = newcb(_("Cursor blinking:"), 'use_custom_cursor_blinking') cursor_spin = self.create_spinbox( "", _("ms"), 'custom_cursor_blinking', default=QApplication.cursorFlashTime(), min_=0, max_=5000, step=100) cursor_box.toggled.connect(cursor_spin.spinbox.setEnabled) cursor_box.toggled.connect(cursor_spin.slabel.setEnabled) cursor_spin.spinbox.setEnabled( self.get_option('use_custom_cursor_blinking')) cursor_spin.slabel.setEnabled( self.get_option('use_custom_cursor_blinking')) margins_cursor_layout = QGridLayout() margins_cursor_layout.addWidget(margin_box, 0, 0) margins_cursor_layout.addWidget(margin_spin.spinbox, 0, 1) margins_cursor_layout.addWidget(margin_spin.slabel, 0, 2) margins_cursor_layout.addWidget(cursor_box, 1, 0) margins_cursor_layout.addWidget(cursor_spin.spinbox, 1, 1) margins_cursor_layout.addWidget(cursor_spin.slabel, 1, 2) margins_cursor_layout.setColumnStretch(2, 100) # Layout interface interface_layout = QVBoxLayout() interface_layout.addWidget(verttabs_box) interface_layout.addLayout(margins_cursor_layout) interface_group.setLayout(interface_layout) if sys.platform == "darwin": def set_open_file(state): if state: register_app_launchservices() else: restore_launchservices() macOS_group = QGroupBox(_("macOS integration")) mac_open_file_box = newcb( _("Open files from Finder with Spyder"), 'mac_open_file', tip=_("Register Spyder with the Launch Services")) mac_open_file_box.toggled.connect(set_open_file) macOS_layout = QVBoxLayout() macOS_layout.addWidget(mac_open_file_box) if als.get_bundle_identifier() is None: # Disable setting mac_open_file_box.setDisabled(True) macOS_layout.addWidget( QLabel( _('Launch Spyder with <code>python.app</code> to enable' ' Apple event integrations.'))) macOS_group.setLayout(macOS_layout) # --- Status bar sbar_group = QGroupBox(_("Status bar")) show_status_bar = newcb(_("Show status bar"), 'show_status_bar') memory_box = newcb(_("Show memory usage every"), 'memory_usage/enable', tip=self.main.mem_status.toolTip()) memory_spin = self.create_spinbox("", _(" ms"), 'memory_usage/timeout', min_=100, max_=1000000, step=100) memory_box.toggled.connect(memory_spin.setEnabled) memory_spin.setEnabled(self.get_option('memory_usage/enable')) memory_box.setEnabled(self.main.mem_status.is_supported()) memory_spin.setEnabled(self.main.mem_status.is_supported()) cpu_box = newcb(_("Show CPU usage every"), 'cpu_usage/enable', tip=self.main.cpu_status.toolTip()) cpu_spin = self.create_spinbox("", _(" ms"), 'cpu_usage/timeout', min_=100, max_=1000000, step=100) cpu_box.toggled.connect(cpu_spin.setEnabled) cpu_spin.setEnabled(self.get_option('cpu_usage/enable')) cpu_box.setEnabled(self.main.cpu_status.is_supported()) cpu_spin.setEnabled(self.main.cpu_status.is_supported()) clock_box = newcb(_("Show clock"), 'clock/enable') status_bar_o = self.get_option('show_status_bar') show_status_bar.toggled.connect(memory_box.setEnabled) show_status_bar.toggled.connect(memory_spin.setEnabled) show_status_bar.toggled.connect(cpu_box.setEnabled) show_status_bar.toggled.connect(cpu_spin.setEnabled) show_status_bar.toggled.connect(clock_box.setEnabled) memory_box.setEnabled(status_bar_o) memory_spin.setEnabled(status_bar_o) cpu_box.setEnabled(status_bar_o) cpu_spin.setEnabled(status_bar_o) clock_box.setEnabled(status_bar_o) # Layout status bar cpu_memory_layout = QGridLayout() cpu_memory_layout.addWidget(memory_box, 0, 0) cpu_memory_layout.addWidget(memory_spin, 0, 1) cpu_memory_layout.addWidget(cpu_box, 1, 0) cpu_memory_layout.addWidget(cpu_spin, 1, 1) cpu_memory_layout.addWidget(clock_box, 2, 0) sbar_layout = QVBoxLayout() sbar_layout.addWidget(show_status_bar) sbar_layout.addLayout(cpu_memory_layout) sbar_group.setLayout(sbar_layout) # --- Screen resolution Group (hidpi) screen_resolution_group = QGroupBox(_("Screen resolution")) screen_resolution_bg = QButtonGroup(screen_resolution_group) screen_resolution_label = QLabel( _("Configuration for high DPI " "screens<br><br>" "Please see " "<a href=\"{0}\">{0}</a><> " "for more information about " "these options (in " "English).").format(HDPI_QT_PAGE)) screen_resolution_label.setWordWrap(True) screen_resolution_label.setOpenExternalLinks(True) normal_radio = self.create_radiobutton( _("Normal"), 'normal_screen_resolution', button_group=screen_resolution_bg) auto_scale_radio = self.create_radiobutton( _("Enable auto high DPI scaling"), 'high_dpi_scaling', button_group=screen_resolution_bg, tip=_("Set this for high DPI displays"), restart=True) custom_scaling_radio = self.create_radiobutton( _("Set a custom high DPI scaling"), 'high_dpi_custom_scale_factor', button_group=screen_resolution_bg, tip=_("Set this for high DPI displays when " "auto scaling does not work"), restart=True) self.custom_scaling_edit = self.create_lineedit( "", 'high_dpi_custom_scale_factors', tip=_("Enter values for different screens " "separated by semicolons ';'.\n" "Float values are supported"), alignment=Qt.Horizontal, regex=r"[0-9]+(?:\.[0-9]*)(;[0-9]+(?:\.[0-9]*))*", restart=True) normal_radio.toggled.connect(self.custom_scaling_edit.setDisabled) auto_scale_radio.toggled.connect(self.custom_scaling_edit.setDisabled) custom_scaling_radio.toggled.connect( self.custom_scaling_edit.setEnabled) # Layout Screen resolution screen_resolution_layout = QVBoxLayout() screen_resolution_layout.addWidget(screen_resolution_label) screen_resolution_inner_layout = QGridLayout() screen_resolution_inner_layout.addWidget(normal_radio, 0, 0) screen_resolution_inner_layout.addWidget(auto_scale_radio, 1, 0) screen_resolution_inner_layout.addWidget(custom_scaling_radio, 2, 0) screen_resolution_inner_layout.addWidget(self.custom_scaling_edit, 2, 1) screen_resolution_layout.addLayout(screen_resolution_inner_layout) screen_resolution_group.setLayout(screen_resolution_layout) if sys.platform == "darwin": interface_tab = self.create_tab(screen_resolution_group, interface_group, macOS_group) else: interface_tab = self.create_tab(screen_resolution_group, interface_group) tabs = QTabWidget() tabs.addTab(interface_tab, _("Interface")) tabs.addTab(self.create_tab(general_group, sbar_group), _("Advanced settings")) vlayout = QVBoxLayout() vlayout.addWidget(tabs) self.setLayout(vlayout)
def __init__(self, layer): super().__init__(layer) self.layer.events.mode.connect(self._on_mode_change) self.layer.events.edge_width.connect(self._on_edge_width_change) self.layer.events.current_edge_color.connect( self._on_current_edge_color_change) self.layer.events.current_face_color.connect( self._on_current_face_color_change) self.layer.events.editable.connect(self._on_editable_change) self.layer.text.events.visible.connect(self._on_text_visibility_change) sld = QSlider(Qt.Horizontal) sld.setFocusPolicy(Qt.NoFocus) sld.setMinimum(0) sld.setMaximum(40) sld.setSingleStep(1) value = self.layer.current_edge_width if isinstance(value, Iterable): if isinstance(value, list): value = np.asarray(value) value = value.mean() sld.setValue(int(value)) sld.valueChanged.connect(self.changeWidth) self.widthSlider = sld def _radio_button( parent, btn_name, mode, action_name, extra_tooltip_text='', **kwargs, ): """ Convenience local function to create a RadioButton and bind it to an action at the same time. Parameters ---------- parent : Any Parent of the generated QtModeRadioButton btn_name : str name fo the button mode : Enum Value Associated to current button action_name : str Action triggered when button pressed extra_tooltip_text : str Text you want added after the automatic tooltip set by the action manager **kwargs: Passed to QtModeRadioButton Returns ------- button: QtModeRadioButton button bound (or that will be bound to) to action `action_name` Notes ----- When shortcuts are modifed/added/removed via the action manager, the tooltip will be updated to reflect the new shortcut. """ action_name = 'napari:' + action_name btn = QtModeRadioButton(parent, btn_name, mode, **kwargs) action_manager.bind_button( action_name, btn, extra_tooltip_text='', ) return btn self.select_button = _radio_button(layer, 'select', Mode.SELECT, "activate_select_mode") self.direct_button = _radio_button(layer, 'direct', Mode.DIRECT, "activate_direct_mode") self.panzoom_button = _radio_button( layer, 'zoom', Mode.PAN_ZOOM, "napari:activate_shape_pan_zoom_mode", extra_tooltip_text=trans._('(or hold Space)'), checked=True, ) self.rectangle_button = _radio_button( layer, 'rectangle', Mode.ADD_RECTANGLE, "activate_add_rectangle_mode", ) self.ellipse_button = _radio_button( layer, 'ellipse', Mode.ADD_ELLIPSE, "activate_add_ellipse_mode", ) self.line_button = _radio_button(layer, 'line', Mode.ADD_LINE, "activate_add_line_mode") self.path_button = _radio_button(layer, 'path', Mode.ADD_PATH, "activate_add_path_mode") self.polygon_button = _radio_button( layer, 'polygon', Mode.ADD_POLYGON, "activate_add_polygon_mode", ) self.vertex_insert_button = _radio_button( layer, 'vertex_insert', Mode.VERTEX_INSERT, "activate_vertex_insert_mode", ) self.vertex_remove_button = _radio_button( layer, 'vertex_remove', Mode.VERTEX_REMOVE, "activate_vertex_remove_mode", ) self.move_front_button = QtModePushButton( layer, 'move_front', slot=self.layer.move_to_front, tooltip=trans._('Move to front'), ) action_manager.bind_button('napari:move_shapes_selection_to_front', self.move_front_button) self.move_back_button = QtModePushButton( layer, 'move_back', slot=self.layer.move_to_back, tooltip=trans._('Move to back'), ) action_manager.bind_button('napari:move_shapes_selection_to_back', self.move_back_button) self.delete_button = QtModePushButton( layer, 'delete_shape', slot=self.layer.remove_selected, tooltip=trans._( "Delete selected shapes ({shortcut})", shortcut=Shortcut('Backspace').platform, ), ) self.button_group = QButtonGroup(self) self.button_group.addButton(self.select_button) self.button_group.addButton(self.direct_button) self.button_group.addButton(self.panzoom_button) self.button_group.addButton(self.rectangle_button) self.button_group.addButton(self.ellipse_button) self.button_group.addButton(self.line_button) self.button_group.addButton(self.path_button) self.button_group.addButton(self.polygon_button) self.button_group.addButton(self.vertex_insert_button) self.button_group.addButton(self.vertex_remove_button) button_grid = QGridLayout() button_grid.addWidget(self.vertex_remove_button, 0, 2) button_grid.addWidget(self.vertex_insert_button, 0, 3) button_grid.addWidget(self.delete_button, 0, 4) button_grid.addWidget(self.direct_button, 0, 5) button_grid.addWidget(self.select_button, 0, 6) button_grid.addWidget(self.panzoom_button, 0, 7) button_grid.addWidget(self.move_back_button, 1, 1) button_grid.addWidget(self.move_front_button, 1, 2) button_grid.addWidget(self.ellipse_button, 1, 3) button_grid.addWidget(self.rectangle_button, 1, 4) button_grid.addWidget(self.polygon_button, 1, 5) button_grid.addWidget(self.line_button, 1, 6) button_grid.addWidget(self.path_button, 1, 7) button_grid.setContentsMargins(5, 0, 0, 5) button_grid.setColumnStretch(0, 1) button_grid.setSpacing(4) self.faceColorEdit = QColorSwatchEdit( initial_color=self.layer.current_face_color, tooltip=trans._('click to set current face color'), ) self._on_current_face_color_change() self.edgeColorEdit = QColorSwatchEdit( initial_color=self.layer.current_edge_color, tooltip=trans._('click to set current edge color'), ) self._on_current_edge_color_change() self.faceColorEdit.color_changed.connect(self.changeFaceColor) self.edgeColorEdit.color_changed.connect(self.changeEdgeColor) text_disp_cb = QCheckBox() text_disp_cb.setToolTip(trans._('toggle text visibility')) text_disp_cb.setChecked(self.layer.text.visible) text_disp_cb.stateChanged.connect(self.change_text_visibility) self.textDispCheckBox = text_disp_cb # grid_layout created in QtLayerControls # addWidget(widget, row, column, [row_span, column_span]) self.grid_layout.addLayout(button_grid, 0, 0, 1, 2) self.grid_layout.addWidget(QLabel(trans._('opacity:')), 1, 0) self.grid_layout.addWidget(self.opacitySlider, 1, 1) self.grid_layout.addWidget(QLabel(trans._('edge width:')), 2, 0) self.grid_layout.addWidget(self.widthSlider, 2, 1) self.grid_layout.addWidget(QLabel(trans._('blending:')), 3, 0) self.grid_layout.addWidget(self.blendComboBox, 3, 1) self.grid_layout.addWidget(QLabel(trans._('face color:')), 4, 0) self.grid_layout.addWidget(self.faceColorEdit, 4, 1) self.grid_layout.addWidget(QLabel(trans._('edge color:')), 5, 0) self.grid_layout.addWidget(self.edgeColorEdit, 5, 1) self.grid_layout.addWidget(QLabel(trans._('display text:')), 6, 0) self.grid_layout.addWidget(self.textDispCheckBox, 6, 1) self.grid_layout.setRowStretch(7, 1) self.grid_layout.setColumnStretch(1, 1) self.grid_layout.setSpacing(4)
def create_widgets(self, show_animation_button=True): """creates the menu objects""" # title self.title_label = QLabel("Title:") self.title_edit = QLineEdit(str(self._default_title)) self.title_button = QPushButton("Default") # Min self.min_label = QLabel("Min:") self.min_edit = QLineEdit(str(self._default_min)) self.min_button = QPushButton("Default") # Max self.max_label = QLabel("Max:") self.max_edit = QLineEdit(str(self._default_max)) self.max_button = QPushButton("Default") #--------------------------------------- # Format self.format_label = QLabel("Format (e.g. %.3f, %g, %.6e):") self.format_edit = QLineEdit(str(self._format)) self.format_button = QPushButton("Default") #--------------------------------------- # Scale self.scale_label = QLabel("True Scale:") self.scale_edit = QLineEdit(str(self._scale)) self.scale_button = QPushButton("Default") if self._icase_disp is None: self.scale_label.setVisible(False) self.scale_edit.setVisible(False) self.scale_button.setVisible(False) # Phase self.phase_label = QLabel("Phase (deg):") self.phase_edit = QLineEdit(str(self._phase)) self.phase_button = QPushButton("Default") if self._icase_disp is None or self._default_phase is None: self.phase_label.setVisible(False) self.phase_edit.setVisible(False) self.phase_button.setVisible(False) self.phase_edit.setText('0.0') #--------------------------------------- self.arrow_scale_label = QLabel("Arrow Scale:") self.arrow_scale_edit = QLineEdit(str(self._arrow_scale)) self.arrow_scale_button = QPushButton("Default") if self._icase_vector is None: self.arrow_scale_label.setVisible(False) self.arrow_scale_edit.setVisible(False) self.arrow_scale_button.setVisible(False) #tip = QtGui.QToolTip() #tip.setTe #self.format_edit.toolTip(tip) #--------------------------------------- # nlabels self.nlabels_label = QLabel("Number of Labels:") self.nlabels_edit = QLineEdit(str(self._nlabels)) self.nlabels_button = QPushButton("Default") self.labelsize_label = QLabel("Label Size:") self.labelsize_edit = QLineEdit(str(self._labelsize)) self.labelsize_button = QPushButton("Default") self.ncolors_label = QLabel("Number of Colors:") self.ncolors_edit = QLineEdit(str(self._ncolors)) self.ncolors_button = QPushButton("Default") self.colormap_label = QLabel("Color Map:") self.colormap_edit = QComboBox(self) self.colormap_button = QPushButton("Default") for key in colormap_keys: self.colormap_edit.addItem(key) self.colormap_edit.setCurrentIndex(colormap_keys.index(self._colormap)) # -------------------------------------------------------------- # the header self.grid2_title = QLabel("Color Scale:") # red/blue or blue/red self.low_to_high_radio = QRadioButton('Low -> High') self.high_to_low_radio = QRadioButton('High -> Low') widget = QWidget(self) low_to_high_group = QButtonGroup(widget) low_to_high_group.addButton(self.low_to_high_radio) low_to_high_group.addButton(self.high_to_low_radio) self.low_to_high_radio.setChecked(self._default_is_low_to_high) self.high_to_low_radio.setChecked(not self._default_is_low_to_high) # horizontal / vertical self.horizontal_radio = QRadioButton("Horizontal") self.vertical_radio = QRadioButton("Vertical") widget = QWidget(self) horizontal_vertical_group = QButtonGroup(widget) horizontal_vertical_group.addButton(self.horizontal_radio) horizontal_vertical_group.addButton(self.vertical_radio) self.horizontal_radio.setChecked(self._default_is_horizontal) self.vertical_radio.setChecked(not self._default_is_horizontal) # on / off self.show_radio = QRadioButton("Show") self.hide_radio = QRadioButton("Hide") widget = QWidget(self) show_hide_group = QButtonGroup(widget) show_hide_group.addButton(self.show_radio) show_hide_group.addButton(self.hide_radio) self.show_radio.setChecked(self._default_is_shown) self.hide_radio.setChecked(not self._default_is_shown) # -------------------------------------------------------------- if self._icase_fringe is None: self.title_label.setVisible(False) self.title_edit.setVisible(False) self.title_button.setVisible(False) if not self._is_fringe: self.max_label.hide() self.min_label.hide() self.max_edit.hide() self.min_edit.hide() self.max_button.hide() self.min_button.hide() self.format_label.hide() self.format_edit.hide() self.format_button.hide() self.nlabels_label.hide() self.nlabels_edit.hide() self.nlabels_button.hide() self.ncolors_label.hide() self.ncolors_edit.hide() self.ncolors_button.hide() self.grid2_title.hide() self.vertical_radio.hide() self.horizontal_radio.hide() self.show_radio.hide() self.hide_radio.hide() self.low_to_high_radio.hide() self.high_to_low_radio.hide() self.colormap_label.hide() self.colormap_edit.hide() self.colormap_button.hide() self.animate_button = QPushButton('Create Animation') self.animate_button.setVisible(show_animation_button) #self.advanced_button = QPushButton('Advanced') if self._default_icase_disp is None: # or self._default_icase_vector is None: self.animate_button.setEnabled(False) self.animate_button.setToolTip(ANIMATE_TOOLTIP_OFF) else: self.animate_button.setEnabled(True) self.animate_button.setToolTip(ANIMATE_TOOLTIP_ON) # closing self.apply_button = QPushButton("Apply") self.ok_button = QPushButton("OK") self.cancel_button = QPushButton("Cancel")
def __init__(self, layer): super().__init__(layer) self.layer.events.mode.connect(self._on_mode_change) self.layer.events.selected_label.connect(self._on_selection_change) self.layer.events.brush_size.connect(self._on_brush_size_change) self.layer.events.contiguous.connect(self._on_contig_change) self.layer.events.n_dimensional.connect(self._on_n_dim_change) self.layer.events.editable.connect(self._on_editable_change) self.layer.events.preserve_labels.connect( self._on_preserve_labels_change ) self.layer.events.color_mode.connect(self._on_color_mode_change) # selection spinbox self.selectionSpinBox = QSpinBox() self.selectionSpinBox.setKeyboardTracking(False) self.selectionSpinBox.setSingleStep(1) self.selectionSpinBox.setMinimum(0) self.selectionSpinBox.setMaximum(2147483647) self.selectionSpinBox.valueChanged.connect(self.changeSelection) self.selectionSpinBox.setAlignment(Qt.AlignCenter) self._on_selection_change() sld = QSlider(Qt.Horizontal) sld.setFocusPolicy(Qt.NoFocus) sld.setMinimum(1) sld.setMaximum(40) sld.setSingleStep(1) sld.valueChanged.connect(self.changeSize) self.brushSizeSlider = sld self._on_brush_size_change() contig_cb = QCheckBox() contig_cb.setToolTip('contiguous editing') contig_cb.stateChanged.connect(self.change_contig) self.contigCheckBox = contig_cb self._on_contig_change() ndim_cb = QCheckBox() ndim_cb.setToolTip('n-dimensional editing') ndim_cb.stateChanged.connect(self.change_ndim) self.ndimCheckBox = ndim_cb self._on_n_dim_change() preserve_labels_cb = QCheckBox() preserve_labels_cb.setToolTip( 'preserve existing labels while painting' ) preserve_labels_cb.stateChanged.connect(self.change_preserve_labels) self.preserveLabelsCheckBox = preserve_labels_cb self._on_preserve_labels_change() # shuffle colormap button self.colormapUpdate = QtModePushButton( None, 'shuffle', slot=self.changeColor, tooltip='shuffle colors', ) self.panzoom_button = QtModeRadioButton( layer, 'zoom', Mode.PAN_ZOOM, tooltip='Pan/zoom mode (Space)', checked=True, ) self.pick_button = QtModeRadioButton( layer, 'picker', Mode.PICK, tooltip='Pick mode' ) self.paint_button = QtModeRadioButton( layer, 'paint', Mode.PAINT, tooltip='Paint mode' ) btn = 'Cmd' if sys.platform == 'darwin' else 'Ctrl' self.fill_button = QtModeRadioButton( layer, 'fill', Mode.FILL, tooltip=f'Fill mode ({btn})' ) self.erase_button = QtModeRadioButton( layer, 'erase', Mode.ERASE, tooltip='Erase mode (Alt)' ) self.button_group = QButtonGroup(self) self.button_group.addButton(self.panzoom_button) self.button_group.addButton(self.paint_button) self.button_group.addButton(self.pick_button) self.button_group.addButton(self.fill_button) self.button_group.addButton(self.erase_button) self._on_editable_change() button_row = QHBoxLayout() button_row.addStretch(1) button_row.addWidget(self.colormapUpdate) button_row.addWidget(self.erase_button) button_row.addWidget(self.fill_button) button_row.addWidget(self.paint_button) button_row.addWidget(self.pick_button) button_row.addWidget(self.panzoom_button) button_row.setSpacing(4) button_row.setContentsMargins(0, 0, 0, 5) color_mode_comboBox = QComboBox(self) color_mode_comboBox.addItems(LabelColorMode.keys()) index = color_mode_comboBox.findText( self.layer.color_mode, Qt.MatchFixedString ) color_mode_comboBox.setCurrentIndex(index) color_mode_comboBox.activated[str].connect(self.change_color_mode) self.colorModeComboBox = color_mode_comboBox self._on_color_mode_change() color_layout = QHBoxLayout() color_layout.addWidget(QtColorBox(layer)) color_layout.addWidget(self.selectionSpinBox) # grid_layout created in QtLayerControls # addWidget(widget, row, column, [row_span, column_span]) self.grid_layout.addLayout(button_row, 0, 0, 1, 4) self.grid_layout.addWidget(QLabel('label:'), 1, 0, 1, 1) self.grid_layout.addLayout(color_layout, 1, 1, 1, 3) self.grid_layout.addWidget(QLabel('opacity:'), 2, 0, 1, 1) self.grid_layout.addWidget(self.opacitySlider, 2, 1, 1, 3) self.grid_layout.addWidget(QLabel('brush size:'), 3, 0, 1, 1) self.grid_layout.addWidget(self.brushSizeSlider, 3, 1, 1, 3) self.grid_layout.addWidget(QLabel('blending:'), 4, 0, 1, 1) self.grid_layout.addWidget(self.blendComboBox, 4, 1, 1, 3) self.grid_layout.addWidget(QLabel('color mode:'), 5, 0, 1, 1) self.grid_layout.addWidget(self.colorModeComboBox, 5, 1, 1, 3) self.grid_layout.addWidget(QLabel('contiguous:'), 6, 0, 1, 1) self.grid_layout.addWidget(self.contigCheckBox, 6, 1, 1, 1) self.grid_layout.addWidget(QLabel('n-dim:'), 6, 2, 1, 1) self.grid_layout.addWidget(self.ndimCheckBox, 6, 3, 1, 1) self.grid_layout.addWidget(QLabel('preserve labels:'), 7, 0, 1, 2) self.grid_layout.addWidget(self.preserveLabelsCheckBox, 7, 1, 1, 1) self.grid_layout.setRowStretch(8, 1) self.grid_layout.setColumnStretch(1, 1) self.grid_layout.setSpacing(4)
def __init__(self, settings, plotWidget, parent=None): super().__init__(parent) self.mainwindow = parent self.plotWidget = plotWidget # xmin self.xminLabel = QLabel(self.tr('xmin:')) self.xminSpinBox = CoordSpinBox() self.xminLabel.setBuddy(self.xminSpinBox) self.xminSpinBox.editingFinished.connect(self.change_limits) # xmax self.xmaxLabel = QLabel(self.tr('xmax:')) self.xmaxSpinBox = CoordSpinBox() self.xmaxLabel.setBuddy(self.xmaxSpinBox) self.xmaxSpinBox.editingFinished.connect(self.change_limits) # ymin self.yminLabel = QLabel(self.tr('ymin:')) self.yminSpinBox = CoordSpinBox() self.yminLabel.setBuddy(self.yminSpinBox) self.yminSpinBox.editingFinished.connect(self.change_limits) # ymax self.ymaxLabel = QLabel(self.tr('ymax:')) self.ymaxSpinBox = CoordSpinBox() self.ymaxLabel.setBuddy(self.ymaxSpinBox) self.ymaxSpinBox.editingFinished.connect(self.change_limits) # Autoscale Radio Group self.autoscaleButtonGroup = QButtonGroup() # Autoscale Group Box self.autoscaleGroupBox = QGroupBox() # autoscale self.autoscaleRadioButton = QRadioButton(self.tr("autoscale")) self.autoscaleButtonGroup.addButton(self.autoscaleRadioButton) # autotrack self.autoscrollRadioButton = QRadioButton(self.tr("autoscroll")) self.autoscaleButtonGroup.addButton(self.autoscrollRadioButton) # no autoscale self.manualscaleRadioButton = QRadioButton(self.tr("manual")) self.autoscaleButtonGroup.addButton(self.manualscaleRadioButton) layout = QVBoxLayout() layout.addWidget(self.autoscaleRadioButton) layout.addWidget(self.autoscrollRadioButton) layout.addWidget(self.manualscaleRadioButton) self.autoscaleGroupBox.setLayout(layout) # Layout layout = QGridLayout() layout.addWidget(self.xminLabel, 1, 0) layout.addWidget(self.xminSpinBox, 1, 1) layout.addWidget(self.xmaxLabel, 2, 0) layout.addWidget(self.xmaxSpinBox, 2, 1) layout.addWidget(self.yminLabel, 3, 0) layout.addWidget(self.yminSpinBox, 3, 1) layout.addWidget(self.ymaxLabel, 4, 0) layout.addWidget(self.ymaxSpinBox, 4, 1) layout.addWidget(self.autoscaleGroupBox, 5, 0, 1, 2) layout.setRowStretch(6, 1) self.setLayout(layout) # settings self.settings = settings self.settings.add_handler(S_XMIN, self.xminSpinBox) self.settings.add_handler(S_XMAX, self.xmaxSpinBox) self.settings.add_handler(S_YMIN, self.yminSpinBox) self.settings.add_handler(S_YMAX, self.ymaxSpinBox) self.settings.add_handler(S_AUTOSCALE, self.autoscaleButtonGroup)
def initialize_content(self): """ Initialize the content of the frame """ # Validators self._content.low_scale_edit.setValidator(QDoubleValidator(self._content.low_scale_edit)) self._content.medium_scale_edit.setValidator(QDoubleValidator(self._content.medium_scale_edit)) self._content.high_scale_edit.setValidator(QDoubleValidator(self._content.high_scale_edit)) self._content.low_min_edit.setValidator(QDoubleValidator(self._content.low_min_edit)) self._content.low_max_edit.setValidator(QDoubleValidator(self._content.low_max_edit)) self._content.medium_min_edit.setValidator(QDoubleValidator(self._content.medium_min_edit)) self._content.medium_max_edit.setValidator(QDoubleValidator(self._content.medium_max_edit)) # Browse buttons self._content.low_q_browse_button.clicked.connect(self._low_q_browse) self._content.medium_q_browse_button.clicked.connect(self._medium_q_browse) self._content.high_q_browse_button.clicked.connect(self._high_q_browse) self._content.low_q_combo.activated.connect(self._update_low_q) self._content.medium_q_combo.activated.connect(self._update_medium_q) self._content.high_q_combo.activated.connect(self._update_high_q) # Radio buttons self._content.low_radio.clicked.connect(self._low_q_selected) self._content.medium_radio.clicked.connect(self._medium_q_selected) self._content.high_radio.clicked.connect(self._high_q_selected) # Selection buttons self._content.low_range_button.clicked.connect(self._low_range) self._content.medium_range_button.clicked.connect(self._medium_range) # Scale factors self._content.low_scale_edit.returnPressed.connect(self._update_low_scale) self._content.medium_scale_edit.returnPressed.connect(self._update_medium_scale) self._content.high_scale_edit.returnPressed.connect(self._update_high_scale) # Apply and save buttons self._content.apply_button.clicked.connect(self._apply) self._content.save_result_button.clicked.connect(self._save_result) # Create button group for data set selection g = QButtonGroup(self) g.addButton(self._content.low_radio) g.addButton(self._content.medium_radio) g.addButton(self._content.high_radio) g.setExclusive(True) self._content.low_radio.setChecked(True) self._content.low_q_combo.insertItem(0, "") self.populate_combobox(self._content.low_q_combo) self._content.low_q_combo.setEditable(True) self._content.medium_q_combo.insertItem(0, "") self.populate_combobox(self._content.medium_q_combo) self._content.medium_q_combo.setEditable(True) self._content.high_q_combo.insertItem(0, "") self.populate_combobox(self._content.high_q_combo) self._content.high_q_combo.setEditable(True) # pylint: disable = no-self-argument class ShowEventFilter(QObject): def eventFilter(obj_self, filteredObj, event): if event.type() == QEvent.HoverEnter: self.populate_combobox(filteredObj) filteredObj.update() elif event.type() == QEvent.KeyPress: if filteredObj == self._content.low_q_combo: self._low_q_modified = True elif filteredObj == self._content.medium_q_combo: self._medium_q_modified = True elif filteredObj == self._content.high_q_combo: self._high_q_modified = True if event.key() == Qt.Key_Return or event.key() == Qt.Key_Enter: filteredObj.setItemText(0, filteredObj.lineEdit().text()) if filteredObj == self._content.low_q_combo: self._update_low_q() elif filteredObj == self._content.medium_q_combo: self._update_medium_q() elif filteredObj == self._content.high_q_combo: self._update_high_q() return True return QObject.eventFilter(obj_self, filteredObj, event) eventFilter = ShowEventFilter(self) self._content.low_q_combo.installEventFilter(eventFilter) self._content.medium_q_combo.installEventFilter(eventFilter) self._content.high_q_combo.installEventFilter(eventFilter)
def setup_page(self): newcb = self.create_checkbox # Python executable Group pyexec_group = QGroupBox(_("Python interpreter")) pyexec_bg = QButtonGroup(pyexec_group) pyexec_label = QLabel( _("Select the Python interpreter for all Spyder " "consoles")) self.def_exec_radio = self.create_radiobutton( _("Default (i.e. the same as Spyder's)"), 'default', button_group=pyexec_bg, ) self.cus_exec_radio = self.create_radiobutton( _("Use the following Python interpreter:"), 'custom', button_group=pyexec_bg, ) if os.name == 'nt': filters = _("Executables") + " (*.exe)" else: filters = None pyexec_layout = QVBoxLayout() pyexec_layout.addWidget(pyexec_label) pyexec_layout.addWidget(self.def_exec_radio) pyexec_layout.addWidget(self.cus_exec_radio) self.validate_custom_interpreters_list() self.cus_exec_combo = self.create_file_combobox( _('Recent custom interpreters'), self.get_option('custom_interpreters_list'), 'custom_interpreter', filters=filters, default_line_edit=True, adjust_to_contents=True, validate_callback=programs.is_python_interpreter, ) self.def_exec_radio.toggled.connect(self.cus_exec_combo.setDisabled) self.cus_exec_radio.toggled.connect(self.cus_exec_combo.setEnabled) pyexec_layout.addWidget(self.cus_exec_combo) pyexec_group.setLayout(pyexec_layout) self.pyexec_edit = self.cus_exec_combo.combobox.lineEdit() # UMR Group umr_group = QGroupBox(_("User Module Reloader (UMR)")) umr_label = QLabel( _("UMR forces Python to reload modules which were " "imported when executing a file in a Python or " "IPython console with the <i>runfile</i> " "function.")) umr_label.setWordWrap(True) umr_enabled_box = newcb( _("Enable UMR"), 'umr/enabled', msg_if_enabled=True, msg_warning=_( "This option will enable the User Module Reloader (UMR) " "in Python/IPython consoles. UMR forces Python to " "reload deeply modules during import when running a " "Python script using the Spyder's builtin function " "<b>runfile</b>." "<br><br><b>1.</b> UMR may require to restart the " "console in which it will be called " "(otherwise only newly imported modules will be " "reloaded when executing files)." "<br><br><b>2.</b> If errors occur when re-running a " "PyQt-based program, please check that the Qt objects " "are properly destroyed (e.g. you may have to use the " "attribute <b>Qt.WA_DeleteOnClose</b> on your main " "window, using the <b>setAttribute</b> method)"), ) umr_verbose_box = newcb( _("Show reloaded modules list"), 'umr/verbose', msg_info=_("Please note that these changes will " "be applied only to new consoles"), ) umr_namelist_btn = QPushButton( _("Set UMR excluded (not reloaded) modules")) umr_namelist_btn.clicked.connect(self.set_umr_namelist) umr_layout = QVBoxLayout() umr_layout.addWidget(umr_label) umr_layout.addWidget(umr_enabled_box) umr_layout.addWidget(umr_verbose_box) umr_layout.addWidget(umr_namelist_btn) umr_group.setLayout(umr_layout) vlayout = QVBoxLayout() vlayout.addWidget(pyexec_group) vlayout.addWidget(umr_group) vlayout.addStretch(1) self.setLayout(vlayout)
def __init__(self, layer): super().__init__(layer) self.layer.events.mode.connect(self._on_mode_change) self.layer.events.selected_label.connect(self._on_selection_change) self.layer.events.brush_size.connect(self._on_brush_size_change) self.layer.events.contiguous.connect(self._on_contig_change) self.layer.events.n_dimensional.connect(self._on_n_dim_change) self.layer.events.editable.connect(self._on_editable_change) # shuffle colormap button self.colormapUpdate = QPushButton('shuffle colors') self.colormapUpdate.setObjectName('shuffleButton') self.colormapUpdate.clicked.connect(self.changeColor) # selection spinbox self.selectionSpinBox = QSpinBox() self.selectionSpinBox.setKeyboardTracking(False) self.selectionSpinBox.setSingleStep(1) self.selectionSpinBox.setMinimum(0) self.selectionSpinBox.setMaximum(2147483647) self.selectionSpinBox.valueChanged.connect(self.changeSelection) self.selectionSpinBox.setAlignment(Qt.AlignCenter) self._on_selection_change() sld = QSlider(Qt.Horizontal) sld.setFocusPolicy(Qt.NoFocus) sld.setMinimum(1) sld.setMaximum(40) sld.setSingleStep(1) sld.valueChanged.connect(self.changeSize) self.brushSizeSlider = sld self._on_brush_size_change() contig_cb = QCheckBox() contig_cb.setToolTip('contiguous editing') contig_cb.stateChanged.connect(self.change_contig) self.contigCheckBox = contig_cb self._on_contig_change() ndim_cb = QCheckBox() ndim_cb.setToolTip('n-dimensional editing') ndim_cb.stateChanged.connect(self.change_ndim) self.ndimCheckBox = ndim_cb self._on_n_dim_change() self.panzoom_button = QtModeRadioButton(layer, 'zoom', Mode.PAN_ZOOM, tooltip='Pan/zoom mode', checked=True) self.pick_button = QtModeRadioButton(layer, 'picker', Mode.PICKER, tooltip='Pick mode') self.paint_button = QtModeRadioButton(layer, 'paint', Mode.PAINT, tooltip='Paint mode') self.fill_button = QtModeRadioButton(layer, 'fill', Mode.FILL, tooltip='Fill mode') self.button_group = QButtonGroup(self) self.button_group.addButton(self.panzoom_button) self.button_group.addButton(self.paint_button) self.button_group.addButton(self.pick_button) self.button_group.addButton(self.fill_button) self._on_editable_change() button_row = QHBoxLayout() button_row.addStretch(1) button_row.addWidget(self.pick_button) button_row.addWidget(self.fill_button) button_row.addWidget(self.paint_button) button_row.addWidget(self.panzoom_button) button_row.setSpacing(4) button_row.setContentsMargins(0, 0, 0, 5) color_layout = QHBoxLayout() color_layout.addWidget(QtColorBox(layer)) color_layout.addWidget(self.selectionSpinBox) # grid_layout created in QtLayerControls # addWidget(widget, row, column, [row_span, column_span]) self.grid_layout.addLayout(button_row, 0, 1) self.grid_layout.addWidget(self.colormapUpdate, 0, 0) self.grid_layout.addWidget(QLabel('label:'), 1, 0) self.grid_layout.addLayout(color_layout, 1, 1) self.grid_layout.addWidget(QLabel('opacity:'), 2, 0) self.grid_layout.addWidget(self.opacitySlider, 2, 1) self.grid_layout.addWidget(QLabel('brush size:'), 3, 0) self.grid_layout.addWidget(self.brushSizeSlider, 3, 1) self.grid_layout.addWidget(QLabel('blending:'), 4, 0) self.grid_layout.addWidget(self.blendComboBox, 4, 1) self.grid_layout.addWidget(QLabel('contiguous:'), 5, 0) self.grid_layout.addWidget(self.contigCheckBox, 5, 1) self.grid_layout.addWidget(QLabel('n-dim:'), 6, 0) self.grid_layout.addWidget(self.ndimCheckBox, 6, 1) self.grid_layout.setRowStretch(7, 1) self.grid_layout.setColumnStretch(1, 1) self.grid_layout.setSpacing(4)