コード例 #1
0
    def mousePressEvent(self, event):
        #randomly choose a shape to draw
        shapenum = randint(0, 4)
        if shapenum == 0:
            #information to draw Rectangle
            rect = Shapes.Rectangle(event.x(), event.y())
            self.__shapes.append(rect)

        elif shapenum == 1:
            #information to draw Squares
            square = Shapes.Squares(event.x(), event.y())
            self.__shapes.append(square)

        elif shapenum == 2:
            #information to draw Ellipse
            elpse = Shapes.Ellipses(event.x(), event.y())
            self.__shapes.append(elpse)

        elif shapenum == 3:
            #information to draw Circle
            circle = Shapes.Circles(event.x(), event.y())
            self.__shapes.append(circle)

        elif shapenum == 4:
            #information to draw Triangle
            tri = Shapes.Triangles(event.x(), event.y())
            self.__shapes.append(tri)

        self.update()