本文整理匯總了Python中PyQt4.QtCore.QRectF方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QRectF方法的具體用法?Python QtCore.QRectF怎麽用?Python QtCore.QRectF使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt4.QtCore
的用法示例。
在下文中一共展示了QtCore.QRectF方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: readFromXMLNode
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRectF [as 別名]
def readFromXMLNode(self, correctionNode):
if not correctionNode.tag == 'correction':
return
typeNode = correctionNode.find('type')
self.type = int(typeNode.text)
annotationNode = correctionNode.find('annotation')
self.annotation = annotationNode.text
bboxNode = correctionNode.find('bbox')
x = float(bboxNode.find('x').text)
y = float(bboxNode.find('y').text)
width = float(bboxNode.find('width').text)
height = float(bboxNode.find('height').text)
self.bbox = QtCore.QRectF(x,y,width,height)
# Append the information to a node of an XML file
# Creates an object node with all children and appends to the given node
# Usually the given node is the root
示例2: drawHZ
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRectF [as 別名]
def drawHZ(self,qp):
qp.resetTransform()
w = self.width()
h = self.height()
defaultCol = QColor(0,255,0, 200)
top = 50
bottom = h-50
width, height = w*0.2, 22
dist = 10
space = height+dist
pos = width/4
for i,k in enumerate(self.hzDisplay.hz.keys()):
t = self.hzDisplay.hz[k][1]
v = self.hzDisplay.hz[k][0]
if t<0:
self.drawBar(qp, QRectF(pos, top+space*(6+i), width,height), QColor(128,128,128,200), k+' OFF', 0, 0, 1)
else:
self.drawBar(qp, QRectF(pos, top+space*(6+i), width,height), defaultCol, k+': %5.1fhz'%v, v, 0, t)
示例3: generatePicture
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRectF [as 別名]
def generatePicture(self):
## pre-computing a QPicture object allows paint() to run much more quickly,
## rather than re-drawing the shapes every time.
self.picture = QtGui.QPicture()
p = QtGui.QPainter(self.picture)
p.setPen(pg.mkPen(color='w', width=0.4)) # 0.4 means w*2
# w = (self.data[1][0] - self.data[0][0]) / 3.
w = 0.2
for (t, open, close, min, max) in self.data:
p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max))
if open > close:
p.setBrush(pg.mkBrush('g'))
else:
p.setBrush(pg.mkBrush('r'))
p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open))
p.end()
示例4: setImage
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRectF [as 別名]
def setImage(self, image):
""" Set the scene's current image pixmap to the input QImage or QPixmap.
Raises a RuntimeError if the input image has type other than QImage or QPixmap.
:type image: QImage | QPixmap
"""
if type(image) is QPixmap:
pixmap = image
elif type(image) is QImage:
pixmap = QPixmap.fromImage(image)
else:
raise RuntimeError("ImageViewer.setImage: Argument must be a QImage or QPixmap.")
if self.hasImage():
self._pixmapHandle.setPixmap(pixmap)
else:
self._pixmapHandle = self.scene.addPixmap(pixmap)
self.setSceneRect(QRectF(pixmap.rect())) # Set scene size to image size.
self.updateViewer()
示例5: generatePicture
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRectF [as 別名]
def generatePicture(self):
## pre-computing a QPicture object allows paint() to run much more quickly,
## rather than re-drawing the shapes every time.
self.picture = QtGui.QPicture()
p = QtGui.QPainter(self.picture)
p.setPen(pg.mkPen(color='r', width=0.4)) # 0.4 means w*2
# w = (self.data[1][0] - self.data[0][0]) / 3.
w = 0.2
for (t, open, close, min, max) in self.data:
p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max))
if open > close:
p.setBrush(pg.mkBrush('g'))
else:
p.setBrush(pg.mkBrush('r'))
p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open))
p.end()
示例6: paintEvent
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRectF [as 別名]
def paintEvent(self, event):
painter = QtGui.QPainter(self)
painter.setRenderHints(QtGui.QPainter.Antialiasing)
painter.fillRect(QtCore.QRectF(50, 50, 200, 200), QtGui.QBrush(QtGui.QColor(QtGui.QColor(110, 110, 110))))
painter.fillRect(QtCore.QRectF(50, 50, 200, 200), QtGui.QBrush(QtCore.Qt.CrossPattern))
painter.setPen(QtGui.QPen(QtGui.QColor(QtCore.Qt.lightGray), 2, QtCore.Qt.SolidLine))
path = QtGui.QPainterPath()
path.moveTo(50, 250)
path.cubicTo(self.points[0][0], self.points[0][1], self.points[1][0], self.points[1][1], 250, 50)
painter.drawPath(path)
painter.setBrush(QtGui.QBrush(QtGui.QColor(QtCore.Qt.darkCyan)))
painter.setPen(QtGui.QPen(QtGui.QColor(QtCore.Qt.lightGray), 1))
#for x, y in pts:
painter.drawEllipse(QtCore.QRectF(self.points[0][0] - 4, self.points[0][1] - 4, 8, 8))
painter.drawEllipse(QtCore.QRectF(self.points[1][0] - 4, self.points[1][1] - 4, 8, 8))
painter.setPen(QtGui.QPen(QtGui.QColor(QtCore.Qt.white), 1))
label1 = "("+ str((self.points[0][0] - 50)/2) + "," + str(100 - ((self.points[0][1] -50)/2)) + ")"
painter.drawText(self.points[0][0] -25, self.points[0][1] + 18, QtCore.QString(label1))
label2 = "("+ str((self.points[1][0] - 50)/2) + "," + str(100 - ((self.points[1][1] -50)/2)) + ")"
painter.drawText(self.points[1][0] -25, self.points[1][1] + 18, QtCore.QString(label2))
示例7: mouseMoveEvent
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRectF [as 別名]
def mouseMoveEvent(self,event):
if self.image.isNull() or self.w == 0 or self.h == 0:
return
self.updateMousePos( event.posF() )
if not self.config.correctionMode:
# If we are dragging a point, update
if self.draggedPt >= 0:
# Update the dragged point
self.drawPoly.replace( self.draggedPt , self.mousePosScaled )
# If the polygon is the polygon of the selected object,
# update the object polygon and
# keep track of the changes we do
if self.selObjs:
obj = self.annotation.objects[self.selObjs[-1]]
obj.polygon[self.draggedPt] = Point(self.mousePosScaled.x(),self.mousePosScaled.y())
# Check if we changed the object's polygon the first time
if not obj.id in self.changedPolygon:
self.changedPolygon.append(obj.id)
self.addChange( "Changed polygon of object {0} with label {1}".format( obj.id, obj.label ) )
else:
if self.in_progress_bbox is not None:
p0 = (self.mousePosScaled.x(), self.mousePosScaled.y())
p1 = (self.mousePressEvent.x(), self.mousePressEvent.y())
xy = min(p0[0], p1[0]), min(p0[1], p1[1])
w, h = abs(p0[0] - p1[0]), abs(p0[1] - p1[1])
self.in_progress_bbox = QtCore.QRectF(xy[0], xy[1], w, h)
#p.set_x(xy[0])
#p.set_y(xy[1])
#p.set_width(w)
#p.set_height(h)
# Update the object selected by the mouse
self.updateMouseObject()
# Redraw
self.update()
# Mouse left the widget
示例8: drawZoom
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRectF [as 別名]
def drawZoom(self,qp,overlay):
# Zoom disabled?
if not self.zoom:
return
# No image
if self.image.isNull() or not self.w or not self.h:
return
# No mouse
if not self.mousePosOrig:
return
# Abbrevation for the zoom window size
zoomSize = self.zoomSize
# Abbrevation for the mouse position
mouse = self.mousePosOrig
# The pixel that is the zoom center
pix = self.mousePosScaled
# The size of the part of the image that is drawn in the zoom window
selSize = zoomSize / ( self.zoomFactor * self.zoomFactor )
# The selection window for the image
sel = QtCore.QRectF(pix.x() -selSize/2 ,pix.y() -selSize/2 ,selSize,selSize )
# The selection window for the widget
view = QtCore.QRectF(mouse.x()-zoomSize/2,mouse.y()-zoomSize/2,zoomSize,zoomSize)
if overlay :
overlay_scaled = overlay.scaled(self.image.width(), self.image.height())
else :
overlay_scaled = QtGui.QImage( self.image.width(), self.image.height(), QtGui.QImage.Format_ARGB32_Premultiplied )
# Show the zoom image
qp.save()
qp.drawImage(view,self.image,sel)
qp.setOpacity(self.transp)
qp.drawImage(view,overlay_scaled,sel)
qp.restore()
# Draw disparities
示例9: drawModeBox
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRectF [as 別名]
def drawModeBox(self, qp, xy, col, txt):
#qp = QtGui.QPainter()
qp.save()
qp.translate(xy)
qp.setBrush(col.dark())
qp.setPen(QPen(col, 0.5, Qt.SolidLine))
qp.setFont(QFont('Monospace', 14, QFont.Monospace))
rh = 11
rw = 20
r=QRectF(-rw,-rh, 2*rw, 2*rh)
qp.drawRect(r)
qp.drawText(r, Qt.AlignCenter, txt)
qp.restore()
示例10: drawBar
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRectF [as 別名]
def drawBar(self, qp, rect, col, txt, val, minVal=0, maxVal=100):
valN = (float(val)-minVal)/(maxVal-minVal)*100.
percent = min(max(valN,0),100)
#qp = QtGui.QPainter()
qp.setBrush(QColor(0,0,0,0))
qp.setPen(col)
qp.drawRect(rect)
qp.setBrush(col.light())
qp.drawText(rect, Qt.AlignCenter, txt)
qp.setBrush(col.dark())
qp.drawRect(QRectF(rect.left(), rect.top(), rect.width()/100.*percent, rect.height()))
示例11: drawStats
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRectF [as 別名]
def drawStats(self, qp):
defaultCol = QColor(0,255,0, 200)
#qp = QtGui.QPainter()
qp.resetTransform()
w = self.width()
h = self.height()
top = 50
bottom = h-50
width, height = w*0.2, 22
dist = 10
space = height+dist
pos = width/4
# DRAW PROGRESS BAGS (left)
if self.bat>-1:
self.drawBar(qp, QRectF(pos, top+space*0, width,height), defaultCol, 'BAT %4.2fV'%(self.bat/1000.), self.bat, 3000, 4150)
if self.link>-1:
self.drawBar(qp, QRectF(pos, top+space*1, width,height), defaultCol, 'SIG %03d%%'%self.link, self.link)
if self.cpu>-1:
self.drawBar(qp, QRectF(pos, top+space*2, width,height), defaultCol, 'CPU %03d%%'%self.cpu, self.cpu)
# DRAW RAW STATS( right)
pos = w-width/4-width/2
space = height+2
if self.pktsOut>-1:
qp.drawText(QRectF(pos, top+space*0, width,height), Qt.AlignLeft, '%04d kb/s'%self.pktsOut)
if self.pktsIn>-1:
qp.drawText(QRectF(pos, top+space*1, width,height), Qt.AlignLeft, '%04d kb/s'%self.pktsIn)
if self.pressure>-1:
qp.drawText(QRectF(pos, top+space*3, width,height), Qt.AlignLeft, '%06.2f hPa'%self.pressure)
if self.temp>-1:
qp.drawText(QRectF(pos, top+space*4, width,height), Qt.AlignLeft, QString('%05.2f'%self.temp)+QChar(0260)+QString("C"))
if self.aslLong>-1:
qp.drawText(QRectF(pos, top+space*5, width,height), Qt.AlignLeft, '%4.2f m'%self.aslLong)
示例12: findRectF
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRectF [as 別名]
def findRectF( self, name ):
from PyQt4.QtCore import QRectF
return self._findRect( name, QRectF, float )
示例13: boundingRect
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRectF [as 別名]
def boundingRect(self):
## boundingRect _must_ indicate the entire area that will be drawn on
## or else we will get artifacts and possibly crashing.
## (in this case, QPicture does all the work of computing the bouning rect for us)
return QtCore.QRectF(self.picture.boundingRect())
#----------------------------------------------------------------------
示例14: mousePressEvent
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRectF [as 別名]
def mousePressEvent(self,e):
x_m,y_m=e.x(),e.y()
self.drawButtonRect=False
if self.state=="normal":
if 15<x_m<self.width-15 and 30<y_m<55:
#open
self.buttonRect=QtCore.QRectF(10,30,self.width-10,30)
self.drawButtonRect=True
elif 15<x_m<self.width-15 and 57<y_m<85:
#move
self.buttonRect=QtCore.QRectF(10,60,self.width-10,30)
self.drawButtonRect=True
elif 15<x_m<self.width-15 and 87<y_m<115:
#remove
self.buttonRect=QtCore.QRectF(10,90,self.width-10,30)
self.drawButtonRect=True
else:
self.drawButtonRect=False
self.buttonRect=None
elif self.state=="moving":
if 35<y_m<80 and self.width/2+35<x_m<self.width/2+75:
self.buttonRect=QtCore.QRectF(self.width/2+35,35,40,40)
self.drawButtonRect=True
if self.height-45<y_m<self.height-5 and self.width/2+35<x_m<self.width/2+75:
self.buttonRect=QtCore.QRectF(self.width/2+35,self.height-45,40,40)
self.drawButtonRect=True
self.update()
示例15: paintEvent
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QRectF [as 別名]
def paintEvent(self, e):
qp=QtGui.QPainter()
qp.begin(self)
qp.setFont(QtGui.QFont(Config.get()["font"],12))
qp.setRenderHint(QtGui.QPainter.Antialiasing)
qp.setPen(QtGui.QColor(250,250,250,0))
qp.setBrush(QtGui.QColor(self.r,self.g,self.b))
qp.drawRoundedRect(QtCore.QRectF(0,0,self.w,self.h),2,2)
#title
if self.drawButtonRect==True and self.buttonRect!=None:
qp.setPen(QtGui.QColor(0,0,0,0))
qp.setBrush(QtGui.QColor(254,254,255,50))
qp.drawRect(self.buttonRect)
textRect=QtCore.QRectF(0,0,self.w,40)
qp.setPen(QtGui.QColor(250,250,250))
if self.state=="logout":
if "XFCE" or "Duck" in os.environ.get("XDG_CURRENT_DESKTOP"):
qp.drawText(textRect,QtCore.Qt.AlignCenter,"Log out from your computer?")
else:
qp.drawText(textRect,QtCore.Qt.AlignCenter,"Sorry, logout is not supported yet..")
i = QtGui.QIcon("/usr/share/duck-launcher/default-theme/logout.svg")
i.paint(qp, self.w/2-40,self.h/2-60,80,80)
if self.state=="restart":
qp.drawText(textRect,QtCore.Qt.AlignCenter,"Restart your computer?")
i = QtGui.QIcon("/usr/share/duck-launcher/default-theme/restart.svg")
i.paint(qp, self.w/2-40,self.h/2-60,80,80)
if self.state=="shutdown":
qp.drawText(textRect,QtCore.Qt.AlignCenter,"Shut down your computer?")
i = QtGui.QIcon("/usr/share/duck-launcher/default-theme/shutdown.svg")
i.paint(qp, self.w/2-40,self.h/2-60,80,80)
##Yes No
qp.drawLine(20,self.h-50, self.w-20,self.h-50)
qp.drawLine(self.w/2, self.h-40, self.w/2,self.h-10)
qp.drawText(QtCore.QRectF(0,self.h-50,self.w/2-6,50),QtCore.Qt.AlignCenter, "No")
qp.drawText(QtCore.QRectF(self.w/2+2,self.h-50,self.w/2,50),QtCore.Qt.AlignCenter, "Yes")