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


Python QtGui.QGraphicsPixmapItem类代码示例

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


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

示例1: __init__

 def __init__(self, *args):
       self.seleccionado = False
       self.velocity = random.randint(1,10)
       QGraphicsPixmapItem.__init__(self, *args)
       self.setPixmap(QPixmap("sprites/"+str(random.randint(1,45))+".png"))
       self.setTransformOriginPoint(self.boundingRect().width()/2.0,self.boundingRect().height()/2.0)
       self.setZValue(10)
       ##menu contextual
       self.menu = QMenu()
       self.Actions =[] #arreglo de acciones 
       self.Actions.append( self.menu.addAction("Seguir") )
       self.Actions.append( self.menu.addAction("Editar") )
       self.Actions.append( self.menu.addAction("girar clockwise") )
       self.Actions.append( self.menu.addAction("girar anti-clockwise") )
       self.Actions.append( self.menu.addAction("Colisiones") )
       self.Actions.append( self.menu.addAction("Duplicar") )
       self.Actions.append( self.menu.addAction("Eliminar") )
       self.menu.triggered[QAction].connect(self.test)
       ##offset para el arrastre
       self.offset= QPointF(0,0)
       ##poligono de vision
       poligono = QPolygonF()
       poligono.append(QPointF(-1,10))
       poligono.append(QPointF(-1,20))
       poligono.append(QPointF(-30,40))
       poligono.append(QPointF(-40,15))
       poligono.append(QPointF(-30,-10))
       self.vision = QGraphicsPolygonItem(poligono,self,self.scene())
       self.vision.setBrush(QColor(255, 255, 0,100))
       self.vision.setPen(QColor(255, 255, 0))
开发者ID:nicoyanez,项目名称:integracion4,代码行数:30,代码来源:auto.py

示例2: StartSelectView

class StartSelectView(QGraphicsView):

    def __init__(self, *args):
        QGraphicsView.__init__(self, *args)
        self.move(2, 250)
        self.btnSize = 28
        self.setMaximumHeight(self.btnSize * 2)
        self.setMaximumWidth(334)
        self.setMinimumHeight(self.btnSize * 2)
        self.setMinimumWidth(334)
        self.adjustSize()
        self.scene = QGraphicsScene(self)
        self.setStyleSheet('background-color:transparent; border-width: 0px; border: 0px;')
        self.psButtons = QPixmap(os.getcwd() + '/../icons/controller-sprite.png')
        self.select = self.psButtons.copy(696, 120, 45, 30)
        self.select = self.select.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
        self.selectItem = QGraphicsPixmapItem(self.select)
        self.selectItem.setOffset(QPointF(0, 0))
        self.scene.addItem(self.selectItem)
        self.start = self.psButtons.copy(754, 120, 45, 30)
        self.start = self.start.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
        self.startItem = QGraphicsPixmapItem(self.start)
        self.startItem.setOffset(QPointF(86, 0))
        self.scene.addItem(self.startItem)
        self.setScene(self.scene)
开发者ID:derekisbusy,项目名称:AnyController,代码行数:25,代码来源:custom_widgets.py

示例3: get_shot

    def get_shot(self, x, y):
        '''
        Shot handler.
        :param x: x coord of shot
        :param y: y coord of shot
        '''
        is_Hit = False

        if self.my_board[x][y] == 1:
            self.my_board[x][y] = 2
            is_hit = True
            picture = 'res/ok.png'
        else:
            self.my_board[x][y] = -1
            is_hit = False
            picture = 'res/cancel.png'

        if x % 2 != 0:
            self.item = QGraphicsPixmapItem(QPixmap(picture))
            self.item.setOffset(16+y*61, 17+(x*52))
            self.scene.addItem(self.item)

        elif x % 2 == 0:
            self.item = QGraphicsPixmapItem(QPixmap(picture))
            self.item.setOffset(47+y*61, 16+x*53)
            self.scene.addItem(self.item)
开发者ID:pkprzekwas,项目名称:QtHex,代码行数:26,代码来源:gui_qt.py

示例4: make_move

    def make_move(self):
        if not self.game.is_my_turn:
            x = randint(0, 9)
            y = randint(0, 8)
            if self.game.my_board[x][y] not in range(2,4):
                if self.game.my_board[x][y] == 1:
                    self.game.my_board[x][y] = 2
                    picture = 'res/cancel.png'
                else:
                    self.game.my_board[x][y] = 3
                    picture = 'res/ok.png'

                if x % 2 != 0:
                    self.item = QGraphicsPixmapItem(QPixmap(picture))
                    self.item.setOffset(16+y*61, 17+(x*52))
                    self.game.scene.addItem(self.item)

                elif x % 2 == 0:
                    self.item = QGraphicsPixmapItem(QPixmap(picture))
                    self.item.setOffset(47+y*61, 16+x*53)
                    self.game.scene.addItem(self.item)

            print(self.game.enemies_board)
            print(self.game.my_board)
            self.game.is_my_turn = True
开发者ID:pkprzekwas,项目名称:QtHex,代码行数:25,代码来源:ai.py

示例5: FaceButtonsView

class FaceButtonsView(QGraphicsView):

    def __init__(self, *args):
        QGraphicsView.__init__(self, *args)
        self.move(170, 90)
        self.btnSize = 40
        self.padding = 5
        self.setMaximumHeight(self.btnSize * 4)
        self.setMaximumWidth(self.btnSize * 4)
        self.setMinimumHeight(self.btnSize * 4)
        self.setMinimumWidth(self.btnSize * 4)
        self.adjustSize()
        self.setStyleSheet('background-color:transparent; border-width: 0px; border: 0px;')
        self.scene = QGraphicsScene(self)
        self.psButtons = QPixmap(os.getcwd() + '/../icons/PS3_Buttons.png')
        self.triangle = self.psButtons.copy(0, 0, 220, 225)
        self.triangle = self.triangle.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
        self.square = self.psButtons.copy(220, 0, 220, 225)
        self.square = self.square.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
        self.circle = self.psButtons.copy(440, 0, 220, 225)
        self.circle = self.circle.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
        self.cross = self.psButtons.copy(660, 0, 220, 225)
        self.cross = self.cross.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
        self.triangleItem = QGraphicsPixmapItem(self.triangle)
        self.triangleItem.setOffset(QPointF(self.btnSize + self.padding, 0))
        self.scene.addItem(self.triangleItem)
        self.squareItem = QGraphicsPixmapItem(self.square)
        self.squareItem.setOffset(QPointF(0, self.btnSize + self.padding))
        self.scene.addItem(self.squareItem)
        self.circleItem = QGraphicsPixmapItem(self.circle)
        self.circleItem.setOffset(QPointF(self.btnSize * 2 + self.padding * 2, self.btnSize + self.padding))
        self.scene.addItem(self.circleItem)
        self.crossItem = QGraphicsPixmapItem(self.cross)
        self.crossItem.setOffset(QPointF(self.btnSize + self.padding, self.btnSize * 2 + self.padding * 2))
        self.scene.addItem(self.crossItem)
        self.effect = QGraphicsDropShadowEffect()
        self.effect.setOffset(0, 0)
        self.effect.setBlurRadius(20)
        self.effect.setColor(Qt.green)
        self.triangleItem.setGraphicsEffect(self.effect)
        self.setScene(self.scene)
        self.tl2 = QTimeLine(10000)
        self.tl2.setFrameRange(0, 10000)
        self.t = QGraphicsItemAnimation()
        self.t.setItem(self.triangleItem)
        self.t.setTimeLine(self.tl2)
        self.tl2.connect(self.tl2, SIGNAL('frameChanged(int)'), self.updateEffect)
        self.effectd = 3
        self.tl2.start()

    def updateEffect(self):
        if self.effect.blurRadius() > 50:
            self.effectd = -3
        elif self.effect.blurRadius() < 5:
            self.effectd = 3
        self.effect.setBlurRadius(self.effect.blurRadius() + self.effectd)
开发者ID:derekisbusy,项目名称:AnyController,代码行数:56,代码来源:custom_widgets.py

示例6: DpadView

class DpadView(QGraphicsView):

    def __init__(self, *args):
        QGraphicsView.__init__(self, *args)
        self.move(2, 90)
        self.btnSize = 75
        self.padding = -35
        self.setMaximumHeight(self.btnSize * 2 + 20)
        self.setMaximumWidth(self.btnSize * 2 + 20)
        self.setMinimumHeight(self.btnSize * 2 + 20)
        self.setMinimumWidth(self.btnSize * 2 + 20)
        self.adjustSize()
        self.setStyleSheet('background-color:transparent; border-width: 0px; border: 0px;')
        self.scene = QGraphicsScene(self)
        self.left = QPixmap(os.getcwd() + '/../icons/left.png')
        self.left = self.left.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
        self.right = QPixmap(os.getcwd() + '/../icons/right.png')
        self.right = self.right.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
        self.up = QPixmap(os.getcwd() + '/../icons/up.png')
        self.up = self.up.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
        self.down = QPixmap(os.getcwd() + '/../icons/down.png')
        self.down = self.down.scaled(self.btnSize, self.btnSize, Qt.KeepAspectRatio)
        self.leftItem = QGraphicsPixmapItem(self.left)
        self.leftItem.setOffset(QPointF(0, self.btnSize + self.padding))
        self.scene.addItem(self.leftItem)
        self.rightItem = QGraphicsPixmapItem(self.right)
        self.rightItem.setOffset(QPointF(self.btnSize * 2 + self.padding * 2, self.btnSize + self.padding))
        self.scene.addItem(self.rightItem)
        self.upItem = QGraphicsPixmapItem(self.up)
        self.upItem.setOffset(QPointF(self.btnSize + self.padding, 0))
        self.scene.addItem(self.upItem)
        self.downItem = QGraphicsPixmapItem(self.down)
        self.downItem.setOffset(QPointF(self.btnSize + self.padding, self.btnSize * 2 + self.padding * 2))
        self.scene.addItem(self.downItem)
        self.effect = QGraphicsDropShadowEffect()
        self.effect.setOffset(0, 0)
        self.effect.setBlurRadius(20)
        self.effect.setColor(Qt.green)
        self.downItem.setGraphicsEffect(self.effect)
        self.setScene(self.scene)
        self.tl2 = QTimeLine(10000)
        self.tl2.setFrameRange(0, 10000)
        self.t = QGraphicsItemAnimation()
        self.t.setItem(self.downItem)
        self.t.setTimeLine(self.tl2)
        self.tl2.connect(self.tl2, SIGNAL('frameChanged(int)'), self.updateEffect)
        self.effectd = 3
        self.tl2.start()

    def updateEffect(self):
        if self.effect.blurRadius() > 50:
            self.effectd = -3
        elif self.effect.blurRadius() < 5:
            self.effectd = 3
        self.effect.setBlurRadius(self.effect.blurRadius() + self.effectd)
开发者ID:derekisbusy,项目名称:AnyController,代码行数:55,代码来源:custom_widgets.py

示例7: __init__

 def __init__(self, data, encoding, x0, y0, x1, y1, xsize, ysize):
     p = QPixmap()
     p.loadFromData(data, encoding, Qt.AutoColor)
     w, h = p.width(), p.height()
     p = p.copy(x0, y0, min(w, x1-x0), min(h, y1-y0))
     if p.width() != xsize or p.height() != ysize:
         p = p.scaled(xsize, ysize, Qt.IgnoreAspectRatio, Qt.SmoothTransformation)
     QGraphicsPixmapItem.__init__(self, p)
     self.height, self.width = ysize, xsize
     self.setTransformationMode(Qt.SmoothTransformation)
     self.setShapeMode(QGraphicsPixmapItem.BoundingRectShape)
开发者ID:089git,项目名称:calibre,代码行数:11,代码来源:text.py

示例8: createPixmapItem

 def createPixmapItem(self, pixmap, position, matrix=QMatrix()):
     item = QGraphicsPixmapItem(pixmap)
     item.setFlags(QGraphicsItem.ItemIsSelectable|
                   QGraphicsItem.ItemIsMovable)
     item.setPos(position)
     item.setMatrix(matrix)
     self.scene.clearSelection()
     self.scene.addItem(item)
     item.setSelected(True)
开发者ID:pyros2097,项目名称:SabelIDE,代码行数:9,代码来源:designer.py

示例9: __init__

 def __init__(self, *args):
       QGraphicsPixmapItem.__init__(self, *args)
       self.setPixmap(QPixmap("sprites/calle/centro.png"))
       self.setTransformOriginPoint(self.boundingRect().width()/2.0,self.boundingRect().height()/2.0)
       self.setZValue(1)
       self.menu = QMenu()
       self.Actions =[] #arreglo de acciones 
       self.Actions.append( self.menu.addAction("girar clockwise") )
       self.Actions.append( self.menu.addAction("girar anti-clockwise") )
       self.Actions.append( self.menu.addAction("Duplicar") )
       self.Actions.append( self.menu.addAction("Eliminar") )
       self.menu.triggered[QAction].connect(self.test)
       self.offset=QPointF(0,0)
开发者ID:nicoyanez,项目名称:integracion4,代码行数:13,代码来源:centro.py

示例10: build_ships_from_matrix

    def build_ships_from_matrix(self):
        for x in range(10):
            for y in range(9):
                if self.my_board[x][y] == 1:

                    if x % 2 != 0:
                        self.item = QGraphicsPixmapItem(QPixmap(self.STATEK))
                        self.item.setOffset(18+y*61, 21+(x*52))
                        self.scene.addItem(self.item)

                    elif x % 2 == 0:
                        self.item = QGraphicsPixmapItem(QPixmap(self.STATEK))
                        self.item.setOffset(49+y*61, 21+x*53)
                        self.scene.addItem(self.item)
开发者ID:pkprzekwas,项目名称:QtHex,代码行数:14,代码来源:gui_qt.py

示例11: __mouseReleaseEvent

    def __mouseReleaseEvent(self,event):
        global PIX
        self.drag_stop = event.pos()
        im = PIX.pixmap().toImage()
        
        start, stop = self.mapToScene(self.drag_start),self.mapToScene(self.drag_stop)
        logging.debug((start,stop))

        augmented = QGraphicsPixmapItem(QPixmap(tempfile))
        
        augmented.setOffset(rect.topLeft())
        augmented.setMatrix(QMatrix())
        if None != self.selectbox: self.scene().removeItem(self.selectbox)
        self.selectbox = augmented
        self.scene().addItem(self.selectbox)
开发者ID:onelson,项目名称:petalpicker,代码行数:15,代码来源:app.py

示例12: __init__

 def __init__(self, *args):
     QGraphicsView.__init__(self, *args)
     self.move(20, 240)
     self.outerD = 125
     self.innerD = 35
     self.innerRange = 48
     self.inputRange = 256
     self.thresh = 3
     self.padding = 40
     self.marginTop = 10
     self.worker = QSixAxisThread()
     self.worker.valueUpdated.connect(self.moveJoysticks)
     self.worker.start()
     self.setContentsMargins(0, 0, 0, 0)
     self.setMaximumHeight(180)
     self.setMaximumWidth(420)
     self.setMinimumHeight(240)
     self.setMinimumWidth(300)
     self.adjustSize()
     self.scene = QGraphicsScene(self)
     self.outerCircle1 = QGraphicsEllipseItem(0, self.marginTop, self.outerD, self.outerD)
     self.outerCircle1.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
     self.outerCircle1.setBrush(Qt.gray)
     self.innerCircle1 = QGraphicsEllipseItem(self.outerD / 2 - self.innerD / 2, self.outerD / 2 - self.innerD / 2 + self.marginTop, self.innerD, self.innerD)
     self.innerCircle1.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
     self.innerCircle1.setBrush(Qt.lightGray)
     self.scene.addItem(self.outerCircle1)
     self.scene.addItem(self.innerCircle1)
     self.outerCircle2 = QGraphicsEllipseItem(self.outerD + self.padding, self.marginTop, self.outerD, self.outerD)
     self.outerCircle2.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
     self.outerCircle2.setBrush(Qt.gray)
     self.innerCircle2 = QGraphicsEllipseItem(self.outerD + self.padding + self.outerD / 2 - self.innerD / 2, self.outerD / 2 - self.innerD / 2 + self.marginTop, self.innerD, self.innerD)
     self.innerCircle2.setPen(QPen(QColor(Qt.darkGray), 1, Qt.SolidLine))
     self.innerCircle2.setBrush(Qt.lightGray)
     self.scene.addItem(self.outerCircle2)
     self.scene.addItem(self.innerCircle2)
     self.setScene(self.scene)
     self.setStyleSheet('background-color:transparent; border-width: 0px; border: 0px;')
     self.currentX = 0
     self.currentY = 0
     self.currentA = 0
     self.currentZ = 0
     self.psBtn = QPixmap(os.getcwd() + '/../icons/bt_PS.png')
     self.psBtn = self.psBtn.scaled(50, 50, Qt.KeepAspectRatio)
     self.psItem = QGraphicsPixmapItem(self.psBtn)
     self.psItem.setOffset(QPointF(self.outerD - 4, 0))
     self.effect = QGraphicsDropShadowEffect()
     self.effect.setOffset(0, 0)
     self.effect.setBlurRadius(20)
     self.effect.setColor(Qt.green)
     self.psItem.setGraphicsEffect(self.effect)
     self.scene.addItem(self.psItem)
     self.tl2 = QTimeLine(10000)
     self.tl2.setFrameRange(0, 10000)
     self.c = QGraphicsItemAnimation()
     self.c.setItem(self.psItem)
     self.c.setTimeLine(self.tl2)
     self.tl2.connect(self.tl2, SIGNAL('frameChanged(int)'), self.updateEffect)
     self.effectd = 3
     self.tl2.start()
开发者ID:derekisbusy,项目名称:AnyController,代码行数:60,代码来源:custom_widgets.py

示例13: __init__

 def __init__(self, filename=None, width=None, height=None, x=0, y=0, pixmap=None, group=None, pos=None, size=None, padding=None):
     self.effects = {}
     self.animations = {}
     self.filename = filename if isinstance(filename, str) else None
     if pixmap :
         self.pixmap = pixmap
     elif isinstance(filename, QPixmap) :
         self.pixmap = filename
     elif isinstance(filename, str) :
         self.pixmap = QPixmap(os.path.dirname(__file__) + '/../buttons/' + filename)
     else :
         self.pixmap = None
     if (width != None or height != None) and self.pixmap != None :
         self.pixmap = self.pixmap.scaled(width if width != None else height,
                                  height if height != None else width, Qt.KeepAspectRatio)
     self.group = group
     self.pos = pos
     self.size = size
     self.padding = padding
     self.x = x
     self.y = y
     
     if isinstance(self.pixmap, QPixmap) :
         self.item = QGraphicsPixmapItem(self.pixmap)
         self.item.setOffset(QPointF(self.getX(), self.getY()))
         self.effect = QGraphicsDropShadowEffect()
         self.effect.setOffset(0, 0)
         self.effect.setBlurRadius(0)
         self.effect.setColor(Qt.green)
         self.addEffect('shadow', self.effect, True)
         self.addAnimation('glow', Glow(15, 300, self, maxRadius=80, minRadius=5))
开发者ID:derekisbusy,项目名称:AnyController,代码行数:31,代码来源:widget_sixaxis.py

示例14: build_shots_from_matrix

    def build_shots_from_matrix(self):
        picture = 'res/cancel.png'
        for x in range(10):
            for y in range(9):

                if self.my_board[x][y] == 2 or self.my_board[x][y] == 3:

                    if x % 2 != 0:
                        self.item = QGraphicsPixmapItem(QPixmap(picture))
                        self.item.setOffset(16+y*61, 17+(x*52))
                        self.scene.addItem(self.item)

                    elif x % 2 == 0:
                        self.item = QGraphicsPixmapItem(QPixmap(picture))
                        self.item.setOffset(47+y*61, 16+x*53)
                        self.scene.addItem(self.item)

                self.build_ships_from_matrix()
开发者ID:pkprzekwas,项目名称:QtHex,代码行数:18,代码来源:gui_qt.py

示例15: createPixmapItem

    def createPixmapItem(self, pixmap, matrix=QMatrix()):
        global PIX
        item = QGraphicsPixmapItem(pixmap)
        PIX = item
#        item.setFlags(QGraphicsItem.ItemIsSelectable|
#                      QGraphicsItem.ItemIsMovable)
        item.setMatrix(matrix)
        self.scene.clearSelection()
        
        for i in self.scene.items():
            self.scene.removeItem(i)
        
        self.scene.addItem(item)
        self.view.fitInView(item,Qt.KeepAspectRatio)
        
        
        global DIRTY
        DIRTY = True
开发者ID:onelson,项目名称:petalpicker,代码行数:18,代码来源:app.py


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