def widget(self): """Get the QWidget of the Field.""" widget = QtWidgets.QWidget() hbox = QtWidgets.QHBoxLayout(widget) hbox.setContentsMargins(0, 0, 0, 0) validator = QtGui.QDoubleValidator(-999999.0, 999999.0, self.precision) widget_x = QtWidgets.QLineEdit(str(self._value[0])) widget_x.setToolTip(self.help_text) widget_x.setValidator(validator) widget_x.textChanged.connect(self.set_value_x) hbox.addWidget(widget_x) widget_y = QtWidgets.QLineEdit(str(self._value[1])) widget_y.setToolTip(self.help_text) widget_y.setValidator(validator) widget_y.textChanged.connect(self.set_value_y) hbox.addWidget(widget_y) widget_z = QtWidgets.QLineEdit(str(self._value[2])) widget_z.setToolTip(self.help_text) widget_z.setValidator(validator) widget_z.textChanged.connect(self.set_value_z) hbox.addWidget(widget_z) return widget
def __init__(self, parent=None): super(ControlWindow, self).__init__(parent) self.setWindowTitle('CMT Control Creator') self.resize(300, 500) vbox = QtWidgets.QVBoxLayout(self) size = 20 label_width = 60 icon_left = QtGui.QIcon( QtGui.QPixmap(':/nudgeLeft.png').scaled(size, size)) icon_right = QtGui.QIcon( QtGui.QPixmap(':/nudgeRight.png').scaled(size, size)) validator = QtGui.QDoubleValidator(-180.0, 180.0, 2) grid = QtWidgets.QGridLayout() vbox.addLayout(grid) # Rotate X label = QtWidgets.QLabel('Rotate X') label.setMaximumWidth(label_width) grid.addWidget(label, 0, 0, QtCore.Qt.AlignRight) b = QtWidgets.QPushButton(icon_left, '') b.released.connect(partial(self.rotate_x, direction=-1)) grid.addWidget(b, 0, 1) self.offset_x = QtWidgets.QLineEdit('45.0') self.offset_x.setValidator(validator) grid.addWidget(self.offset_x, 0, 2) b = QtWidgets.QPushButton(icon_right, '') b.released.connect(partial(self.rotate_x, direction=1)) grid.addWidget(b, 0, 3) # Rotate Y label = QtWidgets.QLabel('Rotate Y') label.setMaximumWidth(label_width) grid.addWidget(label, 1, 0, QtCore.Qt.AlignRight) b = QtWidgets.QPushButton(icon_left, '') b.released.connect(partial(self.rotate_y, direction=-1)) grid.addWidget(b, 1, 1) self.offset_y = QtWidgets.QLineEdit('45.0') self.offset_y.setValidator(validator) grid.addWidget(self.offset_y, 1, 2) b = QtWidgets.QPushButton(icon_right, '') b.released.connect(partial(self.rotate_y, direction=1)) grid.addWidget(b, 1, 3) # Rotate Z label = QtWidgets.QLabel('Rotate Z') label.setMaximumWidth(label_width) grid.addWidget(label, 2, 0, QtCore.Qt.AlignRight) b = QtWidgets.QPushButton(icon_left, '') b.released.connect(partial(self.rotate_z, direction=-1)) grid.addWidget(b, 2, 1) self.offset_z = QtWidgets.QLineEdit('45.0') self.offset_z.setValidator(validator) grid.addWidget(self.offset_z, 2, 2) b = QtWidgets.QPushButton(icon_right, '') b.released.connect(partial(self.rotate_z, direction=1)) grid.addWidget(b, 2, 3) grid.setColumnStretch(2, 2) hbox = QtWidgets.QHBoxLayout() vbox.addLayout(hbox) b = QtWidgets.QPushButton('Export Selected') b.released.connect(self.dump_controls) hbox.addWidget(b) b = QtWidgets.QPushButton('Set Color') b.released.connect(self.set_color) hbox.addWidget(b) hbox = QtWidgets.QHBoxLayout() vbox.addLayout(hbox) b = QtWidgets.QPushButton('Create Selected') b.released.connect(self.create_selected) hbox.addWidget(b) b = QtWidgets.QPushButton('Remove Selected') b.released.connect(self.remove_selected) hbox.addWidget(b) hbox = QtWidgets.QHBoxLayout() vbox.addLayout(hbox) self.stack_count = QtWidgets.QSpinBox() self.stack_count.setValue(2) hbox.addWidget(self.stack_count) b = QtWidgets.QPushButton('Create Transform Stack') b.released.connect(self.create_transform_stack) b.setToolTip('Creates a transform stack above each selected node.') hbox.addWidget(b) self.control_list = QtWidgets.QListWidget() self.control_list.setSelectionMode( QtWidgets.QAbstractItemView.ExtendedSelection) vbox.addWidget(self.control_list) self.populate_controls()