本文整理汇总了Python中PySide.QtGui.QPixmap.height方法的典型用法代码示例。如果您正苦于以下问题:Python QPixmap.height方法的具体用法?Python QPixmap.height怎么用?Python QPixmap.height使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QPixmap
的用法示例。
在下文中一共展示了QPixmap.height方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CheckIconWidget
# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import height [as 别名]
class CheckIconWidget(QWidget):
"""An icon widget that operates as a checkbox"""
NORMAL_OPACITY = .5
HOVER_OPACITY = .85
FIRST_ICON = 1000
SECOND_ICON = 2000
checked = Signal(bool)
def __init__(self, firstIcon, secondIcon, parent=None):
super(CheckIconWidget, self).__init__(parent)
self.setMouseTracking(True)
self._mouse_over = False
self._checked = False
self._first_icon = QPixmap(firstIcon)
self._second_icon = QPixmap(secondIcon)
w1, w2 = self._first_icon.width(), self._second_icon.width()
h1, h2 = self._first_icon.height(), self._second_icon.height()
max_w = w1 if w1 > w2 else w2
max_h = h1 if h1 > h2 else h2
# set the size to contain both images, but they should have the same size
self.setFixedSize(max_w, max_h)
def mousePressEvent(self, mpe):
self._checked = not self._checked
self.checked.emit(self._checked)
self.repaint()
def mouseMoveEvent(self, mme):
self._mouse_over = True
self.setCursor(Qt.CursorShape.PointingHandCursor)
self.repaint()
def leaveEvent(self, le):
self._mouse_over = False
self.repaint()
def paintEvent(self, pe):
painter = QPainter(self)
if self._checked:
pixmap = self._second_icon
else:
pixmap = self._first_icon
if self._mouse_over:
painter.setOpacity(self.HOVER_OPACITY)
else:
painter.setOpacity(self.NORMAL_OPACITY)
painter.drawPixmap(0, 0, pixmap)
示例2: paintStartAndFinishLine
# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import height [as 别名]
def paintStartAndFinishLine(self, painter):
start = QPixmap()
start.load('.\\pictures\\start-finish\\start.bmp')
finish = QPixmap()
finish.load('.\\pictures\\start-finish\\finish.bmp')
for y in range(0, self.field.height, start.height()):
painter.drawPixmap(QPoint(self.field.start_line_x, y) + self.field.focus_point, start)
painter.drawPixmap(QPoint(self.field.finish_line_x, y) + self.field.focus_point, finish)
示例3: Ant
# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import height [as 别名]
class Ant():
def __init__(self, name):
self.picture = QPixmap()
self.motion = AntMotion()
self.name = name
self.zombie = False
def width(self):
return self.picture.width()
def height(self):
return self.picture.height()
示例4: tag_image
# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import height [as 别名]
def tag_image(source, dest, tag, font, fontsize, x, y, width, height, aspectx, aspecty, red, green, blue, bold=False, italic=False):
"""docstring for tag_image"""
app = QApplication.instance()
pixmap = QPixmap(source)
color = QColor(red,green,blue)
font = QFont(font)
font.setPixelSize(int(fontsize*pixmap.height()))
font.setItalic(italic)
font.setBold(bold)
painter = QPainter(pixmap)
painter.setPen(color)
painter.setFont(font);
painter.drawText(x*pixmap.width(),y*pixmap.height(), tag)
painter.end()
# Resize and save
return pixmap.toImage().scaled(width*aspectx, height*aspecty, Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation).scaled(width, height, Qt.IgnoreAspectRatio, Qt.SmoothTransformation).save(dest)
示例5: paintEvent
# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import height [as 别名]
def paintEvent(self, event):
painter = QPainter(self)
painter.setBrush(Qt.white)
painter.drawRect(self.rect())
painter.translate(self.width()/2, self.height()/2)
if self.pixReady:
grammarPix = QPixmap("/tmp/grammar.png")
pw = grammarPix.width()
ph = grammarPix.height()
painter.drawPixmap(-pw/2, -ph/2, grammarPix)
示例6: setInfo
# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import height [as 别名]
def setInfo( *args ):
filePath = cmds.textField( Window_global.txf_imagePath, q=1, tx=1 )
pixmap = QPixmap(filePath)
Window_global.imgWidth = pixmap.width()
Window_global.imgHeight = pixmap.height()
cmds.intField( Window_global.intf_imageWidth, e=1, v=Window_global.imgWidth )
cmds.intField( Window_global.intf_imageHeight, e=1, v=Window_global.imgHeight )
planeWidth = cmds.floatField( Window_global.floatf_planeWidth, q=1, v=1 )
planeHeight = planeWidth * float(Window_global.imgWidth) / float(Window_global.imgHeight)
cmds.floatField( Window_global.floatf_planeHeight, e=1, v= planeHeight )
示例7: AntObject
# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import height [as 别名]
class AntObject():
def __init__(self, point=QPoint(0, 0)):
self.picture = QPixmap()
self.point = point
self.enabled = True
def width(self):
return self.picture.width()
def height(self):
return self.picture.height()
def __eq__(self, other):
return self.point == other.point and self.width() == other.width() and self.height() == other.height()
示例8: setLogo
# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import height [as 别名]
def setLogo(self):
"""Sets the company logo in the same place in all views"""
logoPixmap = QPixmap(':/resources/logo.png')
self.iconLabel = QLabel(self)
self.iconLabel.setPixmap(logoPixmap)
self.iconLabel.setGeometry(20, 20, logoPixmap.width(), logoPixmap.height())
self.linkLabel = QLabel(self)
self.linkLabel.setText(
"""<font size="1"><a href="http://www.iqstorage.com/fromiqbox.php">
Developed at IQ Storage FTP Hosing Services</a></font>""")
self.linkLabel.setOpenExternalLinks(True)
# Defines a visual line separator to be placed under the `logoPixmap` `QLabel`
self.line = QFrame()
self.line.setFrameShape(QFrame.HLine);
self.line.setFrameShadow(QFrame.Sunken);
示例9: IconWidget
# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import height [as 别名]
class IconWidget(QWidget):
"""A widget that is clickable, has a fixed size and draws
an icon which changes opacity on hover. Setting a tooltip is recommended"""
clicked = Signal()
def __init__(self, iconPath, hoverOpacity=1, normalOpacity=0.25, parent=None):
super(IconWidget, self).__init__(parent)
self.setMouseTracking(True)
self._icon = QPixmap(iconPath)
self.setFixedSize(QSize(self._icon.width(), self._icon.height()))
self._hover_opacity = hoverOpacity
self._normal_opacity = normalOpacity
self._mouse_over = False # this is correct because when an icon appears after another, it appears where the mouse is
self._enabled = True
def paintEvent(self, pe):
painter = QPainter(self)
icon = QPixmap(self._icon)
icon = icon.scaled(self.size(), Qt.IgnoreAspectRatio)
if not self._mouse_over or not self._enabled:
painter.setOpacity(self._normal_opacity)
else:
painter.setOpacity(self._hover_opacity)
painter.drawPixmap(0, 0, icon)
def mouseMoveEvent(self, mme):
if self._mouse_over: return
self._mouse_over = True
self.setCursor(Qt.CursorShape.PointingHandCursor)
self.repaint()
def leaveEvent(self, le):
self._mouse_over = False
self.repaint()
def mousePressEvent(self, mpe):
self.clicked.emit()
def makeEnabled(self):
self._enabled = True
self.show()
def makeDisabled(self):
self._enabled = False
self.hide()
示例10: MdiArea
# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import height [as 别名]
#.........这里部分代码省略.........
## dx = (rect.width() - bgLogo.width()) / 2 # int
## dy = (rect.height() - bgLogo.height()) / 2 # int
## painter.drawPixmap(dx, dy, bgLogo.width(), bgLogo.height(), bgLogo)
def paintEvent(self, event):
"""
Handles the ``paintEvent`` event for :class:`MdiArea`.
:param `event`: A `QPaintEvent`_ to be processed.
"""
vport = self.viewport()
rect = vport.rect()
painter = QPainter(vport)
painter.setRenderHint(painter.SmoothPixmapTransform)
# Always fill with a solid color first
if self.useColor:
# painter.fillRect(rect, self.colorBrush)
painter.fillRect(rect, self.bgColor)
else:
painter.fillRect(rect, self.background())
# Then overlay the texture
if self.useTexture:
# painter.fillRect(rect, self.backgroundBrush)
bgBrush = QBrush(self.bgTexture)
painter.fillRect(rect, bgBrush)
# Overlay the logo last
if self.useLogo:
if not len(self.subWindowList()): # Nothing is open.
cSizeW, cSizeH = rect.width(), rect.height()
bgLogoW, bgLogoH = self.bgLogo.width(), self.bgLogo.height()
if bgLogoW > cSizeW:
# Proportional Scaling an Image.
newHeight = bgLogoH * cSizeW // bgLogoW
scaledLogo = self.bgLogo.scaled(cSizeW, newHeight)
painter.drawPixmap(0,
cSizeH // 2 - scaledLogo.height() // 2,
scaledLogo)
else:
painter.drawPixmap((cSizeW - bgLogoW) // 2,
(cSizeH - bgLogoH) // 2,
self.bgLogo)
else:
# Center the pixmap
dx = (rect.width() - self.bgLogo.width()) / 2
dy = (rect.height() - self.bgLogo.height()) / 2
painter.drawPixmap(dx, dy,
self.bgLogo.width(), self.bgLogo.height(),
self.bgLogo)
def zoomExtentsAllSubWindows(self):
"""
TOWRITE
"""
for window in self.subWindowList(): # foreach(QMdiSubWindow* window, subWindowList())
mdiWin = window # MdiWindow* mdiWin = qobject_cast<MdiWindow*>(window);
if mdiWin:
v = mdiWin.getView() # View*
if v:
v.recalculateLimits()
v.zoomExtents()
示例11: testQPixmapConstructor
# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import height [as 别名]
def testQPixmapConstructor(self):
label = QLabel()
pixmap1 = QPixmap(xpm)
self.assertFalse(pixmap1.isNull())
self.assertEqual(pixmap1.width(), 27)
self.assertEqual(pixmap1.height(), 22)