def _create_axis_label_widget(self, axis): """Create the axis label widget which accompanies its slider. Parameters ---------- axis : int axis index Returns ------- label : QLabel A label with the given text """ label = QLineEdit() label.setText(self.dims.axis_labels[axis]) label.home(False) label.setToolTip('Axis label') label.setAcceptDrops(False) label.setEnabled(True) def changeText(): with self.dims.events.axis_labels.blocker(): self.dims.set_axis_label(axis, label.text()) label.clearFocus() self.setFocus() label.editingFinished.connect(changeText) return label
def __init__(self, layer): super().__init__() self.layer = layer self.layer.events.select.connect(self._on_select_change) self.layer.events.deselect.connect(self._on_deselect_change) self.layer.events.name.connect(self._on_name_change) self.layer.events.visible.connect(self._on_visible_change) self.layer.events.thumbnail.connect(self._on_thumbnail_change) self.setAttribute(Qt.WA_DeleteOnClose) self.setObjectName('layer') self.layout = QHBoxLayout() self.layout.setContentsMargins(0, 0, 0, 0) self.setLayout(self.layout) tb = QLabel(self) tb.setObjectName('thumbnail') tb.setToolTip(trans._('Layer thumbnail')) self.thumbnailLabel = tb self._on_thumbnail_change() self.layout.addWidget(tb) cb = QCheckBox(self) cb.setObjectName('visibility') cb.setToolTip(trans._('Layer visibility')) cb.setChecked(self.layer.visible) cb.setProperty('mode', 'visibility') cb.stateChanged.connect(self.changeVisible) self.visibleCheckBox = cb self.layout.addWidget(cb) textbox = QLineEdit(self) textbox.setText(layer.name) textbox.home(False) textbox.setToolTip(self.layer.name) textbox.setAcceptDrops(False) textbox.setEnabled(True) textbox.editingFinished.connect(self.changeText) self.nameTextBox = textbox self.layout.addWidget(textbox) ltb = QLabel(self) layer_type = type(layer).__name__ ltb.setObjectName(layer_type) ltb.setProperty('layer_type_label', True) ltb.setToolTip(trans._('Layer type')) self.typeLabel = ltb self.layout.addWidget(ltb) msg = trans._('Click to select\nDrag to rearrange') self.setToolTip(msg) self.setSelected(self.layer.selected)
def _create_axis_label_widget(self): """Create the axis label widget which accompanies its slider.""" label = QLineEdit(self) label.setObjectName('axis_label') # needed for _update_label label.setText(self.dims.axis_labels[self.axis]) label.home(False) label.setToolTip('Edit to change axis label') label.setAcceptDrops(False) label.setEnabled(True) label.setAlignment(Qt.AlignRight) label.setContentsMargins(0, 0, 2, 0) label.textChanged.connect(self._update_label) label.editingFinished.connect(self._clear_label_focus) self.axis_label = label
def __init__(self, layer): super().__init__() self.layer = layer layer.events.select.connect(lambda v: self.setSelected(True)) layer.events.deselect.connect(lambda v: self.setSelected(False)) layer.events.name.connect(self._on_layer_name_change) layer.events.blending.connect(self._on_blending_change) layer.events.opacity.connect(self._on_opacity_change) layer.events.visible.connect(self._on_visible_change) layer.events.thumbnail.connect(self._on_thumbnail_change) self.setObjectName('layer') self.vbox_layout = QVBoxLayout() self.top = QFrame() self.top_layout = QHBoxLayout() self.grid = QFrame() self.grid_layout = QGridLayout() self.vbox_layout.addWidget(self.top) self.vbox_layout.addWidget(self.grid) self.vbox_layout.setSpacing(0) self.top.setFixedHeight(38) self.top_layout.setContentsMargins(0, 0, 0, 0) self.grid_layout.setContentsMargins(0, 0, 0, 0) self.top_layout.setAlignment(Qt.AlignCenter) self.top.setLayout(self.top_layout) self.grid.setLayout(self.grid_layout) self.setLayout(self.vbox_layout) self.name_column = 0 self.property_column = 1 cb = QCheckBox(self) cb.setObjectName('visibility') cb.setToolTip('Layer visibility') cb.setChecked(self.layer.visible) cb.setProperty('mode', 'visibility') cb.stateChanged.connect(lambda state=cb: self.changeVisible(state)) self.visibleCheckBox = cb self.top_layout.addWidget(cb) tb = QLabel(self) tb.setObjectName('thumbmnail') tb.setToolTip('Layer thumbmnail') self.thumbnail_label = tb self._on_thumbnail_change(None) self.top_layout.addWidget(tb) textbox = QLineEdit(self) textbox.setText(layer.name) textbox.home(False) textbox.setToolTip('Layer name') textbox.setAcceptDrops(False) textbox.setEnabled(True) textbox.editingFinished.connect(self.changeText) self.nameTextBox = textbox self.top_layout.addWidget(textbox) pb = QPushButton(self) pb.setToolTip('Expand properties') pb.clicked.connect(self.changeExpanded) pb.setObjectName('expand') self.expand_button = pb self.top_layout.addWidget(pb) row = self.grid_layout.rowCount() sld = QSlider(Qt.Horizontal, self) sld.setFocusPolicy(Qt.NoFocus) sld.setMinimum(0) sld.setMaximum(100) sld.setSingleStep(1) sld.setValue(self.layer.opacity * 100) sld.valueChanged[int].connect( lambda value=sld: self.changeOpacity(value)) self.opacitySilder = sld row = self.grid_layout.rowCount() self.grid_layout.addWidget(QLabel('opacity:'), row, self.name_column) self.grid_layout.addWidget(sld, row, self.property_column) row = self.grid_layout.rowCount() blend_comboBox = QComboBox() for blend in Blending: blend_comboBox.addItem(str(blend)) index = blend_comboBox.findText(self.layer.blending, Qt.MatchFixedString) blend_comboBox.setCurrentIndex(index) blend_comboBox.activated[str].connect( lambda text=blend_comboBox: self.changeBlending(text)) self.blendComboBox = blend_comboBox self.grid_layout.addWidget(QLabel('blending:'), row, self.name_column) self.grid_layout.addWidget(blend_comboBox, row, self.property_column) msg = 'Click to select\nDrag to rearrange\nDouble click to expand' self.setToolTip(msg) self.setExpanded(False) self.setFixedWidth(250) self.grid_layout.setColumnMinimumWidth(0, 100) self.grid_layout.setColumnMinimumWidth(1, 100) self.setSelected(self.layer.selected)
def __init__(self, layer): super().__init__() self.layer = layer layer.events.select.connect(self._on_select) layer.events.deselect.connect(self._on_deselect) layer.events.name.connect(self._on_layer_name_change) layer.events.blending.connect(self._on_blending_change) layer.events.opacity.connect(self._on_opacity_change) layer.events.visible.connect(self._on_visible_change) self.setObjectName('layer') self.grid_layout = QGridLayout() cb = QCheckBox(self) cb.setObjectName('visibility') cb.setToolTip('Layer visibility') cb.setChecked(self.layer.visible) cb.setProperty('mode', 'visibility') cb.stateChanged.connect(lambda state=cb: self.changeVisible(state)) self.visibleCheckBox = cb self.grid_layout.addWidget(cb, 0, 0) textbox = QLineEdit(self) textbox.setText(layer.name) textbox.home(False) textbox.setToolTip('Layer name') textbox.setFixedWidth(122) textbox.setAcceptDrops(False) textbox.setEnabled(True) textbox.editingFinished.connect(self.changeText) self.nameTextBox = textbox self.grid_layout.addWidget(textbox, 0, 1) self.grid_layout.addWidget(QLabel('opacity:'), 1, 0) sld = QSlider(Qt.Horizontal, self) sld.setFocusPolicy(Qt.NoFocus) sld.setFixedWidth(110) sld.setMinimum(0) sld.setMaximum(100) sld.setSingleStep(1) sld.setValue(self.layer.opacity * 100) sld.valueChanged[int].connect( lambda value=sld: self.changeOpacity(value)) self.opacitySilder = sld self.grid_layout.addWidget(sld, 1, 1) blend_comboBox = QComboBox() for blend in self.layer._blending_modes: blend_comboBox.addItem(blend) index = blend_comboBox.findText(self.layer.blending, Qt.MatchFixedString) blend_comboBox.setCurrentIndex(index) blend_comboBox.activated[str].connect( lambda text=blend_comboBox: self.changeBlending(text)) self.blendComboBox = blend_comboBox self.grid_layout.addWidget(QLabel('blending:'), 2, 0) self.grid_layout.addWidget(blend_comboBox, 2, 1) self.setLayout(self.grid_layout) msg = 'Click to select\nDrag to rearrange\nDouble click to expand' self.setToolTip(msg) self.setExpanded(False) self.setFixedWidth(250) self.grid_layout.setColumnMinimumWidth(0, 100) self.grid_layout.setColumnMinimumWidth(1, 100) self.layer.selected = True