def __init__(self):
super(SortingBox, self).__init__()
self.circlePath = QPainterPath()
self.squarePath = QPainterPath()
self.trianglePath = QPainterPath()
self.shapeItems = []
self.previousPosition = QPoint()
self.setMouseTracking(True)
self.setBackgroundRole(QPalette.Base)
self.itemInMotion = None
self.newCircleButton = self.createToolButton("New Circle",
QIcon(':/images/circle.png'), self.createNewCircle)
self.newSquareButton = self.createToolButton("New Square",
QIcon(':/images/square.png'), self.createNewSquare)
self.newTriangleButton = self.createToolButton("New Triangle",
QIcon(':/images/triangle.png'), self.createNewTriangle)
self.circlePath.addEllipse(0, 0, 100, 100)
self.squarePath.addRect(0, 0, 100, 100)
x = self.trianglePath.currentPosition().x()
y = self.trianglePath.currentPosition().y()
self.trianglePath.moveTo(x + 120 / 2, y)
self.trianglePath.lineTo(0, 100)
self.trianglePath.lineTo(120, 100)
self.trianglePath.lineTo(x + 120 / 2, y)
self.setWindowTitle("Tooltips")
self.resize(500, 300)
self.createShapeItem(self.circlePath, "Circle",
self.initialItemPosition(self.circlePath),
self.initialItemColor())
self.createShapeItem(self.squarePath, "Square",
self.initialItemPosition(self.squarePath),
self.initialItemColor())
self.createShapeItem(self.trianglePath, "Triangle",
self.initialItemPosition(self.trianglePath),
self.initialItemColor())
评论列表
文章目录