Exemplo n.º 1
0
    def __init__(self, editor, layout=None, *args, **kw):
        super(_FilterTableView, self).__init__(editor, *args, **kw)
        # layout = QVBoxLayout()
        # layout.setSpacing(1)
        # self.table = table = _TableView(parent)

        hl = QHBoxLayout()
        # hl.setSpacing(10)
        #
        self.button = button = QPushButton()
        button.setIcon(icon('delete').create_icon())
        button.setEnabled(False)
        button.setFlat(True)
        button.setSizePolicy(QSizePolicy.Fixed,
                             QSizePolicy.Fixed)
        button.setFixedWidth(15)
        button.setFixedHeight(15)

        self.text = text = QLineEdit()
        self.cb = cb = QCheckBox()
        #
        text.setEnabled(False)
        button.setEnabled(False)
        # table.setEnabled(False)
        # cb.setSizePolicy(QSizePolicy.Fixed,
        # QSizePolicy.Fixed)
        # cb.setFixedWidth(20)
        # cb.setFixedHeight(20)
        #
        hl.addWidget(cb)
        hl.addWidget(text)
        hl.addWidget(button)
        layout.addLayout(hl)
Exemplo n.º 2
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))
Exemplo n.º 3
0
    def _dispose_items(self):
        """ Disposes of each current list item.
        """
        layout = self.layout()
        if not layout:
            layout = QHBoxLayout()
            layout.setSpacing(10)
            self.setLayout(layout)
            return

        child = layout.takeAt(0)
        while child is not None:
            control = child.widget()
            if control is not None:
                control.deleteLater()
            child = layout.takeAt(0)
        del child
Exemplo n.º 4
0
    def __init__(self, *args, **kw):
        super(ComboBoxWidget, self).__init__(*args, **kw)

        layout = QHBoxLayout()
        layout.setSpacing(2)
        self.combo = combo = QComboBox()
        combo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
        combo.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed)

        self.button = button = QPushButton()
        button.setEnabled(False)
        button.setIcon(icon('add').create_icon())
        button.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        button.setFixedWidth(20)
        button.setFixedHeight(20)

        layout.addWidget(combo)
        layout.addSpacing(10)
        layout.addWidget(button)
        self.setLayout(layout)
Exemplo n.º 5
0
    def __init__(self, parent, *args, **kw):
        super(QDiffEdit, self).__init__(*args, **kw)
        self.left = LinkedTextEdit()
        self.left.orientation = 'left'
        self.left.setReadOnly(True)

        self.right = LinkedTextEdit()
        self.right.orientation = 'right'
        self.right.setReadOnly(True)

        self.connector = QDiffConnector()

        self.left.linked_widget = self.right
        self.right.linked_widget = self.left
        self.left.connector = self.connector
        self.right.connector = self.connector

        layout = QHBoxLayout()

        layout.setSpacing(0)
        layout.addWidget(self.left)
        layout.addWidget(self.connector)
        layout.addWidget(self.right)
        self.setLayout(layout)