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


Python QPainter.drawEllipse方法代码示例

本文整理汇总了Python中PySide.QtGui.QPainter.drawEllipse方法的典型用法代码示例。如果您正苦于以下问题:Python QPainter.drawEllipse方法的具体用法?Python QPainter.drawEllipse怎么用?Python QPainter.drawEllipse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PySide.QtGui.QPainter的用法示例。


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

示例1: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawEllipse [as 别名]
	def paintEvent(self, ev):
		if self.isEnabled():
			color = self.color
			colorBorder = [0.4, 0.4, 0.4]
		else:
			color = [0.8, 0.8, 0.8]
			colorBorder = [0.7, 0.7, 0.7]

		painter = QPainter(self)
		painter.setRenderHint(QPainter.Antialiasing)
		painter.setRenderHint(QPainter.HighQualityAntialiasing)

		if self.isChecked():
			pen = QPen(QColor.fromRgbF(0.2, 0.2, 0.2))
			pen.setWidth(2.0)
		else:
			pen = QPen(QColor.fromRgbF(colorBorder[0], colorBorder[1], colorBorder[2]))
			pen.setWidth(1.0)

		size = self.size()
		sizeCircle = 12.0
		x = size.width() / 2.0 - (sizeCircle / 2.0)
		y = size.height() / 2.0 - (sizeCircle / 2.0)
		rect = QRectF(x, y, sizeCircle, sizeCircle)
		painter.setPen(pen)
		painter.setBrush(QColor.fromRgbF(color[0], color[1], color[2]))
		painter.drawEllipse(rect)
开发者ID:berendkleinhaneveld,项目名称:Registrationshop,代码行数:29,代码来源:ColorWidget.py

示例2: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawEllipse [as 别名]
 def paintEvent(self, event):
     painter = QPainter()
     painter.begin(self)
     painter.setRenderHint(QPainter.HighQualityAntialiasing)
     painter.setRenderHint(QPainter.Antialiasing)
     painter.setRenderHint(QPainter.SmoothPixmapTransform)
     # change the look for on/off
     if self.isChecked():
         # blue fill
         brush = QBrush(self.color1)
         painter.setBrush(brush)
         painter.drawRoundedRect(0, 7, self.width() - 2, self.height() - 15, self.height() / 2 - 10,
                                 self.height() / 2)
         brush = QBrush(self.lighter(self.color1))
         painter.setBrush(brush)
         painter.drawEllipse(self.width() - self.height(), 0, self.height(), self.height())
     else:
         # gray fill
         brush = QBrush(self.color2)
         painter.setBrush(brush)
         painter.drawRoundedRect(1, 7, self.width() - 3, self.height() - 15, self.height() / 2 - 10,
                                 self.height() / 2)
         brush = QBrush(QColor(100, 100, 100))
         painter.setBrush(brush)
         painter.drawEllipse(0, 0, self.height(), self.height())
     painter.end()
开发者ID:ethanhs,项目名称:material,代码行数:28,代码来源:material.py

示例3: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawEllipse [as 别名]
    def paintEvent(self, event):
        paintRegion = event.region()
        painter = QPainter(self)
        pal = self.palette()

        for shape in self._shapeList:
            rect = shape.rect
            
            if not paintRegion.contains(rect):
                continue
            
            shapeType = shape.type
            
            painter.setBrush(shape.color)
            
            if shapeType == ShapeType.Rectangle:
                print "rectangle"
                painter.drawRect(rect)
            elif shapeType == ShapeType.Circle:
                print "circle"
                painter.drawEllipse(rect)
            
            # paint the shape name
            painter.setBrush(pal.text())
            painter.drawText(rect, Qt.AlignCenter, shape.name)
开发者ID:satishgoda,项目名称:learningqt,代码行数:27,代码来源:document.py

示例4: draw

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawEllipse [as 别名]
    def draw(self, endPoint_x, endPoint_y):
        painter = QPainter(self.image)

        painter.setPen(QPen(
            self.myPenColor, self.myPenWidth, QtCore.Qt.SolidLine,
            QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin))
        painter.setClipping(True)

        painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
        painter.setRenderHint(QPainter.HighQualityAntialiasing, True)
        painter.setRenderHint(QPainter.Antialiasing, True)
        painter.setCompositionMode(QPainter.CompositionMode())

        if self.tools['circle']:
            x1 = self.firstPoint_x
            y1 = self.firstPoint_y
            x2 = endPoint_x
            y2 = endPoint_y
            painter.drawEllipse(x1, y1, (x2 - x1), (y2 - y1))

        if self.tools['eraser']:
            painter.setPen(QPen(QtCore.Qt.white, 10, QtCore.Qt.SolidLine))
            painter.drawLine(
                self.firstPoint_x, self.firstPoint_y, endPoint_x, endPoint_y)
            self.firstPoint_x = endPoint_x
            self.firstPoint_y = endPoint_y

        if self.tools['pen']:
            painter.drawLine(
                self.firstPoint_x, self.firstPoint_y, endPoint_x, endPoint_y)
            self.firstPoint_x = endPoint_x
            self.firstPoint_y = endPoint_y

        if self.tools['line'] and self.flag:
            painter.drawLine(
                self.firstPoint_x, self.firstPoint_y, endPoint_x, endPoint_y)

        if self.tools['rect']:
            dx = endPoint_x - self.firstPoint_x
            dy = endPoint_y - self.firstPoint_y
            painter.drawRect(self.firstPoint_x, self.firstPoint_y, dx, dy)

        if self.tools['roundRect']:
            x1 = self.firstPoint_x
            y1 = self.firstPoint_y
            dx = endPoint_x - self.firstPoint_x
            dy = endPoint_y - self.firstPoint_y
            if x1 > endPoint_x and y1 > endPoint_y:
                painter.drawRoundedRect(
                    endPoint_x, endPoint_y, -dx, -dy, 20, 20, 0)
            else:
                painter.drawRoundedRect(x1, y1, dx, dy, 20., 20.)

        self.modified = True
        self.update()
开发者ID:pouzzler,项目名称:IED-Logic-Simulator,代码行数:57,代码来源:circuitdrawing.py

示例5: drawPreview

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawEllipse [as 别名]
    def drawPreview(self, endPoint_x, endPoint_y):
        painter = QPainter(self.imagePreview)
        painter.setPen(QPen(
            self.myPenColor,
            self.myPenWidth,
            QtCore.Qt.SolidLine,
            QtCore.Qt.RoundCap,
            QtCore.Qt.RoundJoin))
        painter.setClipping(True)

        painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
        painter.setRenderHint(QPainter.HighQualityAntialiasing, True)
        painter.setRenderHint(QPainter.Antialiasing, True)

        painter.setOpacity(0.5)

        if self.tools['circle']:
            x1 = self.firstPoint_x
            y1 = self.firstPoint_y
            x2 = endPoint_x
            y2 = endPoint_y
            painter.drawEllipse(x1, y1, (x2 - x1), (y2 - y1))

        if self.tools['line']:
            painter.drawLine(
                self.firstPoint_x, self.firstPoint_y, endPoint_x, endPoint_y)

        if self.tools['rect']:
            painter.drawRect(
                self.firstPoint_x, self.firstPoint_y,
                endPoint_x - self.firstPoint_x,
                endPoint_y - self.firstPoint_y)

        if self.tools['roundRect']:
            x1 = self.firstPoint_x
            y1 = self.firstPoint_y
            dx = endPoint_x - self.firstPoint_x
            dy = endPoint_y - self.firstPoint_y
            if x1 > endPoint_x and y1 > endPoint_y:
                painter.drawRoundedRect(
                    endPoint_x, endPoint_y, -dx, -dy, 20, 20, 0)
            else:
                painter.drawRoundedRect(x1, y1, dx, dy, 20., 20.)

        self.update()
开发者ID:pouzzler,项目名称:IED-Logic-Simulator,代码行数:47,代码来源:circuitdrawing.py

示例6: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawEllipse [as 别名]
 def paintEvent(self, event):
     """
     This function handles the low level painting of component.
     :param event:
     :return:
     """
     painter = QPainter()
     painter.begin(self)
     painter.setRenderHint(QPainter.Antialiasing)
     if self.__flag == 1:
         painter.end()
         return
     # setting the masking ellipse
     painter.setClipRegion(self.__clip)
     self.__color.setAlpha(self.__maxOpacity)
     painter.setBrush(QBrush(self.__color))
     painter.setPen(QPen(QColor(0, 0, 0, 0)))
     painter.drawEllipse(self.__origin, self.__r, self.__r)
     painter.end()
开发者ID:nicolas-raoul,项目名称:PyMaterial,代码行数:21,代码来源:MRipple.py

示例7: testFromData

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawEllipse [as 别名]
    def testFromData(self):
        picture = QPicture()
        painter = QPainter()
        painter.begin(picture)
        painter.drawEllipse(10, 20, 80, 70)
        painter.end()

        data = picture.data()
        picture2 = QPicture()
        picture2.setData(data)

        self.assertEqual(picture2.data(), picture.data())

        w = MyWidget()
        w._picture = picture2
        w._app = self.app

        QTimer.singleShot(300, w.show)
        self.app.exec_()
开发者ID:holmeschiu,项目名称:PySide,代码行数:21,代码来源:qpicture_test.py

示例8: createPixmapIcon

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawEllipse [as 别名]
    def createPixmapIcon(self):
        self.markerIcon = QPixmap(MARKER_WIDTH, MARKER_HEIGHT)
        self.markerIcon.fill(Qt.transparent)

        painter = QPainter(self.markerIcon)

        p1 = QPoint(MARKER_WIDTH / 2, MARKER_HEIGHT - 1)
        p2 = QPoint(MARKER_WIDTH / 2, MARKER_HEIGHT - 1 - MARKER_PIN_LEN)
        pen = QPen(Qt.black)
        pen.setWidth(2)
        pen.setCosmetic(True)
        painter.setPen(pen)
        painter.drawLine(p1, p2)
        ellipse = QRect(0, 0, MARKER_WIDTH - 1, MARKER_HEIGHT - 1)
        pen.setWidth(1)
        painter.setPen(pen)
        color = QColor(Qt.green)
        color.setAlpha(127)
        brush = QBrush(color)
        painter.setBrush(brush)
        painter.drawEllipse(ellipse)
开发者ID:AmerGit,项目名称:Examples,代码行数:23,代码来源:mapviewer.py

示例9: addUnit

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawEllipse [as 别名]
    def addUnit(self, unit):
        global mapSize
        unit.tile = self
        self.units.append(unit)
        img = QImage(unit.image).scaledToWidth(self.getImageRect().width())
        if unit.owner:
            rect = img.rect()
            painter = QPainter(img)
            painter.setPen(unit.owner.unitColor())
            painter.drawEllipse(rect)

            hpWidth = 20
            greenWidth = unit.hp / float(unit.maxHp) * hpWidth
            painter.fillRect(5, 5, greenWidth, 5, Qt.green)
            painter.fillRect(5 + greenWidth, 5, hpWidth-greenWidth, 5, Qt.red)
            painter.end()
        image = QGraphicsPixmapItem(QPixmap(img), self)
        if mapSize == 0:
            mapSize = 1
        image.setOffset(self.x + 12/(2*mapSize), self.y + 10/(2*mapSize))
        self.unitImages.append(image)
开发者ID:Odingod,项目名称:Vuoropohjainen-peli,代码行数:23,代码来源:Hexagon.py

示例10: import

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawEllipse [as 别名]
from PySide.QtGui import (QApplication, QGraphicsView, QGraphicsScene,
                          QMainWindow, QPixmap, QPainter)
from PySide.QtCore import Qt
import sys

if __name__ == '__main__':
    app = QApplication(sys.argv)
    scene = QGraphicsScene()
    view = QGraphicsView(scene)
    view.scale(15, 15)

    pix = QPixmap(200, 50)
    pix.fill(Qt.white)
    p = QPainter(pix)
    p.setPen(Qt.black)
    #p.setBrush(Qt.red)
    for i in range(1, 10):
        p.drawEllipse(0, 0, i, i)
        p.translate(i+5, 0)
    p.end()
    pixItem = scene.addPixmap(pix)

    win = QMainWindow()
    win.setCentralWidget(view)
    win.resize(700, 200)
    win.show()

    sys.exit(app.exec_())
开发者ID:jthacker,项目名称:arrview,代码行数:30,代码来源:ellipse_test.py


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