Esempio n. 1
1
    def init(self, parent):
        '''

        '''
        if self.control is None:
            self.control = qtLED()
            scene = QGraphicsScene()
            #             self.control.setStyleSheet("qtLED { border-style: none; }");
            #             self.control.setAutoFillBackground(True)

            # system background color
            scene.setBackgroundBrush(QBrush(QColor(237, 237, 237)))
            self.control.setStyleSheet("border: 0px")
            self.control.setMaximumWidth(35)
            self.control.setMaximumHeight(35)

            x, y = 10, 10
            rad = 20
            cx = x + rad / 1.75
            cy = y + rad / 1.75

            brush = self.get_color(self.value.state, cx, cy, rad / 2)
            pen = QPen()
            pen.setWidth(0)
            self.led = scene.addEllipse(x, y, rad, rad,
                                        pen=pen,
                                        brush=brush
            )

            self.control.setScene(scene)

            self.value.on_trait_change(self.update_object, 'state')
Esempio n. 2
0
    def init(self, parent):
        """
        """
        rad = self.factory.radius
        if not rad:
            rad = 20

        if self.control is None:
            self.control = qtLED()
            scene = QGraphicsScene()
            #             self.control.setStyleSheet("qtLED { border-style: none; }");
            #             self.control.setAutoFillBackground(True)

            # system background color
            scene.setBackgroundBrush(QBrush(QColor(237, 237, 237)))
            self.control.setStyleSheet("border: 0px")
            self.control.setMaximumWidth(rad+15)
            self.control.setMaximumHeight(rad+15)

            x, y = 10, 10
            cx = x + rad / 1.75
            cy = y + rad / 1.75

            brush = self.get_color(self.value.state, cx, cy, rad / 2)
            pen = QPen()
            pen.setWidth(0)
            self.led = scene.addEllipse(x, y, rad, rad,
                                        pen=pen,
                                        brush=brush
                                        )

            self.control.setScene(scene)

            self.value.on_trait_change(self.update_object, 'state')
Esempio n. 3
0
    def init(self, parent):
        """
        """
        rad = self.factory.radius
        if not rad:
            rad = 20

        if self.control is None:

            ctrl = qtLED()
            layout = QVBoxLayout()

            layout.addWidget(ctrl)

            scene = QGraphicsScene()
            #             ctrl.setStyleSheet("qtLED { border-style: none; }");
            #             ctrl.setAutoFillBackground(True)

            # system background color
            scene.setBackgroundBrush(QBrush(QColor(237, 237, 237)))
            ctrl.setStyleSheet("border: 0px")
            ctrl.setMaximumWidth(rad + 15)
            ctrl.setMaximumHeight(rad + 15)

            x, y = 10, 10
            cx = x + rad / 1.75
            cy = y + rad / 1.75

            brush = self.get_color(self.value.state, cx, cy, rad / 2)
            pen = QPen()
            pen.setWidth(0)
            self.led = scene.addEllipse(x, y, rad, rad,
                                        pen=pen,
                                        brush=brush)

            if self.factory.label:
                txt = QLabel(self.factory.label)
                layout.addWidget(txt)
                layout.setAlignment(txt, Qt.AlignHCenter)
                # txt = scene.addText(self.factory.label, QFont('arial 6'))
                # txt.setPos(cx, 10)

            ctrl.setScene(scene)

            layout.setAlignment(ctrl, Qt.AlignHCenter)

            self.value.on_trait_change(self.update_object, 'state')

            self.control = QWidget()
            self.control.setLayout(layout)
Esempio n. 4
0
    def init(self, parent):
        """
        """
        rad = self.factory.radius
        if not rad:
            rad = 20

        if self.control is None:

            ctrl = qtLED()
            layout = QVBoxLayout()

            layout.addWidget(ctrl)

            scene = QGraphicsScene()
            #             ctrl.setStyleSheet("qtLED { border-style: none; }");
            #             ctrl.setAutoFillBackground(True)

            # system background color
            scene.setBackgroundBrush(QBrush(QColor(237, 237, 237)))
            ctrl.setStyleSheet("border: 0px")
            ctrl.setMaximumWidth(rad + 15)
            ctrl.setMaximumHeight(rad + 15)

            x, y = 10, 10
            cx = x + rad / 1.75
            cy = y + rad / 1.75

            brush = self.get_color(self.value.state, cx, cy, rad / 2)
            pen = QPen()
            pen.setWidth(0)
            self.led = scene.addEllipse(x, y, rad, rad, pen=pen, brush=brush)

            if self.factory.label:
                txt = QLabel(self.factory.label)
                layout.addWidget(txt)
                layout.setAlignment(txt, Qt.AlignHCenter)
                # txt = scene.addText(self.factory.label, QFont('arial 6'))
                # txt.setPos(cx, 10)

            ctrl.setScene(scene)

            layout.setAlignment(ctrl, Qt.AlignHCenter)

            self.value.on_trait_change(self.update_object, 'state')

            self.control = QWidget()
            self.control.setLayout(layout)