本文整理汇总了Python中PyQt4.QtCore.QSize.width方法的典型用法代码示例。如果您正苦于以下问题:Python QSize.width方法的具体用法?Python QSize.width怎么用?Python QSize.width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QSize
的用法示例。
在下文中一共展示了QSize.width方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sizeHint
# 需要导入模块: from PyQt4.QtCore import QSize [as 别名]
# 或者: from PyQt4.QtCore.QSize import width [as 别名]
def sizeHint(self):
q = self.parentWidget()
mw = q.style().pixelMetric(QStyle.PM_DockWidgetTitleMargin, None, q)
fw = q.style().pixelMetric(QStyle.PM_DockWidgetFrameWidth, None, q)
closeSize = QSize(0, 0)
if self.closeButton:
closeSize = self.closeButton.sizeHint()
floatSize = QSize(0, 0)
if self.floatButton:
floatSize = self.floatButton.sizeHint()
hideSize = QSize(0, 0)
if self.collapseButton:
hideSize = self.collapseButton.sizeHint()
pinSize = QSize(0, 0)
if self.pinButton:
pinSize = self.pinButton.sizeHint()
buttonHeight = max(max(closeSize.height(), floatSize.height()),
hideSize.height(), pinSize.height()) + 2
buttonWidth = closeSize.width() + floatSize.width() + hideSize.width() + pinSize.width()
titleFontMetrics = q.fontMetrics()
fontHeight = titleFontMetrics.lineSpacing() + 2 * mw
height = max(buttonHeight, fontHeight)
width = buttonWidth + height + 4 * mw + 2 * fw
if hasFeature(q, QDockWidget.DockWidgetVerticalTitleBar):
width, height = height, width
return QSize(width, height)
示例2: viewportSize
# 需要导入模块: from PyQt4.QtCore import QSize [as 别名]
# 或者: from PyQt4.QtCore.QSize import width [as 别名]
def viewportSize(self):
size = QSize(self.m_page.viewportSize())
result = {
'width': size.width(),
'height': size.height()
}
return result
示例3: readSettings
# 需要导入模块: from PyQt4.QtCore import QSize [as 别名]
# 或者: from PyQt4.QtCore.QSize import width [as 别名]
def readSettings(self):
self.imageFolder = os.path.normpath(str(self.settings.value("imageFolder").toString()))
self.ui.actionIgnore_Transparent_Pixels.setChecked( self.settings.value("ignoreAlpha", True).toBool())
self.ui.actionCheck_for_update_at_start.setChecked( self.settings.value("checkupdate", True).toBool())
self.ui.tolerance_le.setText( self.settings.value("tolerance").toString())
self.settings.beginGroup("/geometry")
p = QPoint() # position
s = QSize() # size
x = self.settings.value("X", -1).toInt()[0]
y = self.settings.value("Y", -1).toInt()[0]
# don't position outside current screen
qRect = QtGui.QDesktopWidget.availableGeometry(app.desktop())
if x > qRect.right():
x = 10
if y > qRect.bottom():
y = 10
p.setX(x)
p.setY(y)
s.setWidth(self.settings.value("W", -1).toInt()[0])
s.setHeight(self.settings.value("H", -1).toInt()[0])
self.settings.endGroup()
if p.x() > 0 and p.y() > 0 and s.width() > 0 and s.height() > 0:
self.resize(s) # restore size
self.move(p) # restore position
示例4: _setViewportSize
# 需要导入模块: from PyQt4.QtCore import QSize [as 别名]
# 或者: from PyQt4.QtCore.QSize import width [as 别名]
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))
示例5: pixmapFromSvg
# 需要导入模块: from PyQt4.QtCore import QSize [as 别名]
# 或者: from PyQt4.QtCore.QSize import width [as 别名]
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
示例6: NotificationServer
# 需要导入模块: from PyQt4.QtCore import QSize [as 别名]
# 或者: from PyQt4.QtCore.QSize import width [as 别名]
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)
示例7: get_favicon
# 需要导入模块: from PyQt4.QtCore import QSize [as 别名]
# 或者: from PyQt4.QtCore.QSize import width [as 别名]
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)
示例8: __fillLastTileComboWith
# 需要导入模块: from PyQt4.QtCore import QSize [as 别名]
# 或者: from PyQt4.QtCore.QSize import width [as 别名]
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()
示例9: set_viewport
# 需要导入模块: from PyQt4.QtCore import QSize [as 别名]
# 或者: from PyQt4.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
示例10: setScrolls
# 需要导入模块: from PyQt4.QtCore import QSize [as 别名]
# 或者: from PyQt4.QtCore.QSize import width [as 别名]
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)
示例11: __updatePixmap
# 需要导入模块: from PyQt4.QtCore import QSize [as 别名]
# 或者: from PyQt4.QtCore.QSize import width [as 别名]
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()
示例12: sizeHint
# 需要导入模块: from PyQt4.QtCore import QSize [as 别名]
# 或者: from PyQt4.QtCore.QSize import width [as 别名]
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
示例13: paintEvent
# 需要导入模块: from PyQt4.QtCore import QSize [as 别名]
# 或者: from PyQt4.QtCore.QSize import width [as 别名]
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)
示例14: __init__
# 需要导入模块: from PyQt4.QtCore import QSize [as 别名]
# 或者: from PyQt4.QtCore.QSize import width [as 别名]
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)
示例15: sizeHint
# 需要导入模块: from PyQt4.QtCore import QSize [as 别名]
# 或者: from PyQt4.QtCore.QSize import width [as 别名]
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