当前位置: 首页>>代码示例>>Python>>正文


Python QSize.width方法代码示例

本文整理汇总了Python中PyQt5.QtCore.QSize.width方法的典型用法代码示例。如果您正苦于以下问题:Python QSize.width方法的具体用法?Python QSize.width怎么用?Python QSize.width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtCore.QSize的用法示例。


在下文中一共展示了QSize.width方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_icon_rect

# 需要导入模块: from PyQt5.QtCore import QSize [as 别名]
# 或者: from PyQt5.QtCore.QSize import width [as 别名]
    def _get_icon_rect(self, opt, text_rect):
        """Get a QRect for the icon to draw.

        Args:
            opt: QStyleOptionTab
            text_rect: The QRect for the text.

        Return:
            A QRect.
        """
        icon_size = opt.iconSize
        if not icon_size.isValid():
            icon_extent = self.pixelMetric(QStyle.PM_SmallIconSize)
            icon_size = QSize(icon_extent, icon_extent)
        icon_mode = (QIcon.Normal if opt.state & QStyle.State_Enabled
                     else QIcon.Disabled)
        icon_state = (QIcon.On if opt.state & QStyle.State_Selected
                      else QIcon.Off)
        # reserve space for favicon when tab bar is vertical (issue #1968)
        position = config.get('tabs', 'position')
        if (opt.icon.isNull() and
                position in [QTabWidget.East, QTabWidget.West] and
                config.get('tabs', 'show-favicons')):
            tab_icon_size = icon_size
        else:
            actual_size = opt.icon.actualSize(icon_size, icon_mode, icon_state)
            tab_icon_size = QSize(
                min(actual_size.width(), icon_size.width()),
                min(actual_size.height(), icon_size.height()))
        icon_rect = QRect(text_rect.left(), text_rect.top() + 1,
                          tab_icon_size.width(), tab_icon_size.height())
        icon_rect = self._style.visualRect(opt.direction, opt.rect, icon_rect)
        return icon_rect
开发者ID:NoctuaNivalis,项目名称:qutebrowser,代码行数:35,代码来源:tabwidget.py

示例2: _get_icon_rect

# 需要导入模块: from PyQt5.QtCore import QSize [as 别名]
# 或者: from PyQt5.QtCore.QSize import width [as 别名]
    def _get_icon_rect(self, opt, text_rect):
        """Get a QRect for the icon to draw.

        Args:
            opt: QStyleOptionTab
            text_rect: The QRect for the text.

        Return:
            A QRect.
        """
        icon_size = opt.iconSize
        if not icon_size.isValid():
            icon_extent = self.pixelMetric(QStyle.PM_SmallIconSize)
            icon_size = QSize(icon_extent, icon_extent)
        icon_mode = (QIcon.Normal if opt.state & QStyle.State_Enabled
                     else QIcon.Disabled)
        icon_state = (QIcon.On if opt.state & QStyle.State_Selected
                      else QIcon.Off)
        tab_icon_size = opt.icon.actualSize(icon_size, icon_mode, icon_state)
        tab_icon_size = QSize(min(tab_icon_size.width(), icon_size.width()),
                              min(tab_icon_size.height(), icon_size.height()))
        icon_rect = QRect(text_rect.left(),
                          text_rect.center().y() - tab_icon_size.height() / 2,
                          tab_icon_size.width(), tab_icon_size.height())
        icon_rect = self._style.visualRect(opt.direction, opt.rect, icon_rect)
        qtutils.ensure_valid(icon_rect)
        return icon_rect
开发者ID:mfussenegger,项目名称:qutebrowser,代码行数:29,代码来源:tabwidget.py

示例3: minimumTabSizeHint

# 需要导入模块: from PyQt5.QtCore import QSize [as 别名]
# 或者: from PyQt5.QtCore.QSize import width [as 别名]
    def minimumTabSizeHint(self, index):
        """Set the minimum tab size to indicator/icon/... text.

        Args:
            index: The index of the tab to get a size hint for.

        Return:
            A QSize.
        """
        icon = self.tabIcon(index)
        padding_count = 2
        if icon.isNull():
            icon_size = QSize(0, 0)
        else:
            extent = self.style().pixelMetric(QStyle.PM_TabBarIconSize, None,
                                              self)
            icon_size = icon.actualSize(QSize(extent, extent))
            padding_count += 1
        indicator_width = config.get('tabs', 'indicator-width')
        if indicator_width != 0:
            indicator_width += config.get('tabs', 'indicator-space')
        padding_width = self.style().pixelMetric(PM_TabBarPadding, None, self)
        height = self.fontMetrics().height()
        width = (self.fontMetrics().width('\u2026') +
                 icon_size.width() + padding_count * padding_width +
                 indicator_width)
        return QSize(width, height)
开发者ID:JIVS,项目名称:qutebrowser,代码行数:29,代码来源:tabwidget.py

示例4: set_viewport

# 需要导入模块: from PyQt5.QtCore import QSize [as 别名]
# 或者: from PyQt5.QtCore.QSize import width [as 别名]
    def set_viewport(self, size, raise_if_empty=False):
        """
        Set viewport size.
        If size is "full" viewport size is detected automatically.
        If can also be "<width>x<height>".

        .. note::

           This will update all JS geometry variables, but window resize event
           is delivered asynchronously and so ``window.resize`` will not be
           invoked until control is yielded to the event loop.

        """
        if size == 'full':
            size = self.web_page.mainFrame().contentsSize()
            self.logger.log("Contents size: %s" % size, min_level=2)
            if size.isEmpty():
                if raise_if_empty:
                    raise RuntimeError("Cannot detect viewport size")
                else:
                    size = defaults.VIEWPORT_SIZE
                    self.logger.log("Viewport is empty, falling back to: %s" %
                                    size)

        if not isinstance(size, QSize):
            validate_size_str(size)
            w, h = map(int, size.split('x'))
            size = QSize(w, h)
        self.web_page.setViewportSize(size)
        self._force_relayout()
        w, h = int(size.width()), int(size.height())
        self.logger.log("viewport size is set to %sx%s" % (w, h), min_level=2)
        return w, h
开发者ID:takaaptech,项目名称:splash,代码行数:35,代码来源:browser_tab.py

示例5: renderToTexture

# 需要导入模块: from PyQt5.QtCore import QSize [as 别名]
# 或者: from PyQt5.QtCore.QSize import width [as 别名]
    def renderToTexture(self, levelOfDetail = 1.0):
        # Determine the fbo size we will need.
        size = (self.sceneRect().size() * levelOfDetail).toSize()
        fboSize = nextPowerOfTwo(size)
        if fboSize.isEmpty():
            fboSize = QSize(16, 16)

        # Create or re-create the fbo.
        if self.fbo is None or self.fbo.size() != fboSize:
            #del self.fbo
            self.fbo = QGLFramebufferObject(fboSize, self.format)
            if not self.fbo.isValid():
                #del self.fbo
                self.fbo = None
                return 0
            self.dirty = True

        # Return the previous texture contents if the scene hasn't changed.
        if self.fbo is not None and not self.dirty:
            return self.fbo.texture()

        # Render the scene into the fbo, scaling the QPainter's view
        # transform up to the power-of-two fbo size.
        painter = QPainter(self.fbo)
        painter.setWindow(0, 0, size.width(), size.height())
        painter.setViewport(0, 0, fboSize.width(), fboSize.height())
        self.render(painter)
        painter.end()
        self.dirty = False
        return self.fbo.texture()
开发者ID:xuanvu,项目名称:Carla,代码行数:32,代码来源:qgraphicsembedscene.py

示例6: minimumTabSizeHint

# 需要导入模块: from PyQt5.QtCore import QSize [as 别名]
# 或者: from PyQt5.QtCore.QSize import width [as 别名]
    def minimumTabSizeHint(self, index):
        """Set the minimum tab size to indicator/icon/... text.

        Args:
            index: The index of the tab to get a size hint for.

        Return:
            A QSize.
        """
        icon = self.tabIcon(index)
        padding = config.get('tabs', 'padding')
        padding_h = padding.left + padding.right
        padding_v = padding.top + padding.bottom
        if icon.isNull():
            icon_size = QSize(0, 0)
        else:
            extent = self.style().pixelMetric(QStyle.PM_TabBarIconSize, None,
                                              self)
            icon_size = icon.actualSize(QSize(extent, extent))
            padding_h += self.style().pixelMetric(
                PixelMetrics.icon_padding, None, self)
        indicator_width = config.get('tabs', 'indicator-width')
        height = self.fontMetrics().height() + padding_v
        width = (self.fontMetrics().width('\u2026') + icon_size.width() +
                 padding_h + indicator_width)
        return QSize(width, height)
开发者ID:ProtractorNinja,项目名称:qutebrowser,代码行数:28,代码来源:tabwidget.py

示例7: calculate_relative_position

# 需要导入模块: from PyQt5.QtCore import QSize [as 别名]
# 或者: from PyQt5.QtCore.QSize import width [as 别名]
def calculate_relative_position(parent_rect: QtCore.QRect, own_size: QtCore.QSize,
                                constraint: RelativeLayoutConstraint):
    """
    Calculates the position of the element, given its size, the position and size of the parent and a relative layout
    constraint. The position is the position of the parent plus the weighted size of the parent, the weighted size of
    the element and an offset. The weights and the offset are given by the constraint for each direction.

    :param parent_rect: parent coordinates and size as rectangle
    :param own_size: size of the element (width and height)
    :param constraint: relative layout constraint to apply
    :return: tuple of recommended x and y positions of the element
    """
    """
        Returns the left, upper corner of an object if the parent rectangle (QRect) is given and our own size (QSize)
        and a relative layout constraint (see RelativeLayoutConstraint).
    """
    x = (parent_rect.x()
         + constraint.x[0] * parent_rect.width()
         + constraint.x[1] * own_size.width()
         + constraint.x[2])
    y = (parent_rect.y()
         + constraint.y[0] * parent_rect.height()
         + constraint.y[1] * own_size.height()
         + constraint.y[2])
    return x, y
开发者ID:Trilarion,项目名称:imperialism-remake,代码行数:27,代码来源:qt.py

示例8: minimumTabSizeHint

# 需要导入模块: from PyQt5.QtCore import QSize [as 别名]
# 或者: from PyQt5.QtCore.QSize import width [as 别名]
    def minimumTabSizeHint(self, index):
        """Override minimumTabSizeHint because we want no hard minimum.

        There are two problems with having a hard minimum tab size:
        - When expanding is True, the window will expand without stopping
          on some window managers.
        - We don't want the main window to get bigger with many tabs. If
          nothing else helps, we *do* want the tabs to get smaller instead
          of enforcing a minimum window size.

        Args:
            index: The index of the tab to get a sizehint for.

        Return:
            A QSize.
        """
        icon = self.tabIcon(index)
        padding_count = 0
        if not icon.isNull():
            extent = self.style().pixelMetric(QStyle.PM_TabBarIconSize, None,
                                              self)
            icon_size = icon.actualSize(QSize(extent, extent))
            padding_count += 1
        else:
            icon_size = QSize(0, 0)
        padding_width = self.style().pixelMetric(PM_TabBarPadding, None, self)
        height = self.fontMetrics().height()
        width = (self.fontMetrics().size(0, '\u2026').width() +
                 icon_size.width() + padding_count * padding_width)
        return QSize(width, height)
开发者ID:mfussenegger,项目名称:qutebrowser,代码行数:32,代码来源:tabwidget.py

示例9: get_favicon

# 需要导入模块: from PyQt5.QtCore import QSize [as 别名]
# 或者: from PyQt5.QtCore.QSize import width [as 别名]
    def get_favicon(self):
        u"""
        Get favicon for the site.

        This is called when the site_url can’t be loaded or when that
        page doesn’t contain a link tag with rel set to icon (the new
        way of doing site icons.)
        """
        if self.site_icon:
            return
        if not with_pyqt:
            self.site_icon = None
            return
        ico_url = urllib.parse.urljoin(self.icon_url, "/favicon.ico")
        ico_request = urllib.request.Request(ico_url)
        if self.user_agent:
            ico_request.add_header('User-agent', self.user_agent)
        ico_response = urllib.request.urlopen(ico_request)
        if 200 != ico_response.code:
            self.site_icon = None
            return
        self.site_icon = QImage.fromData(ico_response.read())
        max_size = QSize(self.max_icon_size, self.max_icon_size)
        ico_size = self.site_icon.size()
        if ico_size.width() > max_size.width() \
                or ico_size.height() > max_size.height():
            self.site_icon = self.site_icon.scaled(
                max_size, Qt.KeepAspectRatio, Qt.SmoothTransformation)
开发者ID:ospalh,项目名称:anki-addons,代码行数:30,代码来源:downloader.py

示例10: maxSize

# 需要导入模块: from PyQt5.QtCore import QSize [as 别名]
# 或者: from PyQt5.QtCore.QSize import width [as 别名]
 def maxSize(self):
     size = QSize()
     for variation in self.d.variations:
         size.setWidth(max(size.width(), variation.map.width()))
         size.setHeight(max(size.height(), variation.map.height()))
     
     return size
开发者ID:theall,项目名称:Python-Tiled,代码行数:9,代码来源:tilestamp.py

示例11: calculateSize

# 需要导入模块: from PyQt5.QtCore import QSize [as 别名]
# 或者: from PyQt5.QtCore.QSize import width [as 别名]
    def calculateSize(self, sizeType):
        totalSize = QSize()

        for wrapper in self.list:
            position = wrapper.position
            itemSize = QSize()

            if sizeType == self.MinimumSize:
                itemSize = wrapper.item.minimumSize()
            else: # sizeType == self.SizeHint
                itemSize = wrapper.item.sizeHint()

            if position in (self.North, self.South, self.Center):
                totalSize.setHeight(totalSize.height() + itemSize.height())

            if position in (self.West, self.East, self.Center):
                totalSize.setWidth(totalSize.width() + itemSize.width())

        return totalSize
开发者ID:Axel-Erfurt,项目名称:pyqt5,代码行数:21,代码来源:borderlayout.py

示例12: sizeHint

# 需要导入模块: from PyQt5.QtCore import QSize [as 别名]
# 或者: from PyQt5.QtCore.QSize import width [as 别名]
    def sizeHint(self):
        hint = QLabel.sizeHint(self)

        if self.maximum_size_hint != None:
            hint = QSize(max(hint.width(), self.maximum_size_hint.width()),
                         max(hint.height(), self.maximum_size_hint.height()))

        self.maximum_size_hint = hint

        return hint
开发者ID:Tinkerforge,项目名称:brickv,代码行数:12,代码来源:plot_widget.py

示例13: FeatureTableWidgetHHeader

# 需要导入模块: from PyQt5.QtCore import QSize [as 别名]
# 或者: from PyQt5.QtCore.QSize import width [as 别名]
class FeatureTableWidgetHHeader(QTableWidgetItem):
    sub_trans = str.maketrans('0123456789', '₀₁₂₃₄₅₆₇₈₉')

    def __init__(self, column, sigma=None, window_size=3.5):
        QTableWidgetItem.__init__(self)
        # init
        # ------------------------------------------------
        self.column = column
        self.sigma = sigma
        self.window_size = window_size
        self.pixmapSize = QSize(61, 61)
        self.setNameAndBrush(self.sigma)

    @property
    def brushSize(self):
        if self.sigma is None:
            return 0
        else:
            return int(3.0 * self.sigma + 0.5) + 1

    def setNameAndBrush(self, sigma, color=Qt.black):
        self.sigma = sigma
        self.setText(f'σ{self.column}'.translate(self.sub_trans))
        if self.sigma is not None:
            total_window = (1 + 2 * int(self.sigma * self.window_size + 0.5))
            self.setToolTip(f'sigma = {sigma:.1f} pixels, window diameter = {total_window:.1f}')
        font = QFont()
        font.setPointSize(10)
        # font.setBold(True)
        self.setFont(font)
        self.setForeground(color)

        pixmap = QPixmap(self.pixmapSize)
        pixmap.fill(Qt.transparent)
        painter = QPainter()
        painter.begin(pixmap)
        painter.setRenderHint(QPainter.Antialiasing, True)
        painter.setPen(color)
        brush = QBrush(color)
        painter.setBrush(brush)
        painter.drawEllipse(QRect(old_div(self.pixmapSize.width(), 2) - old_div(self.brushSize, 2),
                                  old_div(self.pixmapSize.height(), 2) - old_div(self.brushSize, 2),
                                  self.brushSize, self.brushSize))
        painter.end()
        self.setIcon(QIcon(pixmap))
        self.setTextAlignment(Qt.AlignVCenter)

    def setIconAndTextColor(self, color):
        self.setNameAndBrush(self.sigma, color)
开发者ID:ilastik,项目名称:ilastik,代码行数:51,代码来源:featureTableWidget.py

示例14: mapSize

# 需要导入模块: from PyQt5.QtCore import QSize [as 别名]
# 或者: from PyQt5.QtCore.QSize import width [as 别名]
 def mapSize(self):
     p = RenderParams(self.map())
     # The map size is the same regardless of which indexes are shifted.
     if (p.staggerX):
         size = QSize(self.map().width() * p.columnWidth + p.sideOffsetX,
                    self.map().height() * (p.tileHeight + p.sideLengthY))
         if (self.map().width() > 1):
             size.setHeight(size.height() + p.rowHeight)
         return size
     else:
         size = QSize(self.map().width() * (p.tileWidth + p.sideLengthX),
                    self.map().height() * p.rowHeight + p.sideOffsetY)
         if (self.map().height() > 1):
             size.setWidth(size.width() + p.columnWidth)
         return size
开发者ID:theall,项目名称:Python-Tiled,代码行数:17,代码来源:hexagonalrenderer.py

示例15: maybe_get_icon

# 需要导入模块: from PyQt5.QtCore import QSize [as 别名]
# 或者: from PyQt5.QtCore.QSize import width [as 别名]
    def maybe_get_icon(self):
        u"""
        Get icon for the site as a QImage if we haven’t already.

        Get the site icon, either the 'rel="icon"' or the favicon, for
        the web page at url or passed in as page_html and store it as
        a QImage. This function can be called repeatedly and loads the
        icon only once.
        """
        if self.site_icon:
            return
        if not with_pyqt:
            self.site_icon = None
            return
        page_request = urllib.request.Request(self.icon_url)
        if self.user_agent:
            page_request.add_header('User-agent', self.user_agent)
        page_response = urllib.request.urlopen(page_request)
        if 200 != page_response.code:
            self.get_favicon()
            return
        page_soup = soup(page_response, 'html.parser')
        try:
            icon_url = page_soup.find(
                name='link', attrs={'rel': 'icon'})['href']
        except (TypeError, KeyError):
            self.get_favicon()
            return
        # The url may be absolute or relative.
        if not urllib.parse.urlsplit(icon_url).netloc:
            icon_url = urllib.parse.urljoin(
                self.url, urllib.parse.quote(icon_url.encode('utf-8')))
        icon_request = urllib.request.Request(icon_url)
        if self.user_agent:
            icon_request.add_header('User-agent', self.user_agent)
        icon_response = urllib.request.urlopen(icon_request)
        if 200 != icon_response.code:
            self.site_icon = None
            return
        self.site_icon = QImage.fromData(icon_response.read())
        max_size = QSize(self.max_icon_size, self.max_icon_size)
        icon_size = self.site_icon.size()
        if icon_size.width() > max_size.width() \
                or icon_size.height() > max_size.height():
            self.site_icon = self.site_icon.scaled(
                max_size, Qt.KeepAspectRatio, Qt.SmoothTransformation)
开发者ID:ospalh,项目名称:anki-addons,代码行数:48,代码来源:downloader.py


注:本文中的PyQt5.QtCore.QSize.width方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。