Ejemplo n.º 1
0
    def _init_ui(self, txt):
        self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.FramelessWindowHint)

        pal = QPalette()
        color = QColor()
        color.setNamedColor(self._window_bgcolor)
        color.setAlpha(255 * self._opacity)
        pal.setColor(QPalette.Background, color)

        self.setAutoFillBackground(True)
        self.setPalette(pal)

        wm, hm = 5, 5
        spacing = 8
        layout = QVBoxLayout()
        layout.setSpacing(spacing)
        layout.setContentsMargins(wm, hm, wm, hm)

        nlines, ts = self._generate_text(txt)

        qlabel = QLabel('\n'.join(ts))

        ss = 'QLabel {{color: {}; font-family:{}, sans-serif; font-size: {}px}}'.format(self._color,
                                                                                        self._font,
                                                                                        self._fontsize)
        qlabel.setStyleSheet(ss)
        layout.addWidget(qlabel)

        hlabel = QLabel('double click to dismiss')
        hlabel.setStyleSheet('QLabel {font-size: 10px}')

        hlayout = QHBoxLayout()

        hlayout.addStretch()
        hlayout.addWidget(hlabel)
        hlayout.addStretch()

        layout.addLayout(hlayout)

        self.setLayout(layout)

        font = QFont(self._font, self._fontsize)
        fm = QFontMetrics(font)

        pw = max([fm.width(ti) for ti in ts])
        ph = (fm.height() + 2) * nlines

        w = pw + wm * 2
        h = ph + (hm + spacing + 1) * 2

        self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.setFixedWidth(w)
        self.setFixedHeight(h)

        self.setMask(mask(self.rect(), 10))
Ejemplo n.º 2
0
 def _create_control(self, parent):
     label = QLabel()
     width, height = self.item.width, self.item.height
     if self.item.width != -1.0:
         label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
         label.setFixedWidth(abs(width))
         label.setFixedHeight(abs(height))
     return label
Ejemplo n.º 3
0
    def _create_control(self, parent):
        layout = QVBoxLayout()
        pb = QProgressBar()

        self._message_control = QLabel()
        self._message_control.setText('     ')
        layout.addWidget(self._message_control)
        layout.addWidget(pb)

        return pb
Ejemplo n.º 4
0
    def _create_control(self, parent):
        control = QLabel()
        bgcolor = None
        if self.item.use_color_background:
            bgcolor = self.item.bgcolor.name()
        self._set_style(color=self.item.color.name(),
                        bgcolor=bgcolor,
                        control=control)

        control.setMargin(5)
        parent.setSpacing(0)

        return control
Ejemplo n.º 5
0
    def __init__(self, text):
        super(GosubPopupWidget, self).__init__()
        self.setWindowFlags(Qt.ToolTip)
        layout = QVBoxLayout()

        if text:
            self.text = QPlainTextEdit()
            self.text.setPlainText(text)

        else:
            self.text = QLabel('Invalid Gosub')
            self.text.setStyleSheet('QLabel {color: green; font-size: 30px}')

        layout.addWidget(self.text)
        self.setLayout(layout)
        self.resize(500, 300)
Ejemplo n.º 6
0
    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)