def ui(self): super(SkinningWidget, self).ui() self._average_falloff_widget = QWidget() average_falloff_layout = layouts.VerticalLayout(spacing=2, margins=(5, 5, 5, 5)) self._average_falloff_widget.setLayout(average_falloff_layout) self._average_falloff_curve = fallofcurve.FallofCurveWidget( parent=self) average_falloff_layout.addWidget(self._average_falloff_curve) self._mirror_auto_assign_joints_labels_cbx = checkbox.BaseCheckBox( 'Auto Assign Labels', self) self._copy_skin_weights_auto_assign_joints_labels_cbx = checkbox.BaseCheckBox( 'Auto Assign Labels', self) self._transfer_skin_uvs_auto_assign_joints_labels_cbx = checkbox.BaseCheckBox( 'Auto Assign Labels', self) self._clean_skin_mesh_auto_assign_joints_labels_cbx = checkbox.BaseCheckBox( 'Auto Assign Labels', self) self._extract_skin_faces_auto_assign_joints_labels_cbx = checkbox.BaseCheckBox( 'Auto Assign Labels', self) self._distance_widget = QWidget() distance_layout = layouts.VerticalLayout(spacing=2, margins=(5, 5, 5, 5)) self._distance_widget.setLayout(distance_layout) self._distance_average_cbx = checkbox.BaseCheckBox('On Distance', self) self._average_falloff_curve = fallofcurve.FallofCurveWidget( parent=self) distance_layout.addWidget(self._distance_average_cbx) distance_layout.addWidget(self._average_falloff_curve) self._fast_delete_cbx = checkbox.BaseCheckBox('Fast Delete', self) self._average_falloff_widget.setVisible(False) self._mirror_auto_assign_joints_labels_cbx.setVisible(False) self._copy_skin_weights_auto_assign_joints_labels_cbx.setVisible(False) self._transfer_skin_uvs_auto_assign_joints_labels_cbx.setVisible(False) self._clean_skin_mesh_auto_assign_joints_labels_cbx.setVisible(False) self._extract_skin_faces_auto_assign_joints_labels_cbx.setVisible( False) self._distance_widget.setVisible(False) self._fast_delete_cbx.setVisible(False) self.main_layout.addWidget(self._average_falloff_widget) self.main_layout.addWidget(self._mirror_auto_assign_joints_labels_cbx) self.main_layout.addWidget( self._copy_skin_weights_auto_assign_joints_labels_cbx) self.main_layout.addWidget( self._transfer_skin_uvs_auto_assign_joints_labels_cbx) self.main_layout.addWidget( self._clean_skin_mesh_auto_assign_joints_labels_cbx) self.main_layout.addWidget( self._extract_skin_faces_auto_assign_joints_labels_cbx) self.main_layout.addWidget(self._distance_widget) self.main_layout.addWidget(self._fast_delete_cbx)
def add_ligand(tool): rows = tool.ligand_table.rowCount() if rows != 0: rows -= 1 ligand_name = QTableWidgetItem() name = "<click to choose>" is_c2 = Qt.Unchecked enabled = True if rows > 0: name = tool.ligand_table.item(rows - 1, 0).text() is_c2 = tool.ligand_table.cellWidget(rows - 1, 1).layout().itemAt(0).widget().checkState() enabled = tool.ligand_table.cellWidget(rows - 1, 1).layout().itemAt(0).widget().isEnabled() ligand_name.setData(Qt.DisplayRole, name) tool.ligand_table.setItem(rows, 0, ligand_name) widget_that_lets_me_horizontally_align_a_checkbox = QWidget() widget_layout = QHBoxLayout(widget_that_lets_me_horizontally_align_a_checkbox) c2 = QCheckBox() c2.setEnabled(enabled) c2.setCheckState(is_c2) widget_layout.addWidget(c2, 0, Qt.AlignHCenter) widget_layout.setContentsMargins(0, 0, 0, 0) tool.ligand_table.setCellWidget( rows, 1, widget_that_lets_me_horizontally_align_a_checkbox ) widget_that_lets_me_horizontally_align_an_icon = QWidget() widget_layout = QHBoxLayout(widget_that_lets_me_horizontally_align_an_icon) section_remove = QLabel() dim = int(1.5 * section_remove.fontMetrics().boundingRect("Q").height()) section_remove.setPixmap( QIcon(section_remove.style().standardIcon( QStyle.SP_DialogDiscardButton) ).pixmap(dim, dim) ) widget_layout.addWidget(section_remove, 0, Qt.AlignHCenter) widget_layout.setContentsMargins(0, 0, 0, 0) tool.ligand_table.setCellWidget( rows, 2, widget_that_lets_me_horizontally_align_an_icon ) rows += 1 tool.ligand_table.insertRow(rows) widget_that_lets_me_horizontally_align_an_icon = QWidget() widget_layout = QHBoxLayout(widget_that_lets_me_horizontally_align_an_icon) ligand_add = QLabel("add ligand") widget_layout.addWidget(ligand_add, 0, Qt.AlignHCenter) widget_layout.setContentsMargins(0, 0, 0, 0) tool.ligand_table.setCellWidget(rows, 1, widget_that_lets_me_horizontally_align_an_icon)
def add_files(self, filenames): """add filenames (list(str)) to the table""" for f in filenames: row = self.table.rowCount() self.table.insertRow(row) file_item = QTableWidgetItem() file_item.setData(Qt.DisplayRole, f) self.table.setItem(row, 0, file_item) widget_that_lets_me_horizontally_align_an_icon = QWidget() widget_layout = QHBoxLayout( widget_that_lets_me_horizontally_align_an_icon) section_remove = QLabel() dim = int(1.5 * section_remove.fontMetrics().boundingRect("Z").height()) section_remove.setPixmap( QIcon(section_remove.style().standardIcon( QStyle.SP_DialogDiscardButton)).pixmap(dim, dim)) widget_layout.addWidget(section_remove, 0, Qt.AlignHCenter) widget_layout.setContentsMargins(0, 0, 0, 0) self.table.setCellWidget( row, 1, widget_that_lets_me_horizontally_align_an_icon) self.add_last_row()
def ui(self): """ Function that sets up the ui of the widget Override it on new widgets (but always call super) """ self.main_layout = self.get_main_layout() if self._use_scrollbar: layout = layouts.VerticalLayout(spacing=0, margins=(0, 0, 0, 0)) self.setLayout(layout) central_widget = QWidget() central_widget.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) scroll = QScrollArea() scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) scroll.setWidgetResizable(True) scroll.setFocusPolicy(Qt.NoFocus) layout.addWidget(scroll) scroll.setWidget(central_widget) central_widget.setLayout(self.main_layout) self.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) else: self.setLayout(self.main_layout)
def ui(self): super(InterpolateItView, self).ui() central_layout = layouts.VerticalLayout(spacing=0, margins=(0, 0, 0, 0)) central_widget = QWidget() central_widget.setLayout(central_layout) central_widget.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) scroll = QScrollArea() scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) scroll.setWidgetResizable(True) scroll.setFocusPolicy(Qt.NoFocus) self.main_layout.addWidget(scroll) scroll.setWidget(central_widget) self._interpolator_layout = layouts.VerticalLayout(spacing=0, margins=(0, 0, 0, 0)) self._interpolator_layout.setAlignment(Qt.AlignTop) button_layout = layouts.HorizontalLayout(spacing=2, margins=(0, 0, 0, 0)) self._load_btn = buttons.BaseButton('Load', parent=self) self._save_btn = buttons.BaseButton('Save', parent=self) self._add_btn = buttons.BaseButton('New', parent=self) button_layout.addWidget(self._save_btn) button_layout.addWidget(self._load_btn) button_layout.addStretch() button_layout.addWidget(self._add_btn) central_layout.addLayout(self._interpolator_layout) self.main_layout.addLayout(button_layout)
def _toolbar_example(self): def _collapse(): tool_bar.collapse() def _set_icon_color(): tool_bar.set_icon_color(QColor(255, 255, 0)) toolbar_widget = QWidget(parent=self) toolbar_layout = layouts.VerticalLayout() toolbar_widget.setLayout(toolbar_layout) tool_bar = toolbar.ToolBar(parent=self) tool_bar.set_children_height(50) toolbar_layout.addWidget(tool_bar) line_edit = lineedit.BaseLineEdit(parent=self) line_edit.setObjectName('hello') collapse_action = tool_bar.addAction('Collapse') tool_bar.addWidget(line_edit) tool_bar.addAction(resources.icon('add'), 'Plus') color_action = QAction('Yellow', None) tool_bar.insertAction('Plus', color_action) collapse_action.triggered.connect(_collapse) color_action.triggered.connect(_set_icon_color) self.main_layout.addWidget(buttons.BaseButton('Hello')) self.main_layout.addStretch() return toolbar_widget
def initPenSizeButtons(self): self.penSize = QWidget(self) self.penSizeLayout = QHBoxLayout() self.penSize.setLayout(self.penSizeLayout) # adjust pen size self.penSize1 = QPushButton(self.penSize) self.penSize1.setIcon(QIcon(":/resource/icon/pensize1.png")) self.penSize1.setObjectName('1') self.penSize1.setFixedSize(self.iconWidth, self.iconHeight) self.penSize1.setCheckable(True) self.penSize2 = QPushButton(self.penSize) self.penSize2.setIcon(QIcon(":/resource/icon/pensize2.png")) self.penSize2.setObjectName('2') self.penSize2.setFixedSize(self.iconWidth, self.iconHeight) self.penSize2.setCheckable(True) self.penSize3 = QPushButton(self.penSize) self.penSize3.setIcon(QIcon(":/resource/icon/pensize3.png")) self.penSize3.setObjectName('3') self.penSize3.setFixedSize(self.iconWidth, self.iconHeight) self.penSize3.setCheckable(True) self.sizeButtonGroup = QButtonGroup(self.penSize) self.sizeButtonGroup.addButton(self.penSize1) self.sizeButtonGroup.addButton(self.penSize2) self.sizeButtonGroup.addButton(self.penSize3) self.sizeButtonGroup.buttonClicked.connect(self.sizeButtonToggled) self.penSizeLayout.addWidget(self.penSize1) self.penSizeLayout.addWidget(self.penSize2) self.penSizeLayout.addWidget(self.penSize3) self.penSizeLayout.setSpacing(5) self.penSizeLayout.setContentsMargins(0, 0, 0, 0)
def __init__(self, url: QUrl) -> None: super().__init__() self.setupUi(self) self.m_cookies = [] self.m_urlLineEdit.setText(url.toString()) self.m_layout = QVBoxLayout() self.m_layout.addItem( QSpacerItem(0, 0, QSizePolicy.Minimum, QSizePolicy.Expanding)) self.m_layout.setContentsMargins(0, 0, 0, 0) self.m_layout.setSpacing(0) w = QWidget() p = w.palette() p.setColor(self.widget.backgroundRole(), Qt.white) w.setPalette(p) w.setLayout(self.m_layout) self.m_scrollArea.setWidget(w) self.m_scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.m_scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.m_urlButton.clicked.connect(self.handleUrlClicked) self.m_deleteAllButton.clicked.connect(self.handleDeleteAllClicked) self.m_newButton.clicked.connect(self.handleNewClicked) self.m_store: QWebEngineCookieStore = self.m_webview.page().profile( ).cookieStore() self.m_store.cookieAdded.connect(self.handleCookieAdded) self.m_store.loadAllCookies() self.m_webview.load(url)
def ui(self): super(RenamerView, self).ui() renamer_widget = QWidget() renamer_widget.setLayout( layouts.VerticalLayout(spacing=0, margins=(0, 0, 0, 0))) renamer_widget.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) self.main_layout.addWidget(renamer_widget) rename_layout = layouts.HorizontalLayout(spacing=2, margins=(0, 0, 0, 0)) rename_layout.setAlignment(Qt.AlignLeft) renamer_widget.layout().addLayout(rename_layout) self._base_name_cbx = checkbox.BaseCheckBox(parent=self) rename_layout.addWidget(self._base_name_cbx) self._renamer_line = lineedit.BaseLineEdit(parent=self) self._renamer_line.setPlaceholderText('New Name') rename_layout.addWidget(self._renamer_line) reg_ex = QRegExp("^(?!^_)[a-zA-Z_]+") text_validator = QRegExpValidator(reg_ex, self._renamer_line) self._renamer_line.setValidator(text_validator) self._renamer_btn = buttons.BaseButton(parent=self) self._renamer_btn.setIcon(resources.icon('rename')) rename_layout.addWidget(self._renamer_btn)
def main(): import sys app = QApplication(sys.argv) layout = QVBoxLayout() infos = QSerialPortInfo.availablePorts() for info in infos: s = ( f"Port: {info.portName()}", f"Location: {info.systemLocation()}", f"Description: {info.description()}", f"Manufacturer: {info.manufacturer()}", f"Serial number: {info.serialNumber()}", "Vendor Identifier: " + f"{info.vendorIdentifier():x}" if info.hasVendorIdentifier() else "", "Product Identifier: " + f"{info.productIdentifier():x}" if info.hasProductIdentifier() else "", ) label = QLabel("\n".join(s)) layout.addWidget(label) workPage = QWidget() workPage.setLayout(layout) area = QScrollArea() area.setWindowTitle("Info about all available serial ports.") area.setWidget(workPage) area.show() sys.exit(app.exec_())
def initPenColorButtons(self): self.colorSet = QWidget(self) self.colorLayout = QHBoxLayout() self.colorLayout.setSpacing(5) self.colorLayout.setContentsMargins(5, 0, 5, 0) self.colorSet.setLayout(self.colorLayout) self.presentColor = QPushButton(self.colorSet) self.presentColor.setFixedSize(self.iconWidth, self.iconHeight) self.presentColor.setEnabled(False) # adjust pen color self.colorPick = QWidget(self.colorSet) self.colorGrid = QGridLayout() self.colorGrid.setSpacing(0) self.colorGrid.setContentsMargins(5, 0, 5, 0) self.colorPick.setLayout(self.colorGrid) self.colorList = [('white', '#ffffff'), ('red', '#ff0000'), ('green', '#00ff00'), ('blue', '#0000ff'), ('cyan', '#00ffff'), ('magenta', '#ff00ff'), ('yellow', '#ffff00'), ('gray', '#a0a0a4'), ('black', '#000000'), ('darkRed', '#800000'), ('darkGreen', '#008000'), ('darkBlue', '#000080'), ('darkCyan', '#008080'), ('darkMagenta', '#800080'), ('darkYellow', '#808000'), ('darkGray', '#808080')] self.generateButtons() self.colorButtonGroup = QButtonGroup(self) for button in self.colorButtons: self.colorButtonGroup.addButton(button) self.colorButtonGroup.buttonClicked.connect(self.colorButtonToggled) # set the layout tmp = 0 for x in range(0, 2): for y in range(0, int(len(self.colorList) / 2)): self.colorGrid.addWidget(self.colorButtons[tmp], x, y) tmp += 1 self.colorGrid.setSpacing(0) self.colorGrid.setContentsMargins(0, 0, 0, 0) self.colorLayout.addWidget(self.presentColor) self.colorLayout.addWidget(self.colorPick)
def ui(self): super(Changelog, self).ui() self.set_logo('changelog_logo') self.main_layout.setAlignment(Qt.AlignTop) self.main_layout.setContentsMargins(0, 0, 0, 0) self.setFixedWidth(600) self.setMaximumHeight(800) scroll_layout = layouts.VerticalLayout(spacing=2, margins=(2, 2, 2, 2)) scroll_layout.setAlignment(Qt.AlignTop) central_widget = QWidget() central_widget.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) scroll = QScrollArea() scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded) scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) scroll.setWidgetResizable(True) scroll.setFocusPolicy(Qt.NoFocus) ok_btn = QPushButton('OK') ok_btn.clicked.connect(self.close) self.main_layout.addWidget(scroll) self.main_layout.setAlignment(Qt.AlignTop) self.main_layout.addWidget(ok_btn) scroll.setWidget(central_widget) central_widget.setLayout(scroll_layout) self.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self.main_layout = scroll_layout # =========================================================================================== self.version_accordion = accordion.AccordionWidget(parent=self) self.version_accordion.rollout_style = accordion.AccordionStyle.MAYA self.main_layout.addWidget(self.version_accordion) # =========================================================================================== changelog_json_file = os.path.join( os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'changelog.json') if not os.path.isfile(changelog_json_file): return with open(changelog_json_file, 'r') as f: changelog_data = json.load(f, object_pairs_hook=OrderedDict) if not changelog_data: return changelog_data = OrderedDict( sorted(changelog_data.items(), reverse=True)) for version, elements in changelog_data.items(): self._create_version(version, elements) last_version_item = self.version_accordion.item_at(0) last_version_item.set_collapsed(False)
def ui(self): super(AutoRenameWidget, self).ui() top_layout = layouts.HorizontalLayout(spacing=2, margins=(0, 0, 0, 0)) self._unique_id_cbx = checkbox.BaseCheckBox('Unique Id') self._last_joint_end_cbx = checkbox.BaseCheckBox('Make Last Joint End') top_layout.addStretch() top_layout.addWidget(self._unique_id_cbx) top_layout.addWidget(self._last_joint_end_cbx) self.main_layout.addLayout(top_layout) main_splitter = QSplitter(Qt.Horizontal) main_splitter.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding) self.main_layout.addWidget(main_splitter) auto_widget = QWidget() auto_layout = layouts.VerticalLayout(spacing=0, margins=(0, 0, 0, 0)) auto_widget.setLayout(auto_layout) main_splitter.addWidget(auto_widget) self._rules_list = QTreeWidget(self) self._rules_list.setHeaderHidden(True) self._rules_list.setSortingEnabled(True) self._rules_list.setRootIsDecorated(False) self._rules_list.setSelectionMode(QAbstractItemView.SingleSelection) self._rules_list.sortByColumn(0, Qt.AscendingOrder) self._rules_list.setUniformRowHeights(True) self._rules_list.setAlternatingRowColors(True) auto_layout.addWidget(self._rules_list) auto_w = QWidget() self.auto_l = layouts.VerticalLayout(spacing=0, margins=(0, 0, 0, 0)) auto_w.setLayout(self.auto_l) auto_w.setMinimumWidth(200) main_splitter.addWidget(auto_w) self.main_auto_layout = QFormLayout() self.auto_l.addLayout(self.main_auto_layout) self._rename_btn = buttons.BaseButton('Rename') self._rename_btn.setIcon(resources.icon('rename')) self.main_layout.addLayout(dividers.DividerLayout()) self.main_layout.addWidget(self._rename_btn)
def __init__(self): super(ScriptsEditorPlugin, self).__init__() self._script_editor_widget = None self._content = QWidget() self._content_layout = layouts.VerticalLayout(spacing=0, margins=(0, 0, 0, 0)) self._content.setLayout(self._content_layout) self.setWidget(self._content)
def __init__(self): super(RenamerPlugin, self).__init__() self._renamer_widget = None self._content = QWidget() self._content_layout = layouts.VerticalLayout(spacing=0, margins=(0, 0, 0, 0)) self._content.setLayout(self._content_layout) self.setWidget(self._content)
def __init__(self): super(VariablesTool, self).__init__() self.setMinimumSize(QtCore.QSize(200, 50)) self.content = QWidget() self.content.setObjectName("VariablesToolContent") self.verticalLayout = QVBoxLayout(self.content) self.verticalLayout.setSpacing(0) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setObjectName("verticalLayout") self.setWidget(self.content)
def _add_category(self, category_name): if not self._controller: return False commands_to_add = list() for command_name, command_data in self._commands_data.items(): command_function = self._controller_functions_mapping.get( command_name, None) if not command_data or command_name not in self._controller_functions_mapping: continue command_categories = command_data.get('categories', list()) if category_name not in command_categories: continue options = list() command_actions = command_data.get('options', dict()) for command_option_name, command_option_data in command_actions.items( ): command_option_function = self._controller_functions_mapping.get( command_option_name, None) if not command_option_function: continue option_data = command_option_data.copy() option_data['fn'] = command_option_function options.append(option_data) new_command_data = command_data.copy() new_command_data.pop( 'categories') # categories is not part of the command creation new_command_data.pop('options', None) new_command = self._create_button(fn=command_function, settings=options, **new_command_data) is_available = self._check_command_availability(command_name) if not is_available: new_command.setToolTip( 'Command "{}" is not available!'.format(command_name)) new_command.setEnabled(False) commands_to_add.append(new_command) if not commands_to_add: return False category_widget = QWidget() category_layout = layouts.FlowLayout() category_layout.setAlignment(Qt.AlignLeft) category_widget.setLayout(category_layout) for command in commands_to_add: category_layout.addWidget(command) return category_widget
def add_spacing(self, spacing): """ Adds new spacing into the widget :param spacing: int """ # TODO: Check if we should use spacer items instead of standard widgets space_widget = QWidget() space_widget.setFixedSize(QSize(spacing, spacing)) self.addWidget(space_widget)
def ui(self): super(CollapsableGroup, self).ui() self._base_widget = QWidget() if self._layout_orientation == Qt.Vertical: manager_layout = layouts.VerticalLayout(spacing=2, margins=(4, 4, 4, 4)) else: manager_layout = layouts.HorizontalLayout(spacing=2, margins=(4, 4, 4, 4)) manager_layout.setAlignment(Qt.AlignCenter) self._base_widget.setLayout(manager_layout) self.main_layout.addWidget(self._base_widget) self.main_layout = manager_layout
def __init__(self): super(HistoryTool, self).__init__() self.setMinimumSize(QtCore.QSize(200, 50)) self.content = QWidget() self.content.setObjectName("historyToolContent") self.verticalLayout = QVBoxLayout(self.content) self.verticalLayout.setSpacing(0) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setObjectName("verticalLayout") self.undoStackView = QUndoView(self) self.undoStackView.setObjectName("undoStackView") self.verticalLayout.addWidget(self.undoStackView) self.setWidget(self.content)
def __init__(self, *args): super(ImageSequenceWidget, self).__init__(*args) self.setMouseTracking(True) self._image_sequence = image.ImageSequence('') self._image_sequence.frameChanged.connect(self._on_frame_changed) self._toolbar = QToolBar(self) animation.fade_out_widget(self._toolbar, duration=0) spacer = QWidget() spacer.setMaximumWidth(4) spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) self._toolbar.addWidget(spacer) spacer1 = QWidget() spacer1.setMaximumWidth(4) spacer1.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) self._first_spacer = self._toolbar.addWidget(spacer1) self.set_size(150, 150)
def get_horizontal_separator(): v_div_w = QWidget() v_div_l = QVBoxLayout() v_div_l.setAlignment(Qt.AlignLeft) v_div_l.setContentsMargins(0, 0, 0, 0) v_div_l.setSpacing(0) v_div_w.setLayout(v_div_l) v_div = QFrame() v_div.setMinimumHeight(30) v_div.setFrameShape(QFrame.VLine) v_div.setFrameShadow(QFrame.Sunken) v_div_l.addWidget(v_div) return v_div_w
def ui(self): super(ExpandablePanel, self).ui() widget_palette = QPalette() widget_palette.setColor(QPalette.Background, QColor.fromRgb(60, 60, 60)) self.setAutoFillBackground(True) self.setPalette(widget_palette) frame = QFrame() frame.setFrameShape(QFrame.StyledPanel) frame.setFrameShadow(QFrame.Sunken) self.main_layout.addWidget(frame) main_layout = layouts.VerticalLayout(spacing=0, margins=(2, 2, 2, 2), parent=frame) main_layout.setAlignment(Qt.AlignTop) self._header_area = QWidget() self._header_area.setMinimumHeight(20) self._widget_area = QWidget() self._widget_area.setAutoFillBackground(True) self._widget_area.setPalette(widget_palette) self._header_text_label = dividers.Divider(self._header_text) self._widget_layout = layouts.VerticalLayout(spacing=5) self._widget_layout.setMargin(5) self._widget_area.setLayout(self._widget_layout) header_layout = layouts.HorizontalLayout(margins=(0, 0, 0, 0)) header_layout.addWidget(self._icon) header_layout.addWidget(self._header_text_label) self._header_area.setLayout(header_layout) main_layout.addWidget(self._header_area) main_layout.addWidget(self._widget_area) self._icon.clicked.connect(self.change_state)
def ui(self): super(OptionsViewer, self).ui() edit_mode_icon = resources.icon('edit') move_up_icon = resources.icon('sort_up') move_down_icon = resources.icon('sort_down') remove_icon = resources.icon('delete') self._edit_widget = QWidget() top_layout = layouts.HorizontalLayout() top_layout.setContentsMargins(0, 0, 0, 0) top_layout.setSpacing(2) self._edit_widget.setLayout(top_layout) self.main_layout.addWidget(self._edit_widget) self._edit_mode_btn = buttons.BaseButton(parent=self) self._edit_mode_btn.setIcon(edit_mode_icon) self._edit_mode_btn.setCheckable(True) top_layout.addWidget(self._edit_mode_btn) horizontal_separator = QFrame() horizontal_separator.setFrameShape(QFrame.VLine) horizontal_separator.setFrameShadow(QFrame.Sunken) top_layout.addWidget(horizontal_separator) self._move_up_btn = buttons.BaseButton(parent=self) self.move_down_btn = buttons.BaseButton(parent=self) self.remove_btn = buttons.BaseButton(parent=self) self._move_up_btn.setIcon(move_up_icon) self.move_down_btn.setIcon(move_down_icon) self.remove_btn.setIcon(remove_icon) self._move_up_btn.setVisible(False) self.move_down_btn.setVisible(False) self.remove_btn.setVisible(False) top_layout.addWidget(self._move_up_btn) top_layout.addWidget(self.move_down_btn) top_layout.addWidget(self.remove_btn) top_layout.addStretch() self.main_layout.addWidget(dividers.Divider()) self._scroll = QScrollArea() self._scroll.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self._scroll.setFocusPolicy(Qt.NoFocus) self._scroll.setWidgetResizable(True) self.setFocusPolicy(Qt.NoFocus) self._options_list = self.OPTION_LIST_CLASS(parent=self) self._scroll.setWidget(self._options_list) self.main_layout.addWidget(self._scroll)
def ui(self): super(MenuTabWidget, self).ui() self.tool_btn_grp = MenuTabBlockButtonGroup() bar_widget = QWidget() bar_widget.setObjectName('bar_widget') self._bar_layout = layouts.HorizontalLayout(margins=(10, 0, 10, 0)) bar_widget.setLayout(self._bar_layout) self._bar_layout.addWidget(self.tool_btn_grp) self._bar_layout.addStretch() self.main_layout.addWidget(bar_widget) self.main_layout.addWidget(dividers.Divider()) self.main_layout.addSpacing(5)
def set_data(self, x, y, z, min_alt, max_alt, vbur, radius, include_vbur): fig, ax = plt.subplots() steric_map = ax.contourf(x, y, z, extend="min", cmap=copy.copy(plt.cm.get_cmap("jet")), levels=np.linspace(min_alt, max_alt, num=21)) steric_map.cmap.set_under('w') ax.contour(x, y, z, extend="min", colors='k', levels=np.linspace(min_alt, max_alt, num=21)) bar = fig.colorbar(steric_map, format="%.1f") bar.set_label("altitude (Å)") ax.set_aspect("equal") if include_vbur: ax.hlines(0, -radius, radius, color='k') ax.vlines(0, -radius, radius, color='k') vbur_1 = vbur[0] + vbur[7] vbur_2 = vbur[1] + vbur[6] vbur_3 = vbur[2] + vbur[5] vbur_4 = vbur[3] + vbur[4] ax.text(+0.7 * radius, +0.9 * radius, "%.1f%%" % vbur_1) ax.text(-0.9 * radius, +0.9 * radius, "%.1f%%" % vbur_2) ax.text(-0.9 * radius, -0.9 * radius, "%.1f%%" % vbur_3) ax.text(+0.7 * radius, -0.9 * radius, "%.1f%%" % vbur_4) if include_vbur: circle = plt.Circle((0, 0), radius, color="k", fill=False, linewidth=4) ax.add_artist(circle) canvas = Canvas(fig) self.layout.addWidget(canvas) toolbar_widget = QWidget() toolbar = NavigationToolbar(canvas, toolbar_widget) toolbar.setMaximumHeight(32) self.layout.addWidget(toolbar)
def __init__(self, project_name): self.project_name = project_name self._app = QApplication.instance() self._css_filepath = None self.main_window = QWidget() self.main_window.setWindowFlags(Qt.Tool) self.main_window.setWindowTitle("CSS Editor - " + self.project_name) self.variables = Variables() self.variables.changed.connect(self._variables_changed) self.variables.changed.connect(self._render_and_apply) self.template = CSSTextEdit() self.template.changed.connect(self._template_changed) self.template.changed.connect(self._render_and_apply) self.save = QPushButton('Save stylesheet to') self.save.clicked.connect(self._save_stylesheet) self.save_destination = QLineEdit() self.save_destination.textChanged.connect(self._destination_changed) self.splitter = QSplitter() self.splitter.setOrientation(Qt.Vertical) self.splitter.addWidget(self.variables) self.splitter.addWidget(self.template) layout = QGridLayout(self.main_window) layout.addWidget(self.splitter, 0, 0, 1, 2) layout.addWidget(self.save, 1, 0) layout.addWidget(self.save_destination, 1, 1) self.main_window.resize(800, 600) self._project_dir = self._ensure_project_dir() self._top_level_widgets = [ widget for widget in QApplication.topLevelWidgets() if widget.windowTitle() != self.main_window.windowTitle() ] self._variables = dict() self._template = None self._stylesheet = "" self._app.aboutToQuit.connect(self._save_editor_state) self._open() self.save_destination.setText(self.css_filepath) self.main_window.show()
def addCircle(self): try: self.win = QWidget() self.win.setMinimumSize(self.child_widget.width()/1.05,self.child_widget.height()/1.1) self.loading_wrapper = MLoading.huge() self.win.setLayout(QHBoxLayout()) self.win.layout().addWidget(self.loading_wrapper) self.widget.layout().addWidget(self.win) except: pass
def __init__(self, parent=None): QScrollArea.__init__(self, parent) self.setWidgetResizable(True) self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self._layout = QVBoxLayout() self._layout.setContentsMargins(0, 0, 0, 0) self._layout.setSpacing(Counters.SPACING) widget = QWidget() widget.setLayout(self._layout) self.setWidget(widget) self.setFixedWidth(200) self.checked_buttons = dict()
def ui(self): super(ProjectSettingsWidget, self).ui() image_layout = layouts.HorizontalLayout(spacing=2, margins=(2, 2, 2, 2)) image_layout.setContentsMargins(2, 2, 2, 2) image_layout.setSpacing(2) self.main_layout.addLayout(image_layout) self._project_image = QLabel() self._project_image.setAlignment(Qt.AlignCenter) image_layout.addStretch() image_layout.addWidget(self._project_image) image_layout.addStretch() self._settings_tab = tabs.BaseTabWidget(parent=self) self.main_layout.addWidget(self._settings_tab) self._naming_widget = NamingWidget(project=self._project) self._project_options_widget = rigoptionsviewer.RigOptionsViewer( option_object=self._project, parent=self) self._external_code_widget = ExternalCodeDirectoryWidget(parent=self) version_control_widget = QWidget(parent=self) version_control_layout = layouts.VerticalLayout(spacing=0, margins=(2, 2, 2, 2)) version_control_widget.setLayout(version_control_layout) self._version_type_combo = combobox.BaseComboBox(parent=self) version_control_layout.addWidget(self._version_type_combo) version_control_layout.addStretch() self._settings_tab.addTab(self._project_options_widget, 'Settings') self._settings_tab.addTab(self._naming_widget, 'Nomenclature') self._settings_tab.addTab(version_control_widget, 'Version Control') self._settings_tab.addTab(self._external_code_widget, 'External Code') bottom_layout = layouts.VerticalLayout(spacing=2, margins=(2, 2, 2, 2)) bottom_layout.setAlignment(Qt.AlignBottom) self.main_layout.addLayout(bottom_layout) bottom_layout.addLayout(dividers.DividerLayout()) buttons_layout = layouts.HorizontalLayout(spacing=2, margins=(2, 2, 2, 2)) bottom_layout.addLayout(buttons_layout) ok_icon = resources.icon('ok') self._ok_btn = buttons.BaseButton(parent=self) self._ok_btn.setIcon(ok_icon) buttons_layout.addWidget(self._ok_btn)