本文整理汇总了Python中PyQt5.Qt.QTransform.map方法的典型用法代码示例。如果您正苦于以下问题:Python QTransform.map方法的具体用法?Python QTransform.map怎么用?Python QTransform.map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QTransform
的用法示例。
在下文中一共展示了QTransform.map方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PdfEngine
# 需要导入模块: from PyQt5.Qt import QTransform [as 别名]
# 或者: from PyQt5.Qt.QTransform import map [as 别名]
#.........这里部分代码省略.........
return False
return True
def end_page(self, is_last_page=False):
if self.current_page_inited:
self.pdf.restore_stack()
drop_page = is_last_page and not self.content_written_to_current_page
self.pdf.end_page(drop_page=drop_page)
self.current_page_inited = False
self.current_page_num += 0 if drop_page else 1
return self.content_written_to_current_page
def end(self):
try:
self.end_page()
self.pdf.end()
except:
self.errors(traceback.format_exc())
self.errors_occurred = True
return False
finally:
self.pdf = self.file_object = None
return True
def type(self):
return QPaintEngine.Pdf
def add_image(self, img, cache_key):
if img.isNull():
return
return self.pdf.add_image(img, cache_key)
@store_error
def drawTiledPixmap(self, rect, pixmap, point):
self.content_written_to_current_page = 'drawTiledPixmap'
self.apply_graphics_state()
brush = QBrush(pixmap)
bl = rect.topLeft()
color, opacity, pattern, do_fill = self.graphics.convert_brush(
brush, bl-point, 1.0, self.pdf_system,
self.painter().transform())
self.pdf.save_stack()
self.pdf.apply_fill(color, pattern)
self.pdf.draw_rect(bl.x(), bl.y(), rect.width(), rect.height(),
stroke=False, fill=True)
self.pdf.restore_stack()
@store_error
def drawPixmap(self, rect, pixmap, source_rect):
self.content_written_to_current_page = 'drawPixmap'
self.apply_graphics_state()
source_rect = source_rect.toRect()
pixmap = (pixmap if source_rect == pixmap.rect() else
pixmap.copy(source_rect))
image = pixmap.toImage()
ref = self.add_image(image, pixmap.cacheKey())
if ref is not None:
self.pdf.draw_image(rect.x(), rect.y(), rect.width(),
rect.height(), ref)
@store_error
def drawImage(self, rect, image, source_rect, flags=Qt.AutoColor):
self.content_written_to_current_page = 'drawImage'
self.apply_graphics_state()
source_rect = source_rect.toRect()
image = (image if source_rect == image.rect() else
示例2: update
# 需要导入模块: from PyQt5.Qt import QTransform [as 别名]
# 或者: from PyQt5.Qt.QTransform import map [as 别名]
def update(self):
restant = 360
i = 0
#self.my_scene.clear()
for item in self.pie_items :
self.my_scene.removeItem(item)
self.pie_items = []
self.scene().setSceneRect(QRectF(0,0,self.frameSize().width(),self.frameSize().height()))
#print ('size',self.scene().sceneRect())
#proxy = QGraphicsProxyWidget ()
for item in self.data :
if (i==len(self.data)-1 ):
angle = restant
else:
try :
angle = int(360*item[self.c_box.currentText()]/self.total_value[self.c_box.currentText()])
except ZeroDivisionError:
angle = 0
ellipse = Section(0,0,self.size_pie.width(),self.size_pie.height())
y = (self.parent().size().height()-self.size_pie.height())/2.0
x_pie = ((self.parent().size().width()/2.0)-self.size_pie.height())/2.0
ellipse.setPos(x_pie,y)
ellipse.setStartAngle(16*(360-restant))
ellipse.setSpanAngle(angle*16)
ellipse.setBrush(item['color'])
self.my_scene.addItem(ellipse)
self.pie_items.append(ellipse)
# text pourcentage a afficher dans les portions de disque
try :
v = (item[self.c_box.currentText()]/self.total_value[self.c_box.currentText()])*100
except ZeroDivisionError :
v = 0
text = QGraphicsSimpleTextItem("{0:5.2f}".format(v)+"%")
trans = QTransform().translate(x_pie+self.size_pie.width()/2.0,y+self.size_pie.height()/2.0).rotate(((360-restant)+angle/2.0)*-1)
pts = trans.map(QPointF(self.size_pie.width()/3.0,0))
text.setPos(pts.x(),pts.y())
self.my_scene.addItem(text)
self.pie_items.append(text)
#libelle
rect = QGraphicsRectItem(0,0,10,10)
x = x_pie + self.size_pie.width()+ self.space
interval_height = (self.parent().size().height()-self.margin['top']-self.margin['bottom'])/(len(self.data)+1)
rect.setPos(QPointF(x,self.margin['top']+((i+1)*interval_height)))
rect.setBrush(item['color'])
self.my_scene.addItem(rect)
self.pie_items.append(rect)
text = QGraphicsSimpleTextItem(item['label']+ " ("+str(int(item[self.c_box.currentText()]))+")")
pts = rect.pos()
transform = QTransform().translate(30, 0)
pts = transform.map(pts)
text.setPos(pts)
self.my_scene.addItem(text)
self.pie_items.append(text)
restant = restant - angle
i +=1
# self.fitInView(self.scene.sceneRect())
示例3: update
# 需要导入模块: from PyQt5.Qt import QTransform [as 别名]
# 或者: from PyQt5.Qt.QTransform import map [as 别名]
def update(self):
i = 0
#self.my_scene.clear()
for item in self.histo_items :
self.my_scene.removeItem(item)
self.histo_items = []
self.scene().setSceneRect(QRectF(0,0,self.frameSize().width(),self.frameSize().height()))
max = -1
for value in self.data.values():
if value[self.c_box.currentText()] > max:
max = value[self.c_box.currentText()]
size_text_number = QGraphicsTextItem(str(max)).boundingRect().width()+10
interval= self.parent().size().height()-self.margin['top']-self.margin['bottom']
interval = interval /len(self.data)
temp = "aaaaaaaaaaaaaaaaa"
if len(temp)> self.max_length_text:
data = temp[:self.max_length_text]+"."
else :
data = temp
self.size_text_width = QGraphicsTextItem(data).boundingRect().width()+10
#print ('width:',self.size_text_width)
horizontal_size = self.parent().size().width()- self.margin['left']- self.margin['right']-self.size_text_width- size_text_number
try:
ratio = horizontal_size/ max
except ZeroDivisionError :
ratio = 0
i = 0
for groupe,value in zip(self.data.keys(),self.data.values()) :
if self.c_box.currentText() == "warrior":
title_str = 'Nombre de Heros'
bar_all = QGraphicsRectItem(0,self.margin['top'],value['warrior']*ratio,interval*0.8)
bar_all.setPos(self.size_text_width,interval*0.2+(i*interval))
gradient = QLinearGradient(QPointF(bar_all.rect().width()/2,0),QPointF(bar_all.rect().width()/2,bar_all.rect().height()+self.margin['top']))
gradient.setColorAt(0,QColor('white'))
gradient.setColorAt(1,QColor('red'))
brush = QBrush(gradient)
#brush.setTexture(QPixmap(":/textures/"+groupe.attribs['color']))
bar_all.setBrush(brush)
self.my_scene.addItem(bar_all)
self.histo_items.append(bar_all)
bar_alive = QGraphicsRectItem(0,self.margin['top'],value['alive']*ratio,interval*0.8)
bar_alive.setPos(self.size_text_width,interval*0.2+(i*interval))
gradient = QLinearGradient(QPointF(bar_alive.rect().width()/2,0),QPointF(bar_alive.rect().width()/2,bar_alive.rect().height()+self.margin['top']))
# gradient.setStart(QPointF(0.5,0))
# gradient.setStop(QPointF(0.5,1))
gradient.setColorAt(0,QColor('white'))
gradient.setColorAt(1,QColor('green'))
brush = QBrush(gradient)
bar_alive.setBrush(brush)
self.my_scene.addItem(bar_alive)
self.histo_items.append(bar_alive)
text_nb_warriors= QGraphicsTextItem(str(value['warrior']))
text_nb_warriors.setDefaultTextColor(QColor('green'))
trans = QTransform().translate(bar_all.pos().x()+bar_all.rect().width()+10,interval*0.2+(i*interval)+self.margin['top'])
pts = trans.map(QPointF(0,0.0))
text_nb_warriors.setPos(pts.x(),pts.y())
self.my_scene.addItem(text_nb_warriors)
self.histo_items.append(text_nb_warriors)
#bar ranl
elif self.c_box.currentText()== "rank":
title_str = "Rank Moyen"
bar_rank = QGraphicsRectItem(0,self.margin['top'],value['rank']*ratio,interval*0.8)
bar_rank.setPos(self.size_text_width, interval*0.2+(i*interval))
gradient = QLinearGradient(QPointF(bar_rank.rect().width()/2,0),QPointF(bar_rank.rect().width()/2,bar_rank.rect().height()+self.margin['top']))
# gradient.setStart(QPointF(0.5,0))
# gradient.setStop(QPointF(0.5,1))
gradient.setColorAt(0,QColor('white'))
gradient.setColorAt(1,QColor('red'))
brush = QBrush(gradient)
bar_rank.setBrush(brush)
self.my_scene.addItem(bar_rank)
self.histo_items.append(bar_rank)
# value
text_rank = QGraphicsTextItem("{0:1.1f}".format(value['rank']))
text_rank.setDefaultTextColor(QColor('red'))
trans = QTransform().translate(bar_rank.pos().x()+bar_rank.rect().width()+10,interval*0.2+(i*interval)+self.margin['top'])
pts = trans.map(QPointF(0,0.0))
text_rank.setPos(pts.x(),pts.y())
self.my_scene.addItem(text_rank)
self.histo_items.append(text_rank)
else:
#.........这里部分代码省略.........