def widget(self): """Get the QWidget of the Field.""" widget = QtWidgets.QWidget() hbox = QtWidgets.QHBoxLayout(widget) hbox.setContentsMargins(0, 0, 0, 0) if self._multi: node_widget = QtWidgets.QListWidget() node_widget.addItems(self._value) def on_rows_changed(*args, **kwargs): field = kwargs['field'] node_widget = kwargs['node_widget'] values = [ node_widget.item(x).text() for x in range(node_widget.count()) ] field.set_value(values) model = node_widget.model() model.rowsInserted.connect( partial(on_rows_changed, field=self, node_widget=node_widget)) model.rowsRemoved.connect( partial(on_rows_changed, field=self, node_widget=node_widget)) else: node_widget = QtWidgets.QLineEdit(self._value) node_widget.textChanged.connect(self.set_value) node_widget.setToolTip(self.help_text) hbox.addWidget(node_widget) button = QtWidgets.QPushButton('Set') button.setToolTip('Populate the field with the selected node.') button.released.connect(partial(self.set_from_selected, node_widget)) hbox.addWidget(button) return widget
def create_menu(self): """Creates the menu.""" menubar = self.menuBar() # File Menu menu = menubar.addMenu('File') action = QtWidgets.QAction('New', self) action.triggered.connect(self.new_queue) message = 'Create a new component queue.' action.setToolTip(message) action.setStatusTip(message) menu.addAction(action) action = QtWidgets.QAction('Load Queue', self) action.triggered.connect(self.load_queue) message = 'Load a queue from disk.' action.setToolTip(message) action.setStatusTip(message) menu.addAction(action) action = QtWidgets.QAction('Save Queue', self) action.triggered.connect(self.save_queue) message = 'Save the current queue to disk.' action.setToolTip(message) action.setStatusTip(message) menu.addAction(action) self.recent_menu = QtWidgets.QMenu('Recent Queues', menu) menu.addMenu(self.recent_menu) self.populate_recent_queue_menu()
def add_element(self, field=None, field_layout=None): """Adds a new field to the Array. :param field: Optional field to add. If omitted, a copy of the last element will be added. """ if field is None: if not self.fields: raise RuntimeError('No default field set in the ArrayField.') field = copy.deepcopy(self.fields[-1]) self.fields.append(field) if field_layout: element_widget = QtWidgets.QWidget() field_layout.insertWidget(field_layout.count() - 1, element_widget) hbox = QtWidgets.QHBoxLayout(element_widget) hbox.setContentsMargins(0, 0, 0, 0) field_widget = field.widget() hbox.addWidget(field_widget) action = QtWidgets.QAction('Remove', field_layout) action.triggered.connect( partial(self.remove_element, field_layout, element_widget)) icon = QtGui.QIcon(QtGui.QPixmap(':/smallTrash.png')) action.setIcon(icon) action.setToolTip('Remove') action.setStatusTip('Remove') delete_button = QtWidgets.QToolButton() delete_button.setDefaultAction(action) hbox.addWidget(delete_button)
def __init__(self, *args, **kwargs): super(MayaTestRunnerDialog, self).__init__(*args, **kwargs) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setWindowTitle('CMT Unit Test Runner') self.resize(1000, 600) self.rollback_importer = RollbackImporter() menubar = self.menuBar() menu = menubar.addMenu('Settings') action = menu.addAction('Buffer Output') action.setToolTip('Only display output during a failed test.') action.setCheckable(True) action.setChecked(mayaunittest.Settings.buffer_output) action.toggled.connect(mayaunittest.set_buffer_output) action = menu.addAction('New Scene Between Test') action.setToolTip('Creates a new scene file after each test.') action.setCheckable(True) action.setChecked(mayaunittest.Settings.file_new) action.toggled.connect(mayaunittest.set_file_new) menu = menubar.addMenu('Help') action = menu.addAction('Documentation') action.triggered.connect(documentation) toolbar = self.addToolBar('Tools') action = toolbar.addAction('Run All Tests') action.setIcon(QtGui.QIcon(QtGui.QPixmap(os.path.join(ICON_DIR, 'cmt_run_all_tests.png')))) action.triggered.connect(self.run_all_tests) action.setToolTip('Run all tests.') action = toolbar.addAction('Run Selected Tests') action.setIcon(QtGui.QIcon(QtGui.QPixmap(os.path.join(ICON_DIR, 'cmt_run_selected_tests.png')))) action.setToolTip('Run all selected tests.') action.triggered.connect(self.run_selected_tests) action = toolbar.addAction('Run Failed Tests') action.setIcon(QtGui.QIcon(QtGui.QPixmap(os.path.join(ICON_DIR, 'cmt_run_failed_tests.png')))) action.setToolTip('Run all failed tests.') action.triggered.connect(self.run_failed_tests) widget = QtWidgets.QWidget() self.setCentralWidget(widget) vbox = QtWidgets.QVBoxLayout(widget) splitter = QtWidgets.QSplitter(orientation=QtCore.Qt.Horizontal) self.test_view = QtWidgets.QTreeView() self.test_view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) splitter.addWidget(self.test_view) self.output_console = QtWidgets.QTextEdit() self.output_console.setReadOnly(True) splitter.addWidget(self.output_console) vbox.addWidget(splitter) splitter.setStretchFactor(1, 4) self.stream = TestCaptureStream(self.output_console) test_suite = mayaunittest.get_tests() root_node = TestNode(test_suite) self.model = TestTreeModel(root_node, self) self.test_view.setModel(self.model) self.expand_tree(root_node)
def widget(self, container): """Get a widget containing all the fields of the given container. :param container: ContainerField instance. """ widget = QtWidgets.QFrame() widget.setFrameStyle(QtGui.QFrame.StyledPanel) layout = QtWidgets.QFormLayout(widget) for field in container.fields: layout.addRow(field.name, field.widget()) return widget
def on_component_execution_error(self, message, component): widget = self.get_component_widget(component) if widget: widget.set_color(ComponentWidget.error_color) msg = QtWidgets.QMessageBox(self) msg.setWindowTitle('Execution Error') msg.setText('Component {0} failed to execute.'.format(component.name())) msg.setDetailedText(message) msg.setIcon(QtWidgets.QMessageBox.Critical) # Need to use spacer to set the message box width since setFixedWidth does not work. spacer = QtWidgets.QSpacerItem(500, 0, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) layout = msg.layout() layout.addItem(spacer, layout.rowCount(), 0, 1, layout.columnCount()) msg.show()
def widget(self): """Get a the QWidget displaying the Component data. Users can override this method if they wish to customize the layout of the component. :return: A QWidget containing all the Component fields. """ widget = QtWidgets.QWidget() layout = QtWidgets.QFormLayout(widget) for field in self.fields: if field.display_name: layout.addRow(field.verbose_name, field.widget()) else: layout.addWidget(field.widget()) return widget
def populate_recent_queue_menu(self): """Populates the recent queue menu.""" self.recent_menu.clear() for queue in get_recent_queues(): action = QtWidgets.QAction(queue, self) action.triggered.connect(partial(self.load_queue, queue)) self.recent_menu.addAction(action)
def widget(self): """Get the QWidget of the Field.""" widget = QtWidgets.QCheckBox(self.verbose_name) widget.setChecked(self._value) widget.setToolTip(self.help_text) widget.toggled.connect(self.set_value) return widget
def __init__(self, queue=None, parent=None): super(QueueWidget, self).__init__(parent) self.setAcceptDrops(True) self.queue_layout = QtWidgets.QVBoxLayout(self) self.queue_layout.addStretch() self.queue = queue if queue else core.ComponentQueue() self.drop_indicator = DropIndicator() self.hide_indicator()
def widget(self, container): widget = QtWidgets.QFrame() widget.setFrameStyle(QtWidgets.QFrame.NoFrame) layout = QtWidgets.QHBoxLayout(widget) layout.addWidget(container['operation'].widget()) file_path_widget = container['file_path'].widget() file_path_widget.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) layout.addWidget(file_path_widget) layout.addWidget(QtWidgets.QLabel(container['namespace'].verbose_name)) namespace_widget = container['namespace'].widget() namespace_widget.setMaximumWidth(150) namespace_widget.setSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Fixed) layout.addWidget(namespace_widget) return widget
def widget(self): widget = self.constraints.widget() # Add a new button to the widget button_layout to add selected constraints to the UI. button = QtWidgets.QPushButton('Add from Selected') button.released.connect( partial(self.add_from_selected, field_layout=widget.field_layout)) widget.button_layout.addWidget(button) return widget
def widget(self): """Get the QWidget of the Field.""" widget = QtWidgets.QDoubleSpinBox() widget.setRange(self.min_value, self.max_value) widget.setValue(self._value) widget.setDecimals(self.precision) widget.setSingleStep(self.single_step) widget.setToolTip(self.help_text) widget.valueChanged.connect(self.set_value) return widget
def widget(self): """Get the QWidget of the Field.""" widget = QtWidgets.QWidget() field_layout = QtWidgets.QVBoxLayout(widget) field_layout.setContentsMargins(0, 0, 0, 0) button_layout = QtWidgets.QHBoxLayout() button_layout.setContentsMargins(0, 0, 0, 0) # Monkey path the button_layout onto the widget in case Components want to add more buttons to it. widget.field_layout = field_layout widget.button_layout = button_layout button = QtWidgets.QPushButton(self.add_label_text) button.released.connect( partial(self.add_element, field_layout=field_layout)) button.setToolTip('Add a new element to list.') button_layout.addWidget(button) for field in self.fields: self.add_element(field, field_layout) field_layout.addLayout(button_layout) return widget
def widget(self, container): # The fields will be arranged in two row containers # [[driver, driven], [name, twist, swing, twistAxis]] widget = QtWidgets.QFrame() widget.setFrameStyle(QtWidgets.QFrame.StyledPanel) vbox = QtWidgets.QVBoxLayout(widget) for attrs in [ ['driver', 'driven'], ['name', 'twist', 'swing', 'twist_axis'], ]: hbox = QtWidgets.QHBoxLayout(widget) vbox.addLayout(hbox) hbox.setContentsMargins(0, 0, 0, 0) for attr in attrs: hbox.addWidget(QtWidgets.QLabel(container[attr].verbose_name)) hbox.addWidget(container[attr].widget()) return widget
def widget(self): """Get a the QWidget displaying the Component data. Users can override this method if they wish to customize the layout of the component. :return: A QWidget containing all the Component fields. """ widget = QtWidgets.QWidget() layout = QtWidgets.QHBoxLayout(widget) layout.setContentsMargins(0, 0, 0, 0) self.list_widget = self.control_list.widget() layout.addWidget(self.list_widget) vbox = QtWidgets.QVBoxLayout() vbox.setContentsMargins(0, 0, 0, 0) layout.addLayout(vbox) button = QtWidgets.QPushButton('Store Controls') button.released.connect(self.store_controls) vbox.addWidget(button) vbox.addStretch() return widget
def widget(self): """Override the widget to add a button to auto-populate fields from selected constraints. :return: The QWidget of the ArrayField. """ widget = self.constraints.widget() # Add a new button to the widget button_layout to add selected constraints to the UI. button = QtWidgets.QPushButton('Add from Selected') button.released.connect( partial(self.add_from_selected, field_layout=widget.layout())) widget.button_layout.addWidget(button) return widget
def widget(self): """Get the QWidget of the Field.""" if self.choices: widget = QtWidgets.QComboBox() widget.setEditable(self.editable) for choice in self.choices: widget.addItem(choice, choice) index = widget.findText(self._value) if index == -1: widget.addItem(self._value, self._value) widget.setCurrentIndex(widget.count() - 1) else: widget.setCurrentIndex(index) widget.currentIndexChanged.connect(self.set_value) else: widget = QtWidgets.QLineEdit(self._value) widget.textChanged.connect(self.set_value) widget.setToolTip(self.help_text) return widget
def set_influences(self, imported_influences, existing_influences): infs = list(existing_influences) infs.sort() self.existing_influences.addItems(infs) width = 200 for inf in imported_influences: row = QtWidgets.QHBoxLayout() self.imported_influence_layout.addLayout(row) label = QtWidgets.QLabel(inf) row.addWidget(label) toggle_btn = QtWidgets.QPushButton('>') toggle_btn.setMaximumWidth(30) row.addWidget(toggle_btn) label = QtWidgets.QLabel('') label.setMaximumWidth(width) label.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) row.addWidget(label) toggle_btn.released.connect( partial(self.set_influence_mapping, src=inf, label=label)) self.imported_influence_layout.addStretch()
def widget(self): """Get the QWidget of the Field.""" widget = QtWidgets.QWidget() hbox = QtWidgets.QHBoxLayout(widget) hbox.setContentsMargins(0, 0, 0, 0) label = QtWidgets.QLabel('Relative to') label.setSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Fixed) hbox.addWidget(label) relative_combobox = QtWidgets.QComboBox() relative_combobox.addItems(FilePathField.relative_to_choices) index = relative_combobox.findText(self.relative_to) if index != -1: relative_combobox.setCurrentIndex(index) relative_combobox.currentIndexChanged.connect(self.set_relative_to) hbox.addWidget(relative_combobox) line_edit = QtWidgets.QLineEdit(self._value) line_edit.setToolTip(self.help_text) line_edit.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) line_edit.textChanged.connect(self.set_value) hbox.addWidget(line_edit) button = QtWidgets.QPushButton('Browse') button.released.connect( partial(self.browse, line_edit, relative_combobox)) hbox.addWidget(button) return widget
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 remove(self, prompt=False): """Remove this Component from the queue. :param prompt: True to display a message box confirming the removal of the Component. """ if prompt: msg_box = QtWidgets.QMessageBox() msg_box.setIcon(QtWidgets.QMessageBox.Question) msg_box.setText('Are you sure you want to remove this component?') msg_box.setStandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.Cancel) if msg_box.exec_() != QtWidgets.QMessageBox.Yes: return index = self.queue.index(self.comp) self.queue.remove(index) self.queue_layout.takeAt(index) self.deleteLater()
def widget(self): """Get the QWidget of the Field.""" widget = QtWidgets.QListWidget() widget.setToolTip(self.help_text) if self._value: widget.addItems(self._value) def on_rows_changed(*args, **kwargs): values = [widget.item(x).text() for x in range(widget.count())] self.set_value(values) model = widget.model( ) # Maya crashes if we chain calls and model isn't saved in a variable model.rowsInserted.connect(on_rows_changed) model.rowsRemoved.connect(on_rows_changed) return widget
def widget(self, container): widget = QtWidgets.QFrame() widget.setFrameStyle(QtWidgets.QFrame.StyledPanel) hbox = QtWidgets.QHBoxLayout(widget) hbox.setContentsMargins(0, 0, 0, 0) label = QtWidgets.QLabel(container['drivers'].verbose_name) hbox.addWidget(label) drivers_widget = container['drivers'].widget() drivers_widget.setMaximumHeight(65) hbox.addWidget(drivers_widget) vbox = QtWidgets.QVBoxLayout() hbox.addLayout(vbox) hbox1 = QtWidgets.QHBoxLayout() vbox.addLayout(hbox1) label = QtWidgets.QLabel(container['driven'].verbose_name) hbox1.addWidget(label) hbox1.addWidget(container['driven'].widget()) hbox1.addWidget(container['maintain_offset'].widget()) hbox2 = QtWidgets.QHBoxLayout() vbox.addLayout(hbox2) hbox2.setContentsMargins(0, 0, 0, 0) hbox2.addWidget(container['skip_tx'].widget()) hbox2.addWidget(container['skip_ty'].widget()) hbox2.addWidget(container['skip_tz'].widget()) hbox2.addStretch() hbox3 = QtWidgets.QHBoxLayout() vbox.addLayout(hbox3) hbox3.setContentsMargins(0, 0, 0, 0) hbox3.addWidget(container['skip_rx'].widget()) hbox3.addWidget(container['skip_ry'].widget()) hbox3.addWidget(container['skip_rz'].widget()) hbox3.addStretch() return widget
def __init__(self, parent=None): super(CQueueWindow, self).__init__(parent) self.setWindowTitle('CQueue') self.setObjectName('CQueueWindow') self.resize(1280, 600) self.recent_menu = None self.create_menu() main_widget = QtWidgets.QWidget(self) main_vbox = QtWidgets.QVBoxLayout(main_widget) self.setCentralWidget(main_widget) splitter = QtWidgets.QSplitter() splitter.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding) main_vbox.addWidget(splitter) # Create the list of available components widget = QtWidgets.QWidget() vbox = QtWidgets.QVBoxLayout(widget) vbox.setContentsMargins(0, 0, 0, 0) self.component_tree = QtWidgets.QTreeView() self.component_tree.setSelectionMode( QtWidgets.QAbstractItemView.ExtendedSelection) self.component_tree.setDragEnabled(True) vbox.addWidget(self.component_tree) splitter.addWidget(widget) widget = QtWidgets.QWidget() splitter.addWidget(widget) vbox = QtWidgets.QVBoxLayout(widget) scroll_area = QtWidgets.QScrollArea() scroll_area.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.queue_widget = QueueWidget(parent=self) self.queue_widget.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) scroll_area.setWidget(self.queue_widget) scroll_area.setWidgetResizable(True) vbox.addWidget(scroll_area) hbox = QtWidgets.QHBoxLayout() vbox.addLayout(hbox) button = QtWidgets.QPushButton('Execute') button.released.connect(self.queue_widget.execute_queue) hbox.addWidget(button) splitter.setSizes([50, 300]) splitter.setStretchFactor(0, 0.5) self.populate_components()
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()
def widget(self, container): widget = QtWidgets.QFrame() widget.setFrameStyle(QtWidgets.QFrame.StyledPanel) main_vbox = QtWidgets.QVBoxLayout(widget) hbox = QtWidgets.QHBoxLayout(widget) main_vbox.addLayout(hbox) hbox.setContentsMargins(0, 0, 0, 0) label = QtWidgets.QLabel(container['drivers'].verbose_name) hbox.addWidget(label) drivers_widget = container['drivers'].widget() drivers_widget.setMaximumHeight(65) hbox.addWidget(drivers_widget) vbox = QtWidgets.QVBoxLayout() hbox.addLayout(vbox) hbox1 = QtWidgets.QHBoxLayout() vbox.addLayout(hbox1) label = QtWidgets.QLabel(container['driven'].verbose_name) hbox1.addWidget(label) hbox1.addWidget(container['driven'].widget()) hbox1.addWidget(container['maintain_offset'].widget()) hbox2 = QtWidgets.QHBoxLayout() vbox.addLayout(hbox2) hbox2.setContentsMargins(0, 0, 0, 0) hbox2.addWidget(container['skip_x'].widget()) hbox2.addWidget(container['skip_y'].widget()) hbox2.addWidget(container['skip_z'].widget()) hbox2.addStretch() hbox = QtWidgets.QHBoxLayout(widget) main_vbox.addLayout(hbox) hbox.setContentsMargins(0, 0, 0, 0) hbox.addWidget(QtWidgets.QLabel(container['aim_vector'].verbose_name)) hbox.addWidget(container['aim_vector'].widget()) hbox.addWidget(QtWidgets.QLabel(container['up_vector'].verbose_name)) hbox.addWidget(container['up_vector'].widget()) hbox = QtWidgets.QHBoxLayout(widget) main_vbox.addLayout(hbox) hbox.setContentsMargins(0, 0, 0, 0) hbox.addWidget( QtWidgets.QLabel(container['world_up_type'].verbose_name)) hbox.addWidget(container['world_up_type'].widget()) hbox.addWidget( QtWidgets.QLabel(container['world_up_object'].verbose_name)) hbox.addWidget(container['world_up_object'].widget()) hbox.addWidget( QtWidgets.QLabel(container['world_up_vector'].verbose_name)) hbox.addWidget(container['world_up_vector'].widget()) return widget
def __init__(self, parent=None): super(WeightRemapDialog, self).__init__(parent) self.setWindowTitle('Remap Weights') self.setObjectName('remapWeightsUI') self.setModal(True) self.resize(600, 400) self.mapping = {} mainvbox = QtWidgets.QVBoxLayout(self) label = QtWidgets.QLabel('The following influences have no corresponding influence from the ' \ 'imported file. You can either remap the influences or skip them.') label.setWordWrap(True) mainvbox.addWidget(label) hbox = QtWidgets.QHBoxLayout() mainvbox.addLayout(hbox) # The existing influences that didn't have weight imported vbox = QtWidgets.QVBoxLayout() hbox.addLayout(vbox) vbox.addWidget(QtWidgets.QLabel('Unmapped influences')) self.existing_influences = QtWidgets.QListWidget() vbox.addWidget(self.existing_influences) vbox = QtWidgets.QVBoxLayout() hbox.addLayout(vbox) vbox.addWidget(QtWidgets.QLabel('Available imported influences')) widget = QtWidgets.QScrollArea() self.imported_influence_layout = QtWidgets.QVBoxLayout(widget) vbox.addWidget(widget) hbox = QtWidgets.QHBoxLayout() mainvbox.addLayout(hbox) hbox.addStretch() btn = QtWidgets.QPushButton('Ok') btn.released.connect(self.accept) hbox.addWidget(btn)
def __init__(self, comp, queue, parent=None): super(ComponentWidget, self).__init__(parent) self.setMouseTracking(True) self.queue_layout = parent.queue_layout self.queue = queue self.comp = comp vbox = QtWidgets.QVBoxLayout(self) self.setFrameStyle(QtWidgets.QFrame.StyledPanel) self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Maximum) self.over_grab_hotspot = False self.color = ComponentWidget.normal_color # Header hbox = QtWidgets.QHBoxLayout() self.header_layout = hbox hbox.setContentsMargins(16, 4, 4, 4) vbox.addLayout(hbox) # Expand toggle expand_action = QtWidgets.QAction('Toggle', self) expand_action.setCheckable(True) icon = QtGui.QIcon(QtGui.QPixmap(':/arrowDown.png')) expand_action.setIcon(icon) expand_action.setToolTip('Toggle details') expand_action.setStatusTip('Toggle details') button = QtWidgets.QToolButton() button.setDefaultAction(expand_action) hbox.addWidget(button) # Enable checkbox enabled = QtWidgets.QCheckBox() enabled.setToolTip('Enable/Disable Component') hbox.addWidget(enabled) # Breakpoint self.break_point_action = QtWidgets.QAction('Breakpoint', self) self.break_point_action.setCheckable(True) self.break_point_action.setIcon(self.break_point_disabled_icon) self.break_point_action.setToolTip('Set break point at component.') self.break_point_action.setStatusTip('Set break point at component.') self.break_point_action.toggled.connect(self.set_break_point) button = QtWidgets.QToolButton() button.setDefaultAction(self.break_point_action) hbox.addWidget(button) # Execute button action = QtWidgets.QAction('Execute', self) icon = QtGui.QIcon(QtGui.QPixmap(':/timeplay.png')) action.setIcon(icon) action.setToolTip('Execute the component') action.setStatusTip('Execute the component') action.triggered.connect( partial(self.execute_component, on_error=parent.on_component_execution_error)) button = QtWidgets.QToolButton() button.setDefaultAction(action) hbox.addWidget(button) # Image label label = QtWidgets.QLabel() label.setPixmap(comp.image(size=24)) label.setToolTip(comp.__class__.__doc__) hbox.addWidget(label) # Name label label = QtWidgets.QLabel(comp.name().split('.')[-1]) label.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) label.setToolTip(comp.__class__.__doc__) font = QtGui.QFont() font.setPointSize(14) label.setFont(font) hbox.addWidget(label) hbox.addStretch() if comp.help_url(): action = QtWidgets.QAction('Help', self) icon = QtGui.QIcon(QtGui.QPixmap(':/help.png')) action.setIcon(icon) action.setToolTip('Open help documentation.') action.setStatusTip('Open help documentation.') action.triggered.connect(partial(webbrowser.open, comp.help_url())) button = QtWidgets.QToolButton() button.setDefaultAction(action) hbox.addWidget(button) action = QtWidgets.QAction('Delete', self) icon = QtGui.QIcon(QtGui.QPixmap(':/smallTrash.png')) action.setIcon(icon) message = 'Delete Component' action.setToolTip(message) action.setStatusTip(message) action.triggered.connect(partial(self.remove, prompt=True)) button = QtWidgets.QToolButton() button.setDefaultAction(action) hbox.addWidget(button) content_vbox = QtWidgets.QVBoxLayout() content_vbox.setContentsMargins(16, 0, 0, 0) vbox.addLayout(content_vbox) content_widget = comp.widget() content_vbox.addWidget(content_widget) enabled.toggled.connect(content_widget.setEnabled) enabled.setChecked(comp.enabled) enabled.toggled.connect(comp.set_enabled) expand_action.toggled.connect(content_widget.setVisible) content_widget.setVisible(False)