def _create_control(self): ctrl = QGraphicsView() ctrl.setRenderHints(QPainter.Antialiasing) scene = QGraphicsScene() ctrl.setScene(scene) scene.setBackgroundBrush(QBrush(QColor(237, 237, 237))) ctrl.setStyleSheet("border: 0px") w, h = 150, 150 ctrl.setMinimumHeight(h + 22) ctrl.setMinimumWidth(w + 22) cx, cy = w / 2, h / 2. ex, ey = cx, cy + 20 pen = QPen() pen.setStyle(Qt.NoPen) # pen.setColor(QColor(237, 237, 237)) bounding_rect = scene.addRect(0, 0, w, h, pen=pen) bounding_rect.setFlag(QGraphicsItem.ItemClipsChildrenToShape) self.animation = QSequentialAnimationGroup() self._add_laser_logo(scene, bounding_rect, ex, ey, cx, cy, w, h) self._add_bullet(scene, bounding_rect,ex, ey, cx, cy) self._add_fragments(scene, bounding_rect, ex, ey) self.animation.setLoopCount(-1) return ctrl
def _create_control(self): ctrl = QGraphicsView() ctrl.setRenderHints(QPainter.Antialiasing) scene = QGraphicsScene() ctrl.setScene(scene) scene.setBackgroundBrush(QBrush(QColor(237, 237, 237))) ctrl.setStyleSheet("border: 0px") w, h = 150, 150 ctrl.setMinimumHeight(h + 22) ctrl.setMinimumWidth(w + 22) cx, cy = w / 2, h / 2. ex, ey = cx, cy + 20 pen = QPen() pen.setStyle(Qt.NoPen) # pen.setColor(QColor(237, 237, 237)) bounding_rect = scene.addRect(0, 0, w, h, pen=pen) bounding_rect.setFlag(QGraphicsItem.ItemClipsChildrenToShape) self.animation = QSequentialAnimationGroup() self._add_laser_logo(scene, bounding_rect, ex, ey, cx, cy, w, h) self._add_bullet(scene, bounding_rect, ex, ey, cx, cy) self._add_fragments(scene, bounding_rect, ex, ey) self.animation.setLoopCount(-1) return ctrl
def _create_control(self): ctrl = QGraphicsView() scene = QGraphicsScene() ctrl.setScene(scene) scene.setBackgroundBrush(QBrush(QColor(237, 237, 237))) ctrl.setStyleSheet("border: 0px") md = self._dimension * 3 + self._spacing * 4 ctrl.setMaximumWidth(md) ctrl.setMaximumHeight(md) layout = QVBoxLayout() layout.addWidget(ctrl) self._scene = scene self.control = QWidget() self.control.setLayout(layout)
def init(self, parent): """ """ rad = self.factory.radius if not rad: rad = 20 if self.control is None: scene = QGraphicsScene() # system background color scene.setBackgroundBrush(QBrush(QColor(237, 237, 237))) x, y = 10, 10 cx = x + rad / DIAMETER_SCALAR cy = y + rad / DIAMETER_SCALAR self.colors = [QColor(ci) for ci in self.factory.colors] brush = get_gradient(self.colors[self.value], cx, cy, rad / 2) pen = QPen() pen.setWidth(0) self._led_ellipse = scene.addEllipse(x, y, rad, rad, pen=pen, brush=brush) ctrl = LEDGraphicsView(rad, scene) layout = QVBoxLayout() layout.addWidget(ctrl) layout.setAlignment(ctrl, Qt.AlignHCenter) if self.factory.label: txt = QLabel(self.factory.label) layout.addWidget(txt) layout.setAlignment(txt, Qt.AlignHCenter) self.control = QWidget() self.control.setLayout(layout)