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


Python QtCore.QSize类代码示例

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


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

示例1: get_favicon

    def get_favicon(self):
        """
        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 = urlparse.urljoin(self.icon_url, "/favicon.ico")
        ico_request = urllib2.Request(ico_url)
        if self.user_agent:
            ico_request.add_header('User-agent', self.user_agent)
        ico_response = urllib2.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:hodoo112,项目名称:anki-addons,代码行数:28,代码来源:downloader.py

示例2: set_viewport

    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:0xmilk,项目名称:splash,代码行数:33,代码来源:browser_tab.py

示例3: NotificationServer

class NotificationServer(QObject):
    def __init__(self, parent=None):
        QObject.__init__(self, parent)
        self.notifications = set()
        self.size = QSize(300, 100)
        self.margin = QPoint(10, 10)

    def notify(self, html):
        note = Notification(html)
        self.connect(note, SIGNAL("done"), self.noteDestroyed)

        desktop = QApplication.desktop().availableGeometry(note)
        me = QRect(QPoint(0, 0), self.size)
        me.moveBottomRight(desktop.bottomRight() - self.margin)
        while self.notePosTaken(me):
            me.translate(0, 0 - (self.size.height() + (self.margin.y() * 2)))
            if not desktop.contains(me):
                me.moveBottom(desktop.bottom() - self.margin.y())
                me.translate(0 - (self.size.width() + self.margin.x() * 2), 0)

        note.setGeometry(me)
        self.notifications.add(note)
        note.display()

    def notePosTaken(self, rect):
        for note in self.notifications:
            if note.geometry().intersects(rect):
                return True
        return False

    def noteDestroyed(self, note):
        self.notifications.remove(note)
开发者ID:bodil,项目名称:feedlol,代码行数:32,代码来源:Notification.py

示例4: _setViewportSize

 def _setViewportSize(self, size):
     if not isinstance(size, QSize):
         w, h = map(int, size.split('x'))
         size = QSize(w, h)
     self.web_page.setViewportSize(size)
     w, h = int(size.width()), int(size.height())
     self.log("viewport size for %s is set to %sx%s" % (id(self.splash_request), w, h))
开发者ID:microhello,项目名称:splash,代码行数:7,代码来源:qtrender.py

示例5: __updatePixmap

    def __updatePixmap(self):
        """
        Update the cached shadow pixmap.
        """
        rect_size = QSize(50, 50)
        left = top = right = bottom = self.radius_

        # Size of the pixmap.
        pixmap_size = QSize(rect_size.width() + left + right,
                            rect_size.height() + top + bottom)
        shadow_rect = QRect(QPoint(left, top), rect_size)
        pixmap = QPixmap(pixmap_size)
        pixmap.fill(QColor(0, 0, 0, 0))
        rect_fill_color = self.palette().color(QPalette.Window)

        pixmap = render_drop_shadow_frame(
                      pixmap,
                      QRectF(shadow_rect),
                      shadow_color=self.color_,
                      offset=QPointF(0, 0),
                      radius=self.radius_,
                      rect_fill_color=rect_fill_color
                      )

        self.__shadowPixmap = pixmap
        self.update()
开发者ID:675801717,项目名称:orange3,代码行数:26,代码来源:dropshadow.py

示例6: __fillLastTileComboWith

 def __fillLastTileComboWith(self, lastTiles, winnerTiles):
     """fill last meld combo with prepared content"""
     self.comboTilePairs = lastTiles
     idx = self.cbLastTile.currentIndex()
     if idx < 0:
         idx = 0
     indexedTile = str(self.cbLastTile.itemData(idx).toPyObject())
     restoredIdx = None
     self.cbLastTile.clear()
     if not winnerTiles:
         return
     pmSize = winnerTiles[0].board.tileset.faceSize
     pmSize = QSize(pmSize.width() * 0.5, pmSize.height() * 0.5)
     self.cbLastTile.setIconSize(pmSize)
     QPixmapCache.clear()
     self.__tilePixMaps = []
     shownTiles = set()
     for tile in winnerTiles:
         if tile.element in lastTiles and tile.element not in shownTiles:
             shownTiles.add(tile.element)
             self.cbLastTile.addItem(QIcon(tile.graphics.pixmapFromSvg(pmSize, withBorders=False)),
                     '', QVariant(tile.element))
             if indexedTile == tile.element:
                 restoredIdx = self.cbLastTile.count() - 1
     if not restoredIdx and indexedTile:
         # try again, maybe the tile changed between concealed and exposed
         indexedTile = indexedTile.lower()
         for idx in range(self.cbLastTile.count()):
             if indexedTile == str(self.cbLastTile.itemData(idx).toPyObject()).lower():
                 restoredIdx = idx
                 break
     if not restoredIdx:
         restoredIdx = 0
     self.cbLastTile.setCurrentIndex(restoredIdx)
     self.prevLastTile = self.computeLastTile()
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:35,代码来源:scoring.py

示例7: pixmapFromSvg

 def pixmapFromSvg(self, pmapSize=None, withBorders=None):
     """returns a pixmap with default size as given in SVG and optional borders/shadows"""
     if withBorders is None:
         withBorders = Preferences.showShadows
     if withBorders:
         wantSize = self.tileset.tileSize.toSize()
     else:
         wantSize = self.tileset.faceSize.toSize()
     if not pmapSize:
         pmapSize = wantSize
     result = QPixmap(pmapSize)
     result.fill(Qt.transparent)
     painter = QPainter(result)
     if not painter.isActive():
         logException('painter is not active. Wanted size: %s' % str(pmapSize))
     try:
         xScale = float(pmapSize.width()) / wantSize.width()
         yScale = float(pmapSize.height()) / wantSize.height()
     except ZeroDivisionError:
         xScale = 1
         yScale = 1
     if not withBorders:
         painter.scale(*self.tileset.tileFaceRelation())
         painter.translate(-self.facePos())
     renderer = self.tileset.renderer()
     renderer.render(painter, self.elementId())
     painter.resetTransform()
     self._drawDarkness(painter)
     if self.showFace():
         faceSize = self.tileset.faceSize.toSize()
         faceSize = QSize(faceSize.width() * xScale, faceSize.height() * yScale)
         painter.translate(self.facePos())
         renderer.render(painter, self.tileset.svgName[self.tile.element.lower()],
                 QRectF(QPointF(), QSizeF(faceSize)))
     return result
开发者ID:ospalh,项目名称:kajongg-fork,代码行数:35,代码来源:uitile.py

示例8: sizeHint

    def sizeHint(self):
        """
        Reimplemented from `QPushButton.sizeHint`.

        Returns
        -------
        sh : QSize
        """
        sh = super().sizeHint()
        option = QStyleOptionButton()
        self.initStyleOption(option)
        style = self.style()
        fm = option.fontMetrics
        if option.iconSize.isValid():
            icsize = option.iconSize
            icsize.setWidth(icsize.width() + 4)
        else:
            icsize = QSize()

        for text in self.__textChoiceList:
            option.text = text
            size = fm.size(Qt.TextShowMnemonic, text)

            if not icsize.isNull():
                size.setWidth(size.width() + icsize.width())
                size.setHeight(max(size.height(), icsize.height()))

            sh = sh.expandedTo(
                style.sizeFromContents(QStyle.CT_PushButton, option,
                                       size, self))
        return sh
开发者ID:tomazc,项目名称:orange3,代码行数:31,代码来源:buttons.py

示例9: paintEvent

    def paintEvent(self, event):
        crect = self.rect()
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)

        painter.setBrush(QBrush(Qt.white))
        painter.setPen(QPen(Qt.lightGray, 1.2))
        painter.drawRoundedRect(QRectF(crect).adjusted(2, 2, -2, -2), 2, 2,
                                Qt.AbsoluteSize)

        if self._selected:
            painter.setPen(QPen(QBrush(Qt.red), 2))
        if self._highlighted:
            painter.setBrush(QBrush(Qt.gray,  Qt.FDiagPattern))
        else:
            painter.setBrush(Qt.NoBrush)

        painter.drawRoundedRect(QRectF(crect).adjusted(2, 2, -2, -2), 2, 2,
                                Qt.AbsoluteSize)

        defsize = self.renderer().defaultSize()
        margin = 5

        bound = QSize(defsize)
        bound.scale(crect.width() - margin, crect.height() - margin,
                    Qt.KeepAspectRatio)

        svgrect = QRectF(0, 0, bound.width(), bound.height())
        svgrect.moveCenter(crect.center())
        self.renderer().render(painter, svgrect)
开发者ID:JakaKokosar,项目名称:orange-bio,代码行数:30,代码来源:OWMoleculeVisualizer.py

示例10: viewportSize

 def viewportSize(self):
     size = QSize(self.m_page.viewportSize())
     result = {
         'width': size.width(),
         'height': size.height()
     }
     return result
开发者ID:adragomir,项目名称:phantomjs,代码行数:7,代码来源:phantom.py

示例11: setScrolls

    def setScrolls(self):
        """
        Currently not being used...
        """
        self.horizontalScrollBar().setVisible(True)
        self.verticalScrollBar().setVisible(True)

        self.__prevZoomFactor = 1.0

        # nasty code here...
        shouldZoom = True
        while shouldZoom:
            w = self.width()
            h = self.height()
            imgSize = self.__glWidget.GetImageSize()
            if imgSize.width() == 0 or imgSize.height() == 0:
                imgSize = QSize(100, 100)

            zoomFactor = self.__glWidget.GetZoomFactor()

            if w < imgSize.width() * zoomFactor or h < imgSize.height() * zoomFactor:
                self.__glWidget.ZoomOut()
            else:
                shouldZoom = False

        self.UpdateViewport(True)
开发者ID:azer89,项目名称:x_prototypes,代码行数:26,代码来源:GLContainer.py

示例12: sizeHint

 def sizeHint(self, option, index):
     size = QStyledItemDelegate.sizeHint(self,  option, index)
     parent = self.parent()
     item = parent.itemFromIndex(index)
     widget = parent.itemWidget(item, 0)
     if widget:
         size = QSize(size.width(), widget.sizeHint().height() / 2)
     return size
开发者ID:nagyistoce,项目名称:orange-bio,代码行数:8,代码来源:OWDatabasesUpdate.py

示例13: __init__

 def __init__(self, *args):
     QComboBox.__init__(self, *args)
     self.paletteImg = []
     self.cachedPalettes = []
     ##        self.setItemDelegate(PaletteItemDelegate(self, self))
     size = self.sizeHint()
     size = QSize(size.width() * 2 / 3, size.height() * 2 / 3)
     self.setIconSize(size)
开发者ID:testmana2,项目名称:orange3,代码行数:8,代码来源:colorpalette.py

示例14: minimumSize

    def minimumSize(self):
        size = QSize()
        for item in self.items:
            size = size.expandedTo(item.minimumSize())

        margin = self.margin()
        size += QSize(2*margin, 2*margin)
        return size
开发者ID:enoki,项目名称:bandleader,代码行数:8,代码来源:flowlayout.py

示例15: sizeHint

    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:fischero19,项目名称:brickv,代码行数:10,代码来源:industrial_dual_0_20ma.py


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