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
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))
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)
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=None): QWidget.__init__(self, parent) layout = QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) self.visualization = Visualization() # If you want to debug, beware that you need to remove the Qt # input hook. #QtCore.pyqtRemoveInputHook() #import pdb ; pdb.set_trace() #QtCore.pyqtRestoreInputHook() # The edit_traits call will generate the widget to embed. self.ui = self.visualization.edit_traits(parent=self, kind='subpanel').control layout.addWidget(self.ui) self.ui.setParent(self)
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)