def sizeHint(self, column=0): """ Returns the current size of the item :param column: int :return: QSize """ if self.stretch_to_widget(): if self._size: size = self._size else: size = self.viewer().icon_size() w = self.stretch_to_widget().width() h = size.height() return QSize(w - 20, h) if self._size: return self._size else: icon_size = self.viewer().icon_size() if self.is_label_under_item(): w = icon_size.width() h = icon_size.width() + self.text_height() icon_size = QSize(w, h) return icon_size
def setupUi(self, Form): if not Form.objectName(): Form.setObjectName(u"Form") Form.resize(474, 90) self.horizontalLayout_2 = QHBoxLayout(Form) self.horizontalLayout_2.setObjectName(u"horizontalLayout_2") self.drag_button = QPushButton(Form) self.drag_button.setObjectName(u"drag_button") self.drag_button.setMinimumSize(QSize(16, 72)) self.drag_button.setMaximumSize(QSize(16, 16777215)) self.horizontalLayout_2.addWidget(self.drag_button) self.verticalLayout = QVBoxLayout() self.verticalLayout.setObjectName(u"verticalLayout") self.widget = QWidget(Form) self.widget.setObjectName(u"widget") self.horizontalLayout = QHBoxLayout(self.widget) self.horizontalLayout.setObjectName(u"horizontalLayout") self.icon_label = QLabel(self.widget) self.icon_label.setObjectName(u"icon_label") self.horizontalLayout.addWidget(self.icon_label) self.name_label = QLabel(self.widget) self.name_label.setObjectName(u"name_label") self.horizontalLayout.addWidget(self.name_label) self.horizontalSpacer = QSpacerItem(297, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout.addItem(self.horizontalSpacer) self.kill_button = QPushButton(self.widget) self.kill_button.setObjectName(u"kill_button") self.kill_button.setMinimumSize(QSize(24, 24)) self.kill_button.setMaximumSize(QSize(24, 24)) self.horizontalLayout.addWidget(self.kill_button) self.verticalLayout.addWidget(self.widget) self.progressBar = QProgressBar(Form) self.progressBar.setObjectName(u"progressBar") self.progressBar.setValue(24) self.progressBar.setAlignment(Qt.AlignCenter) self.progressBar.setTextVisible(True) self.progressBar.setInvertedAppearance(False) self.progressBar.setTextDirection(QProgressBar.TopToBottom) self.verticalLayout.addWidget(self.progressBar) self.horizontalLayout_2.addLayout(self.verticalLayout) self.retranslateUi(Form) QMetaObject.connectSlotsByName(Form)
def __init__(self, search_line=None, parent=None): super(SearchFindWidget, self).__init__(parent=parent) self.setObjectName('SearchFindWidget') self.text = '' self._placeholder_text = '' main_layout = layouts.HorizontalLayout(spacing=2, margins=(2, 2, 2, 2)) self.setLayout(main_layout) self._search_line = search_line or QLineEdit(self) self._search_menu = QMenu() self._search_menu.addAction('Test') icon_size = self.style().pixelMetric(QStyle.PM_SmallIconSize) delete_icon = resources.icon('delete') search_icon = QIcon(resources.icon('search')) self._clear_btn = buttons.IconButton(delete_icon, icon_padding=2, parent=self) self._clear_btn.setIconSize(QSize(icon_size, icon_size)) self._clear_btn.setFixedSize(QSize(icon_size, icon_size)) self._clear_btn.hide() self._search_btn = buttons.IconButton(search_icon, icon_padding=2, parent=self) self._search_btn.setIconSize(QSize(icon_size, icon_size)) self._search_btn.setFixedSize(QSize(icon_size, icon_size)) # self._search_btn.setStyleSheet('border: none;') # self._search_btn.setPopupMode(QToolButton.InstantPopup) self._search_btn.setEnabled(True) self._search_line.setStyleSheet(""" QLineEdit { padding-left: %spx; padding-right: %spx; border-radius:10px; border:2px; border-color:red; } """ % (self._search_button_padded_width(), self._clear_button_padded_width())) self._search_line.setMinimumSize( max( self._search_line.minimumSizeHint().width(), self._clear_button_padded_width() + self._search_button_padded_width()), max( self._search_line.minimumSizeHint().height(), max(self._clear_button_padded_width(), self._search_button_padded_width()))) main_layout.addWidget(self._search_line) self._search_line.setFocus() self._search_line.textChanged.connect(self.textChanged) self._search_line.textChanged.connect(self.set_text) # self._search_line.editingFinished.connect(self.editingFinished) # self._search_line.returnPressed.connect(self.returnPressed) self._clear_btn.clicked.connect(self.clear) self._search_btn.clicked.connect(self._popup_menu)
def __init__(self, parent=None, **kwargs): super(ColorPicker, self).__init__(parent=parent, **kwargs) self._default_value = (125, 125, 125) self.attr = None self.normalized = kwargs.get('normalized', False) self.min = kwargs.get('min', 0) self.max = kwargs.get('max', 99) self.color = kwargs.get('color', QColor(1.0, 1.0, 1.0)) self.mult = kwargs.get('mult', 0.1) self.color_swatch = color.ColorSwatch(parent=self, color=self.color, normalized=self.normalized) self.color_swatch.setMaximumSize(QSize(75, 20)) self.color_swatch.setMinimumSize(QSize(75, 20)) self.color_swatch.set_color(color=self.color) self.main_layout.addWidget(self.color_swatch) self.slider = QSlider(self) self.slider.setOrientation(Qt.Horizontal) self.slider.setValue(self.max) self.main_layout.addWidget(self.slider) self.set_max(self.max) self.set_min(self.min) self.slider.valueChanged.connect(self.OnSliderChanged) self.slider.sliderReleased.connect(self.OnSliderReleased) self.color_swatch.clicked.connect(self.OnColorPicked)
def __init__(self, parent=None): super(DataSearcherWidget, self).__init__(parent=parent) self._library = None self._space_operator = 'and' self._icon_btn = buttons.BaseButton(parent=self) self._icon_btn.setIcon(resources.icon('search')) self._icon_btn.setObjectName('searchButton') self._icon_btn.setIconSize(QSize(12, 12)) self._icon_btn.clicked.connect(self._on_icon_clicked) self._clear_btn = buttons.BaseButton(parent=self) self._clear_btn.setIcon(resources.icon('delete')) self._clear_btn.setObjectName('clearButton') self._clear_btn.setIconSize(QSize(12, 12)) self._clear_btn.setCursor(Qt.ArrowCursor) self._clear_btn.setToolTip('Clear all search text') self._clear_btn.clicked.connect(self._on_clear_clicked) self.setPlaceholderText(self.PLACEHOLDER_TEXT) self.textChanged.connect(self._on_text_changed) self.update() tip = 'Search all current items.' self.setToolTip(tip) self.setStatusTip(tip) self._icon_btn.setStyleSheet('background-color: transparent') self._clear_btn.setStyleSheet('background-color: transparent')
def __init__(self, dock_widget, renamable=False): super(DockTitleBar, self).__init__(dock_widget) self._renamable = renamable main_layout = layouts.HorizontalLayout(margins=(0, 0, 0, 1)) self.setLayout(main_layout) self._buttons_box = QGroupBox('') self._buttons_box.setObjectName('Docked') self._buttons_layout = layouts.HorizontalLayout(spacing=1, margins=(2, 2, 2, 2)) self._buttons_box.setLayout(self._buttons_layout) main_layout.addWidget(self._buttons_box) self._icon_label = QLabel(self) self._title_label = QLabel(self) self._title_label.setStyleSheet('background: transparent') self._title_edit = QLineEdit(self) self._title_edit.setVisible(False) self._button_size = QSize(14, 14) self._dock_btn = QToolButton(self) self._dock_btn.setIcon(resources.icon('restore_window', theme='color')) self._dock_btn.setMaximumSize(self._button_size) self._dock_btn.setAutoRaise(True) self._close_btn = QToolButton(self) self._close_btn.setIcon(resources.icon('close_window', theme='color')) self._close_btn.setMaximumSize(self._button_size) self._close_btn.setAutoRaise(True) self._buttons_layout.addSpacing(2) self._buttons_layout.addWidget(self._icon_label) self._buttons_layout.addWidget(self._title_label) self._buttons_layout.addWidget(self._title_edit) self._buttons_layout.addStretch() self._buttons_layout.addSpacing(5) self._buttons_layout.addWidget(self._dock_btn) self._buttons_layout.addWidget(self._close_btn) self._buttons_box.mouseDoubleClickEvent = self.mouseDoubleClickEvent self._buttons_box.mousePressEvent = self.mousePressEvent self._buttons_box.mouseMoveEvent = self.mouseMoveEvent self._buttons_box.mouseReleaseEvent = self.mouseReleaseEvent dock_widget.featuresChanged.connect(self._on_dock_features_changed) self._title_edit.editingFinished.connect(self._on_finish_edit) self._dock_btn.clicked.connect(self._on_dock_btn_clicked) self._close_btn.clicked.connect(self._on_close_btn_clicked) self._on_dock_features_changed(dock_widget.features()) self.set_title(dock_widget.windowTitle()) dock_widget.installEventFilter(self) dock_widget.topLevelChanged.connect(self._on_change_floating_style) if hasattr(dock_widget, 'icon') and callable(dock_widget.icon): self._icon_label.setPixmap(dock_widget.icon().pixmap(QSize(16, 16)))
def minimumSize(self): size = QSize() for item in self.itemList: size = size.expandedTo(item.minimumSize()) margin, _, _, _ = self.getContentsMargins() size += QSize(2 * margin, 2 * margin) return size
def _setup_logo_button(self): """ Internal function that setup window dragger button logo :return: IconMenuButton """ from tpDcc.libs.qt.widgets import buttons logo_button = buttons.IconMenuButton(parent=self) logo_button.setIconSize(QSize(24, 24)) logo_button.setFixedSize(QSize(30, 30)) return logo_button
def minimumSize(self): """ Returns the minimum size for this layout Overrides base minimumSize function :return: QSize """ size = QSize() for item in self._item_list: size = size.expandedTo(item.minimumSize()) size += QSize(2, 2) return size
def ui(self): super(BaseSaveWidget, self).ui() title_layout = layouts.HorizontalLayout() title_layout.setContentsMargins(2, 2, 0, 0) title_layout.setSpacing(2) self._icon_lbl = QLabel() self._icon_lbl.setMaximumSize(QSize(14, 14)) self._icon_lbl.setMinimumSize(QSize(14, 14)) self._icon_lbl.setScaledContents(True) self._title_lbl = QLabel() title_layout.addWidget(self._icon_lbl) title_layout.addWidget(self._title_lbl) self._folder_widget = directory.SelectFolder('Folder', use_app_browser=True) buttons_layout = layouts.HorizontalLayout() buttons_layout.setContentsMargins(4, 4, 4, 4) buttons_layout.setSpacing(4) buttons_frame = QFrame() buttons_frame.setFrameShape(QFrame.NoFrame) buttons_frame.setFrameShadow(QFrame.Plain) buttons_frame.setLayout(buttons_layout) buttons_layout.addStretch() self.save_btn = buttons.BaseButton('Save') self.cancel_btn = buttons.BaseButton('Cancel') buttons_layout.addWidget(self.save_btn, parent=self) buttons_layout.addWidget(self.cancel_btn, parent=self) buttons_layout.addStretch() self._options_layout = layouts.VerticalLayout() self._options_layout.setContentsMargins(0, 0, 0, 0) self._options_layout.setSpacing(2) self._options_frame = QFrame() self._options_frame.setFrameShape(QFrame.NoFrame) self._options_frame.setFrameShadow(QFrame.Plain) self._options_frame.setLineWidth(0) self._options_frame.setLayout(self._options_layout) self._extra_layout = layouts.VerticalLayout() self._extra_layout.setContentsMargins(0, 0, 0, 0) self._extra_layout.setSpacing(2) self.main_layout.addLayout(title_layout) self.main_layout.addWidget(self._folder_widget) self._extra_layout.addWidget(self._options_frame) self.main_layout.addWidget(dividers.Divider()) self.main_layout.addLayout(self._extra_layout) self.main_layout.addWidget(dividers.Divider()) self.main_layout.addWidget(buttons_frame)
def setupUi(self, parent): self.resize(275, 172) self.setWindowTitle('Convert units') self.layout = QVBoxLayout(parent) self.layout.setSizeConstraint(QLayout.SetFixedSize) align = (Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) self.layout1 = QHBoxLayout() self.label1 = QLabel() self.label1.setMinimumSize(QSize(100, 0)) self.label1.setText('Convert from:') self.label1.setAlignment(align) self.layout1.addWidget(self.label1) self.source_units = QLineEdit() self.source_units.setReadOnly(True) self.layout1.addWidget(self.source_units) self.layout.addLayout(self.layout1) self.layout2 = QHBoxLayout() self.label2 = QLabel() self.label2.setMinimumSize(QSize(100, 0)) self.label2.setText('to:') self.label2.setAlignment(align) self.layout2.addWidget(self.label2) self.destination_units = QLineEdit() self.layout2.addWidget(self.destination_units) self.layout.addLayout(self.layout2) self.message = QLabel() self.message.setText('') self.message.setAlignment(Qt.AlignCenter) self.layout.addWidget(self.message) self.buttonBox = QDialogButtonBox() self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Ok) self.layout.addWidget(self.buttonBox) self.buttonBox.setEnabled(False) self.buttonBox.accepted.connect(self.accept) self.destination_units.textChanged.connect(self.check) self.setLayout(self.layout) self.destination_units.setFocus()
def _setup_logo_button(self): """ Internal function that setup window dragger button logo :return: IconMenuButton """ # To avoid cyclic imports from tpDcc.libs.qt.widgets import buttons logo_button = buttons.IconMenuButton(parent=self) logo_button.setIconSize(QSize(24, 24)) logo_button.setFixedSize(QSize(30, 30)) logo_button.set_menu_align(Qt.AlignLeft) return logo_button
def resizeEvent(self, event): a = min(self.width(), self.height()) top_left = QPointF() if self._alignment & Qt.AlignTop: top_left.setY(0) elif self._alignment & Qt.AlignVCenter: top_left.setY((self.height() - a) * 0.5) elif self._alignment & Qt.AlignBottom: top_left.setY(self.height() - a) if self._alignment & Qt.AlignLeft: top_left.setX(0) elif self._alignment & Qt.AlignHCenter: top_left.setX((self.width() - a) * 0.5) elif self._alignment & Qt.AlignRight: top_left.setX(self.width() - a) self._bounds = QRectF(top_left, QSize(a, a)) self._knop_bounds.setWidth(a * 0.3) self._knop_bounds.setHeight(a * 0.3) radius = (self._bounds.width() - self._knop_bounds.height()) * 0.5 self._knop_bounds.moveCenter( QPointF(self._bounds.center().x() + self._x * radius, self._bounds.center().y() - self._y * radius))
def _show_message(self, message, icon, msecs=None, blocking=False): """ Set the given text to be displayed in the status widget :param message: str :param icon: QIcon :param msecs: int :param blocking: bool """ msecs = msecs or self.DEFAULT_DISPLAY_TIME self._blocking = blocking self.label_image.setStyleSheet('border: 0px;') if icon: self.label_image.setPixmap(icon.pixmap(QSize(17, 17))) self.label_image.show() else: self.label_image.hide() if message: self._label.setText(str(message)) self._timer.stop() self._timer.start(msecs) else: self._reset() self.update()
def create(self, delete_if_exists=True): """ Creates a new shelf """ if delete_if_exists: if gui.shelf_exists(shelf_name=self._name): gui.delete_shelf(shelf_name=self._name) else: assert not gui.shelf_exists(self._name), 'Shelf with name {} already exists!'.format(self._name) self._name = gui.create_shelf(name=self._name) # ======================================================================================================== self._category_btn = QPushButton('') if self._category_icon: self._category_btn.setIcon(self._category_icon) self._category_btn.setIconSize(QSize(18, 18)) self._category_menu = QMenu(self._category_btn) self._category_btn.setStyleSheet( 'QPushButton::menu-indicator {image: url(myindicator.png);' 'subcontrol-position: right center;subcontrol-origin: padding;left: -2px;}') self._category_btn.setMenu(self._category_menu) self._category_lbl = QLabel('MAIN') self._category_lbl.setAlignment(Qt.AlignCenter) font = self._category_lbl.font() font.setPointSize(6) self._category_lbl.setFont(font) menu_ptr = maya.OpenMayaUI.MQtUtil.findControl(self._name) menu_widget = qtutils.wrapinstance(menu_ptr, QWidget) menu_widget.layout().addWidget(self._category_btn) menu_widget.layout().addWidget(self._category_lbl) self.add_separator()
def __init__(self, *args): super(StatusWidget, self).__init__(*args) self._status = None self._blocking = False self._timer = QTimer(self) self.setObjectName('StatusWidget') self.setFrameShape(QFrame.NoFrame) self.setFixedHeight(19) self.setMinimumWidth(5) self._label = label.BaseLabel('', parent=self) self._label.setStyleSheet('background-color: transparent;') self._label.setCursor(Qt.IBeamCursor) self._label.setTextInteractionFlags(Qt.TextSelectableByMouse) self._label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) self.label_image = label.BaseLabel(parent=self) self.label_image.setMaximumSize(QSize(17, 17)) self.label_image.hide() self.main_layout = QHBoxLayout(self) self.main_layout.setContentsMargins(1, 0, 0, 0) self.main_layout.addWidget(self.label_image) self.main_layout.addWidget(self._label) self.setLayout(self.main_layout) self._timer.timeout.connect(self._reset) # Force set to initialize default status Qt property self.status = ''
def set_icon(self, icon, colors=None, size=None, color_offset=None, icon_scaling=None, tint_composition=QPainter.CompositionMode_Plus, grayscale=False): if size is not None: self.setIconSize(QSize(size, size)) if color_offset is not None: self.highlightOffset = color_offset if icon_scaling is not None: self.iconScaling = icon_scaling colors = colors or self.iconColors self.grayscale = grayscale self.tintComposition = tint_composition self.icon = icon self.set_icon_color(colors, update=False) self.update_icons()
def set_image(self, image_file): if not image_file or not os.path.isfile(image_file): return self._image_label.setPixmap( QPixmap(image_file).scaled(QSize(256, 256), Qt.KeepAspectRatio)) self._image_label.setVisible(True) self._gif_label.setVisible(False)
def __init__(self, parent=None, size=16, color=(255, 255, 255), initial_index=FIRST_INDEX): super(DisplayModeButton, self).__init__(parent=parent) menu_icon_double_names = [ 'menu_double_empty', 'menu_double_one', 'menu_double_full' ] menu_icon_triple_names = [ 'menu_triple_empty', 'menu_triple_one', 'menu_triple_two', 'menu_triple_full' ] self._menu_icon_double = [ resources.icon(menu_icon) for menu_icon in menu_icon_double_names ] self._menu_icon_triple = [ resources.icon(menu_icon) for menu_icon in menu_icon_triple_names ] self._current_icon = None self._icons = None self._displays = None self._initial_display = initial_index self._current_size = size self._icon_color = color self._highlight_offset = 40 self.setIconSize(QSize(size, size)) self.set_displays(ToolsetDisplays.Double)
def _create_pixmap(self, path, color): """ Internal function that creates a new item pixmap from the given path :param path: str :param color: str or QColor :return: QPixmap """ if not path: return QPixmap() dpi = self.treeWidget().dpi() key = path + color + 'DPI-' + str(dpi) item_pixmap = self._PIXMAP_CACHE.get(key) if not item_pixmap: width = 20 * dpi height = 18 * dpi if '/' not in path and '\\' not in path: path = resources.get('icons', path) if not path or not os.path.exists(path): path = self.default_icon_path() pixmap2 = pixmap.Pixmap(path) pixmap2.set_color(color) pixmap2 = pixmap2.scaled(16 * dpi, 16 * dpi, Qt.KeepAspectRatio, Qt.SmoothTransformation) x = (width - pixmap2.width()) / 2 y = (height - pixmap2.height()) / 2 item_pixmap = QPixmap(QSize(width, height)) item_pixmap.fill(Qt.transparent) painter = QPainter(item_pixmap) painter.drawPixmap(x, y, pixmap2) painter.end() self._PIXMAP_CACHE[key] = item_pixmap return item_pixmap
def ui(self): super(MetaCard, self).ui() self._title_layout = layouts.HorizontalLayout() self._cover_label = QLabel() self._cover_label.setFixedSize(QSize(200, 200)) self._avatar = avatar.Avatar() self._title_label = label.BaseLabel().h4() self._description_label = label.BaseLabel().secondary() self._description_label.setWordWrap(True) self._description_label.theme_elide_mode = Qt.ElideRight self._extra_btn = buttons.BaseToolButton( parent=self).image('more').icon_only() self._title_layout.addWidget(self._title_label) self._title_layout.addStretch() self._title_layout.addWidget(self._extra_btn) self._extra_btn.setVisible(self._extra) content_lyt = layouts.FormLayout(margins=(5, 5, 5, 5)) content_lyt.addRow(self._avatar, self._title_layout) content_lyt.addRow(self._description_label) self._btn_lyt = layouts.HorizontalLayout() self.main_layout.addWidget(self._cover_label) self.main_layout.addLayout(content_lyt) self.main_layout.addLayout(self._btn_lyt) self.main_layout.addStretch()
def __init__(self, name='SaveFile', title='Save File', size=(200, 125), fixed_size=False, frame_less=True, hide_title=False, parent=None, use_app_browser=False): parent = parent or dcc.get_main_window() super(BaseSaveFileDialog, self).__init__(name=name, title=title, size=size, fixed_size=fixed_size, frame_less=frame_less, hide_title=hide_title, use_app_browser=use_app_browser, parent=parent) self._open_button.setText('Save') size = QSize(42, 24) self.new_directory_button = QPushButton('New') self.new_directory_button.setToolTip('Create new directory') self.new_directory_button.setMinimumSize(size) self.new_directory_button.setMaximumWidth(size) self.new_directory_button.clicked.connect(self.create_new_directory) self.grid.itemAtPosition(0, 1).addWidget(self.new_directory_button, 0, 5)
def paint(self, painter, option, index): painter.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform) model = index.model() view = self.parent() if view.hasFocus() and option.state & QStyle.State_MouseOver: painter.setPen(Qt.NoPen) painter.setBrush(Qt.gray) painter.drawRoundedRect(option.rect.adjusted(1, 1, -1, -1), self._ICON_MARGIN, self._ICON_MARGIN) pixmap = model.data(index, Qt.DecorationRole).pixmap(view.iconSize()) pm_rect = QRect( option.rect.topLeft() + QPoint(self._ICON_MARGIN + 1, self._ICON_MARGIN + 1), view.iconSize() - QSize(self._ICON_MARGIN * 2, self._ICON_MARGIN * 2)) painter.drawPixmap(pm_rect, pixmap) if option.state & QStyle.State_Selected: painter.setPen( QPen(Qt.red, 1.0, Qt.SolidLine, Qt.SquareCap, Qt.RoundJoin)) painter.setBrush(Qt.NoBrush) painter.drawRect(option.rect.adjusted(2, 2, -2, -2)) font = view.font() fm = QFontMetrics(font) text = os.path.splitext( os.path.basename(model.data(index, Qt.DisplayRole)))[0] text = fm.elidedText(text, Qt.ElideRight, view.iconSize().width() - 4) text_opt = QTextOption() text_opt.setAlignment(Qt.AlignHCenter) txt_rect = QRectF(QPointF(pm_rect.bottomLeft() + QPoint(0, 1)), QPointF(option.rect.bottomRight() - QPoint(4, 3))) painter.save() painter.setPen(Qt.NoPen) painter.setBrush(QColor(22, 22, 22, 220)) painter.drawRoundedRect(txt_rect.adjusted(-2, -2, 2, 2), 2, 2) painter.restore() painter.setPen(self.parent().palette().color(QPalette.WindowText)) painter.drawText(txt_rect, text, text_opt) font.setPointSize(8) fm = QFontMetrics(font) item = model.itemFromIndex(index) size_text = '%d x %d' % (item.size.width(), item.size.height()) size_rect = fm.boundingRect(option.rect, Qt.AlignLeft | Qt.AlignTop, size_text) size_rect.translate(4, 4) painter.save() painter.setPen(Qt.NoPen) painter.setBrush(QColor(22, 22, 22, 220)) painter.drawRoundedRect(size_rect.adjusted(-2, -2, 2, 2), 2, 2) painter.restore() painter.setFont(font) painter.drawText(size_rect, size_text)
def sizeHint(self): spacing_x = self._flow_layout.spacing_x next_x = 0 for item in self._flow_layout.items_list: widget = item.widget() next_x += widget.sizeHint().width() + spacing_x return QSize(next_x + 3, super(FlowToolBar, self).sizeHint().height())
def get_icon_size(self): """ Returns the icon size :return: QSize """ return QSize(self._icon_size + self._icon_padding, self._icon_size + self._icon_padding)
def _init(self): """ Overrides base WindowResizer _int function """ super(CornerResizer, self)._init() self.setFixedSize(qtutils.size_by_dpi(QSize(5, 5)))
def sizeHint(self): """ Return the size of the tab bar with increased width for the add tab button :return: QSize, size of the tab bar """ size_hint = super(EditableTabBar, self).sizeHint() return QSize(size_hint.width() + 25, size_hint.height())
def __init__(self, orientation, parent): super(CollapsibleSplitterHandle, self).__init__(orientation, parent) self._is_expanded = True expand_icon = resources.icon('back') expand_hover_icon = resources.icon('expand_hover') expand_pressed_icon = resources.icon('expand_pressed') self.expand_btn = CollapsibleSplitterButton( icon=expand_icon, hover_icon=expand_hover_icon, pressed_icon=expand_pressed_icon, parent=self) self.expand_btn.setFixedWidth(16) self.expand_btn.setFixedHeight(16) self.expand_btn.setIconSize(QSize(16, 16)) self.expand_btn.setStyleSheet( 'QWidget {background-color: rgba(255, 255, 255, 0); border:0px;}') self.expand_btn.setFocusPolicy(Qt.NoFocus) self.expand_btn.setVisible(False) collapse_icon = resources.icon('next') collapse_hover_icon = resources.icon('collapse_hover') collapse_pressed_icon = resources.icon('collapse_pressed') self.collapse_btn = CollapsibleSplitterButton( icon=collapse_icon, hover_icon=collapse_hover_icon, pressed_icon=collapse_pressed_icon, parent=self) self.collapse_btn.setFixedWidth(16) self.collapse_btn.setFixedHeight(16) self.collapse_btn.setIconSize(QSize(16, 16)) self.collapse_btn.setStyleSheet( 'QWidget {background-color: rgba(255, 255, 255, 0); border:0px;}') self.collapse_btn.setFocusPolicy(Qt.NoFocus) self.collapse_btn.setVisible(False) if self.orientation() == Qt.Horizontal: self.collapse_btn.setCursor(Qt.SplitHCursor) else: self.collapse_btn.setCursor(Qt.SplitVCursor) self.expand_btn.clickedButton.connect(self.expand) self.collapse_btn.clickedButton.connect(self.collapse) self.expand()
def minimumSizeHint(self): """ Overrides base QRadioButton minimumSizeHint functino We do not need text space :return: QSize """ height = self._size * 1.2 return QSize(height, height / 2)
def set_size(self, size): """ Sets the size of the widget :param size: int """ self.setFixedSize(QSize(size, size)) self._loading_pixmap = self._loading_pixmap.scaledToWidth( size, Qt.SmoothTransformation)