Python PyQt5.QtCore.Qt 模块,AlignLeft() 实例源码

我们从Python开源项目中,提取了以下33个代码示例,用于说明如何使用PyQt5.QtCore.Qt.AlignLeft()

项目:OpenMineMods    作者:OpenMineMods    | 项目源码 | 文件源码
def __init__(self, curse: CurseAPI):
        super().__init__()

        self.curse = curse

        self.setWindowTitle(translate("title.settings"))

        self.layout = QVBoxLayout(self)

        mmc_box = QGroupBox(translate("label.mmc.location"))
        mmc_layout = QHBoxLayout()

        mmc_box.setLayout(mmc_layout)

        self.mmcDir = QLineEdit(self.curse.baseDir)
        self.mmcDir.setReadOnly(True)
        self.mmcDir.setMinimumWidth(250)
        mmc_layout.addWidget(self.mmcDir, 0, Qt.AlignLeft)

        self.mmcEb = makeIconButton(self, "edit", translate("tooltip.mmc.change"))
        self.mmcEb.clicked.connect(partial(self.browse_clicked))
        mmc_layout.addWidget(self.mmcEb, 0, Qt.AlignRight)

        self.layout.addWidget(mmc_box)

        analytics_box = QGroupBox(translate("label.analytics"))
        analytics_layout = QHBoxLayout()

        analytics_box.setLayout(analytics_layout)

        self.analyticsToggle = QCheckBox()
        self.analyticsToggle.setChecked(self.curse.db["analytics"])
        self.analyticsToggle.setToolTip(translate("tooltip.toggle.analytics"))
        self.analyticsToggle.stateChanged.connect(self.analytics_toggle)
        analytics_layout.addWidget(self.analyticsToggle, 1, Qt.AlignCenter)

        self.layout.addWidget(analytics_box)

        self.show()
项目:gui_tool    作者:UAVCAN    | 项目源码 | 文件源码
def set_row(self, row, model):
        for col, spec in enumerate(self.columns):
            value = spec.render(model)
            color = None
            if isinstance(value, tuple):
                value, color = value
            w = QTableWidgetItem(str(value))
            if color is not None:
                w.setBackground(color)
            w.setTextAlignment(Qt.AlignVCenter | Qt.AlignLeft)
            w.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
            self.setItem(row, col, w)

        self.setRowHidden(row, not self.apply_filter_to_row(row))
项目:Red-GUI    作者:ScarletRav3n    | 项目源码 | 文件源码
def req_ui(self):
        self.clear_layout(self.rbox)
        self.clear_layout(self.hbox)
        self.hbox.addStretch()
        self.l1.setText('Select which requirements to install')

        self.rbox.insertSpacing(1, 35)
        self.r1 = QRadioButton("Install basic + audio requirements (recommended)")
        self.r1.setChecked(True)
        self.r1.setFont(self.reg_font)
        self.rbox.addWidget(self.r1, 0, Qt.AlignTop)
        self.r2 = QRadioButton("Install basic requirements")
        self.r2.setFont(self.reg_font)
        self.rbox.addWidget(self.r2, 0, Qt.AlignLeft)

        if os.path.exists("lib"):
            l5 = QLabel(self)
            l5.setText('<font color="#ff0000">Requirements already installed.</font>')
            self.rbox.addWidget(l5, 1, Qt.AlignBottom)
            b5 = QPushButton("Skip", self)
            b5.setMaximumWidth(50)
            self.rbox.addWidget(b5, 0, Qt.AlignBottom)
            b5.clicked.connect(self.token_ui)

        # buttons
        self.buttons_panel()

        # binds
        self.b1.setEnabled(False)
        self.b2.clicked.connect(self.if_req)
        self.b3.clicked.connect(self.close_prompt)
项目:kaptan    作者:KaOSx    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super().__init__(parent)
        self.setSubTitle(self.tr("<h2>Welcome to KaOS</h2>"))

        vlayout = QVBoxLayout(self)
        vlayout.addItem(QSpacerItem(20, 30, QSizePolicy.Preferred, QSizePolicy.Minimum))

        hlayout = QHBoxLayout(self)
        label = QLabel(self)
        label.setText(self.tr("""<h1>What is KaOS?</h1>
        <p>The idea behind KaOS is to create a tightly integrated rolling and<br />
        transparent distribution for the modern desktop, build from scratch with<br />
        a very specific focus. Focus on one DE (KDE), one toolkit (Qt) & one architecture (x86_64).<br />
        Plus a focus on evaluating and selecting the most suitable tools and applications.</p>
        <p>This wizard will help you personalize your KaOS workspace easily and quickly.</p>
        <p>Please click <code style=color:#3498DB>Next</code> in order to begin. Click <code style=color:#3498DB>Cancel</code> anytime and changes won't be saved.</p>"""))
        label.setWordWrap(True)
        label.setAlignment(Qt.AlignLeft)
        hlayout.addWidget(label)

        kaptan_logo = QLabel(self)
        kaptan_logo.setPixmap(QPixmap(":/data/images/welcome.png"))
        kaptan_logo.setAlignment(Qt.AlignRight)
        kaptan_logo.setMaximumSize(157, 181)
        hlayout.addWidget(kaptan_logo)
        vlayout.addLayout(hlayout)

        vlayout.addItem(QSpacerItem(20, 40, QSizePolicy.Preferred, QSizePolicy.Preferred))

        desktop_file = os.path.join(os.environ["HOME"], ".config", "autostart", "kaptan.desktop")
        if os.path.exists(desktop_file):
            self.checkBox = QCheckBox()
            self.checkBox.setText(self.tr("Run on system startup"))
            self.checkBox.setChecked(True)
            self.checkBox.clicked.connect(self.autoRemove)
            vlayout.addWidget(self.checkBox)
项目:vidcutter    作者:ozmartian    | 项目源码 | 文件源码
def paint(self, painter: QPainter, option: QStyleOptionViewItem, index: QModelIndex) -> None:
        r = option.rect
        pencolor = Qt.white if self.theme == 'dark' else Qt.black
        if self.parent.isEnabled():
            if option.state & QStyle.State_Selected:
                painter.setBrush(QColor(150, 190, 78, 150))
            elif option.state & QStyle.State_MouseOver:
                painter.setBrush(QColor(227, 212, 232))
                pencolor = Qt.black
            else:
                brushcolor = QColor(79, 85, 87, 175) if self.theme == 'dark' else QColor('#EFF0F1')
                painter.setBrush(Qt.transparent if index.row() % 2 == 0 else brushcolor)
        painter.setPen(Qt.NoPen)
        painter.drawRect(r)
        thumb = QIcon(index.data(Qt.DecorationRole + 1))
        starttime = index.data(Qt.DisplayRole + 1)
        endtime = index.data(Qt.UserRole + 1)
        externalPath = index.data(Qt.UserRole + 2)
        r = option.rect.adjusted(5, 0, 0, 0)
        thumb.paint(painter, r, Qt.AlignVCenter | Qt.AlignLeft)
        painter.setPen(QPen(pencolor, 1, Qt.SolidLine))
        r = option.rect.adjusted(110, 8, 0, 0)
        painter.setFont(QFont('Noto Sans UI', 10 if sys.platform == 'darwin' else 8, QFont.Bold))
        painter.drawText(r, Qt.AlignLeft, 'FILENAME' if len(externalPath) else 'START')
        r = option.rect.adjusted(110, 20, 0, 0)
        painter.setFont(QFont('Noto Sans UI', 11 if sys.platform == 'darwin' else 9, QFont.Normal))
        if len(externalPath):
            painter.drawText(r, Qt.AlignLeft, self.clipText(os.path.basename(externalPath), painter))
        else:
            painter.drawText(r, Qt.AlignLeft, starttime)
        if len(endtime) > 0:
            r = option.rect.adjusted(110, 45, 0, 0)
            painter.setFont(QFont('Noto Sans UI', 10 if sys.platform == 'darwin' else 8, QFont.Bold))
            painter.drawText(r, Qt.AlignLeft, 'RUNTIME' if len(externalPath) else 'END')
            r = option.rect.adjusted(110, 60, 0, 0)
            painter.setFont(QFont('Noto Sans UI', 11 if sys.platform == 'darwin' else 9, QFont.Normal))
            painter.drawText(r, Qt.AlignLeft, endtime)
        if self.parent.verticalScrollBar().isVisible():
            self.parent.setFixedWidth(210)
        else:
            self.parent.setFixedWidth(190)
项目:deen    作者:takeshixx    | 项目源码 | 文件源码
def _process_row(self, y, row):
        cols = self.columnCount()
        for x, i in enumerate(range(0, len(row), self._width)):
            block = row[i:i+self._width]
            item = QTableWidgetItem(codecs.encode(block, 'hex').decode())
            item.setBackground(QBrush(QColor('lightgray')))
            item.setForeground(QBrush(QColor('black')))
            item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
            item.setData(Qt.UserRole, block)  # store original data
            if self._read_only:
                item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
            else:
                item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)
            self.setItem(y, x, item)

        # process remaining, unfilled cells
        for j in range(x+1, cols):
            item = QTableWidgetItem()
            item.setBackground(QBrush(QColor('white')))
            item.setFlags(Qt.NoItemFlags)
            item.setTextAlignment(Qt.AlignHCenter)
            self.setItem(y, j, item)

        text = self._bytes_to_ascii(row)
        item = QTableWidgetItem(text)
        item.setData(Qt.UserRole, row)  # store original data
        item.setTextAlignment(Qt.AlignLeft| Qt.AlignVCenter)
        item.setBackground(QBrush(QColor('lightblue')))
        item.setForeground(QBrush(QColor('black')))
        if self._read_only:
            item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
        else:
            item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)
        self.setItem(y, cols - 1, item)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def __init__(self, title, parent):
        super(DetailsDialog, self).__init__(parent)

        self.items = ("T-shirt", "Badge", "Reference book", "Coffee cup")

        nameLabel = QLabel("Name:")
        addressLabel = QLabel("Address:")
        addressLabel.setAlignment(Qt.AlignLeft | Qt.AlignTop)

        self.nameEdit = QLineEdit()
        self.addressEdit = QTextEdit()
        self.offersCheckBox = QCheckBox(
                "Send information about products and special offers:")

        self.setupItemsTable()

        buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)

        buttonBox.accepted.connect(self.verify)
        buttonBox.rejected.connect(self.reject)

        mainLayout = QGridLayout()
        mainLayout.addWidget(nameLabel, 0, 0)
        mainLayout.addWidget(self.nameEdit, 0, 1)
        mainLayout.addWidget(addressLabel, 1, 0)
        mainLayout.addWidget(self.addressEdit, 1, 1)
        mainLayout.addWidget(self.itemsTable, 0, 2, 2, 1)
        mainLayout.addWidget(self.offersCheckBox, 2, 1, 1, 2)
        mainLayout.addWidget(buttonBox, 3, 0, 1, 3)
        self.setLayout(mainLayout)

        self.setWindowTitle(title)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def textAlign(self, action):
        if action == self.actionAlignLeft:
            self.textEdit.setAlignment(Qt.AlignLeft | Qt.AlignAbsolute)
        elif action == self.actionAlignCenter:
            self.textEdit.setAlignment(Qt.AlignHCenter)
        elif action == self.actionAlignRight:
            self.textEdit.setAlignment(Qt.AlignRight | Qt.AlignAbsolute)
        elif action == self.actionAlignJustify:
            self.textEdit.setAlignment(Qt.AlignJustify)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def alignmentChanged(self, alignment):
        if alignment & Qt.AlignLeft:
            self.actionAlignLeft.setChecked(True)
        elif alignment & Qt.AlignHCenter:
            self.actionAlignCenter.setChecked(True)
        elif alignment & Qt.AlignRight:
            self.actionAlignRight.setChecked(True)
        elif alignment & Qt.AlignJustify:
            self.actionAlignJustify.setChecked(True)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def alignmentChanged(self, index):
        if index == 0:
            self.alignmentLineEdit.setAlignment(Qt.AlignLeft)
        elif index == 1:
            self.alignmentLineEdit.setAlignment(Qt.AlignCenter)
        elif index == 2:
            self.alignmentLineEdit.setAlignment(Qt.AlignRight)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def updateFormatsTable(self, mimeData=None):
        self.formatsTable.setRowCount(0)

        if mimeData is None:
            return

        for format in mimeData.formats():
            formatItem = QTableWidgetItem(format)
            formatItem.setFlags(Qt.ItemIsEnabled)
            formatItem.setTextAlignment(Qt.AlignTop | Qt.AlignLeft)

            if format == 'text/plain':
                text = mimeData.text().strip()
            elif format == 'text/html':
                text = mimeData.html().strip()
            elif format == 'text/uri-list':
                text = " ".join([url.toString() for url in mimeData.urls()])
            else:
                text = " ".join(["%02X" % ord(datum) for datum in mimeData.data(format)])

            row = self.formatsTable.rowCount()
            self.formatsTable.insertRow(row)
            self.formatsTable.setItem(row, 0, QTableWidgetItem(format))
            self.formatsTable.setItem(row, 1, QTableWidgetItem(text))

        self.formatsTable.resizeColumnToContents(0)
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def __init__(self, title, parent):
        super(DetailsDialog, self).__init__(parent)

        self.items = ("T-shirt", "Badge", "Reference book", "Coffee cup")

        nameLabel = QLabel("Name:")
        addressLabel = QLabel("Address:")
        addressLabel.setAlignment(Qt.AlignLeft | Qt.AlignTop)

        self.nameEdit = QLineEdit()
        self.addressEdit = QTextEdit()
        self.offersCheckBox = QCheckBox(
                "Send information about products and special offers:")

        self.setupItemsTable()

        buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)

        buttonBox.accepted.connect(self.verify)
        buttonBox.rejected.connect(self.reject)

        mainLayout = QGridLayout()
        mainLayout.addWidget(nameLabel, 0, 0)
        mainLayout.addWidget(self.nameEdit, 0, 1)
        mainLayout.addWidget(addressLabel, 1, 0)
        mainLayout.addWidget(self.addressEdit, 1, 1)
        mainLayout.addWidget(self.itemsTable, 0, 2, 2, 1)
        mainLayout.addWidget(self.offersCheckBox, 2, 1, 1, 2)
        mainLayout.addWidget(buttonBox, 3, 0, 1, 3)
        self.setLayout(mainLayout)

        self.setWindowTitle(title)
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def textAlign(self, action):
        if action == self.actionAlignLeft:
            self.textEdit.setAlignment(Qt.AlignLeft | Qt.AlignAbsolute)
        elif action == self.actionAlignCenter:
            self.textEdit.setAlignment(Qt.AlignHCenter)
        elif action == self.actionAlignRight:
            self.textEdit.setAlignment(Qt.AlignRight | Qt.AlignAbsolute)
        elif action == self.actionAlignJustify:
            self.textEdit.setAlignment(Qt.AlignJustify)
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def alignmentChanged(self, alignment):
        if alignment & Qt.AlignLeft:
            self.actionAlignLeft.setChecked(True)
        elif alignment & Qt.AlignHCenter:
            self.actionAlignCenter.setChecked(True)
        elif alignment & Qt.AlignRight:
            self.actionAlignRight.setChecked(True)
        elif alignment & Qt.AlignJustify:
            self.actionAlignJustify.setChecked(True)
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def alignmentChanged(self, index):
        if index == 0:
            self.alignmentLineEdit.setAlignment(Qt.AlignLeft)
        elif index == 1:
            self.alignmentLineEdit.setAlignment(Qt.AlignCenter)
        elif index == 2:
            self.alignmentLineEdit.setAlignment(Qt.AlignRight)
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def updateFormatsTable(self, mimeData=None):
        self.formatsTable.setRowCount(0)

        if mimeData is None:
            return

        for format in mimeData.formats():
            formatItem = QTableWidgetItem(format)
            formatItem.setFlags(Qt.ItemIsEnabled)
            formatItem.setTextAlignment(Qt.AlignTop | Qt.AlignLeft)

            if format == 'text/plain':
                text = mimeData.text().strip()
            elif format == 'text/html':
                text = mimeData.html().strip()
            elif format == 'text/uri-list':
                text = " ".join([url.toString() for url in mimeData.urls()])
            else:
                text = " ".join(["%02X" % ord(datum) for datum in mimeData.data(format)])

            row = self.formatsTable.rowCount()
            self.formatsTable.insertRow(row)
            self.formatsTable.setItem(row, 0, QTableWidgetItem(format))
            self.formatsTable.setItem(row, 1, QTableWidgetItem(text))

        self.formatsTable.resizeColumnToContents(0)
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def headerData(self, section, orientation, role=Qt.DisplayRole):
        if role == Qt.DisplayRole and orientation == Qt.Horizontal:
            return self.header_labels[section]
        elif role == Qt.TextAlignmentRole:
            return Qt.AlignLeft

        return super().headerData(section, orientation, role)
项目:FIRST-plugin-ida    作者:vrtadmin    | 项目源码 | 文件源码
def data(self, index, role=Qt.DisplayRole):
                '''The data stored under the given role for the item referred
                to by the index.

                Args:
                    index (:obj:`QtCore.QModelIndex`): Index
                    role (:obj:`Qt.ItemDataRole`): Default :obj:`Qt.DisplayRole`

                Returns:
                    data
                '''
                if role == Qt.DisplayRole:
                    row = self._data[index.row()]
                    if (index.column() == 0) and (type(row) != dict):
                        return row

                    elif index.column() < self.columnCount():
                        if type(row) == dict:
                            if self.header[index.column()] in row:
                                return row[self.header[index.column()]]
                            elif self.header[index.column()].lower() in row:
                                return row[self.header[index.column()].lower()]

                        return row[index.column()]

                    return None

                elif role == Qt.FontRole:
                    return QtGui.QFont().setPointSize(30)

                elif role == Qt.DecorationRole and index.column() == 0:
                    return None

                elif role == Qt.TextAlignmentRole:
                    return Qt.AlignLeft;
项目:kaptan    作者:PisiLinuxNew    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super().__init__(parent)
        self.setSubTitle(self.tr("<h2>Welcome to Pisi Linux!</h2>"))

        vlayout = QVBoxLayout(self)
        vlayout.addItem(QSpacerItem(20, 150, QSizePolicy.Preferred, QSizePolicy.Minimum))

        hlayout = QHBoxLayout(self)
        label = QLabel(self)
        label.setText(self.tr("""<h1>What is Pisi Linux?</h1>
        <p><strong>Pisi Linux</strong> is a reliable, secure, fast and user friendly operating system.</p>
        <p>With Pisi Linux, you can connect to the internet, read your e-mails, work with your office documents,
         watch movies, play music, develop applications, play games and much more!</p>
        <p><strong>Kaptan</strong>,  will help you personalize your Pisi Linux workspace easily and quickly.
         Please click <strong>Next</strong> in order to begin.</p>"""))
        label.setWordWrap(True)
        label.setAlignment(Qt.AlignLeft)
        hlayout.addWidget(label)

        kaptan_logo = QLabel(self)
        kaptan_logo.setScaledContents(True)
        kaptan_logo.setPixmap(QPixmap(":/data/images/kaptan_welcome.svg"))
        kaptan_logo.setAlignment(Qt.AlignRight)
        kaptan_logo.setFixedSize(196, 196)
        hlayout.addWidget(kaptan_logo)
        vlayout.addLayout(hlayout)

        vlayout.addItem(QSpacerItem(20, 40, QSizePolicy.Preferred, QSizePolicy.Preferred))
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def __init__(self, title, parent):
        super(DetailsDialog, self).__init__(parent)

        self.items = ("T-shirt", "Badge", "Reference book", "Coffee cup")

        nameLabel = QLabel("Name:")
        addressLabel = QLabel("Address:")
        addressLabel.setAlignment(Qt.AlignLeft | Qt.AlignTop)

        self.nameEdit = QLineEdit()
        self.addressEdit = QTextEdit()
        self.offersCheckBox = QCheckBox(
                "Send information about products and special offers:")

        self.setupItemsTable()

        buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)

        buttonBox.accepted.connect(self.verify)
        buttonBox.rejected.connect(self.reject)

        mainLayout = QGridLayout()
        mainLayout.addWidget(nameLabel, 0, 0)
        mainLayout.addWidget(self.nameEdit, 0, 1)
        mainLayout.addWidget(addressLabel, 1, 0)
        mainLayout.addWidget(self.addressEdit, 1, 1)
        mainLayout.addWidget(self.itemsTable, 0, 2, 2, 1)
        mainLayout.addWidget(self.offersCheckBox, 2, 1, 1, 2)
        mainLayout.addWidget(buttonBox, 3, 0, 1, 3)
        self.setLayout(mainLayout)

        self.setWindowTitle(title)
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def textAlign(self, action):
        if action == self.actionAlignLeft:
            self.textEdit.setAlignment(Qt.AlignLeft | Qt.AlignAbsolute)
        elif action == self.actionAlignCenter:
            self.textEdit.setAlignment(Qt.AlignHCenter)
        elif action == self.actionAlignRight:
            self.textEdit.setAlignment(Qt.AlignRight | Qt.AlignAbsolute)
        elif action == self.actionAlignJustify:
            self.textEdit.setAlignment(Qt.AlignJustify)
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def alignmentChanged(self, alignment):
        if alignment & Qt.AlignLeft:
            self.actionAlignLeft.setChecked(True)
        elif alignment & Qt.AlignHCenter:
            self.actionAlignCenter.setChecked(True)
        elif alignment & Qt.AlignRight:
            self.actionAlignRight.setChecked(True)
        elif alignment & Qt.AlignJustify:
            self.actionAlignJustify.setChecked(True)
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def alignmentChanged(self, index):
        if index == 0:
            self.alignmentLineEdit.setAlignment(Qt.AlignLeft)
        elif index == 1:
            self.alignmentLineEdit.setAlignment(Qt.AlignCenter)
        elif index == 2:
            self.alignmentLineEdit.setAlignment(Qt.AlignRight)
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def updateFormatsTable(self, mimeData=None):
        self.formatsTable.setRowCount(0)

        if mimeData is None:
            return

        for format in mimeData.formats():
            formatItem = QTableWidgetItem(format)
            formatItem.setFlags(Qt.ItemIsEnabled)
            formatItem.setTextAlignment(Qt.AlignTop | Qt.AlignLeft)

            if format == 'text/plain':
                text = mimeData.text().strip()
            elif format == 'text/html':
                text = mimeData.html().strip()
            elif format == 'text/uri-list':
                text = " ".join([url.toString() for url in mimeData.urls()])
            else:
                text = " ".join(["%02X" % ord(datum) for datum in mimeData.data(format)])

            row = self.formatsTable.rowCount()
            self.formatsTable.insertRow(row)
            self.formatsTable.setItem(row, 0, QTableWidgetItem(format))
            self.formatsTable.setItem(row, 1, QTableWidgetItem(text))

        self.formatsTable.resizeColumnToContents(0)
项目:echolocation    作者:hgross    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super().__init__(parent)

        width, height = 800, 800
        self.setGeometry(width, height, width, height)

        # configs, can be changed at runtime
        self.circle_line_color = Qt.gray
        self.crosshair_line_color = Qt.gray
        self.text_label_color = Qt.darkGreen
        self.measured_distances_color = Qt.green
        self.circle_count = 10
        self.dot_width = 10
        self.line_width = 1
        self.distance_measurement_angle = 15
        self.measurement_angle = 10  # degrees that one sensor covers
        self.fade_out_time = 4  # older measurements will fade out over this time
        self.add_text_labels = False

        # data
        self.measurements = []
        self.added_time = dict()  # measurement -> timestamp

        # drawing timer
        self.timer = QTimer()
        self.timer.setInterval(80)
        self.timer.timeout.connect(self.draw_radar)
        self.timer.start()

        # internal canvas setup
        self.layout = QHBoxLayout()
        self.setLayout(self.layout)
        self.scene = QGraphicsScene()
        self.scene.setSceneRect(0, 0, width, height)
        self.canvas = QGraphicsView()
        self.canvas.setRenderHint(QPainter.Antialiasing)
        self.canvas.setFixedSize(width, height)
        self.canvas.setAlignment(Qt.AlignLeft)
        self.canvas.setScene(self.scene)
        self.canvas.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.canvas.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.layout.addWidget(self.canvas)

        # initial rendering
        self.draw_radar()
项目:Red-GUI    作者:ScarletRav3n    | 项目源码 | 文件源码
def init_ui(self):

        # v.box
        box = QVBoxLayout()
        box.setSpacing(5)
        box2 = QHBoxLayout()

        l1 = QLabel('Update', self)
        l1.setFont(QtGui.QFont("Times", 12))
        box.addWidget(l1, 0, Qt.AlignHCenter)
        # box.insertSpacing(1, 10)

        l2 = QLabel("Red:", self)
        box.addWidget(l2, 0, Qt.AlignLeft)
        self.r1 = QRadioButton("Update Red + Requirements \n(recommended)")
        self.r1.setChecked(True)
        box.addWidget(self.r1, 0, Qt.AlignLeft)
        self.r2 = QRadioButton("Update Red")
        box.addWidget(self.r2, 0, Qt.AlignLeft)
        self.r3 = QRadioButton("Update Requirements")
        box.addWidget(self.r3, 0, Qt.AlignLeft)
        # box.insertSpacing(1, 10)

        l3 = QLabel("Others:", self)
        box.addWidget(l3, 0, Qt.AlignLeft)
        self.r4 = QRadioButton("Update PIP \n(Might require admin privileges)")
        box.addWidget(self.r4, 0, Qt.AlignLeft)
        # box.insertSpacing(1, 10)

        b1 = QPushButton("OK", self)
        b1.setMinimumWidth(100)
        box2.addWidget(b1, 0, Qt.AlignBottom)
        b2 = QPushButton("Cancel", self)
        b2.setMinimumWidth(100)
        box2.addWidget(b2, 0, Qt.AlignBottom)

        box.setAlignment(Qt.AlignHCenter)
        box.addLayout(box2)
        self.setLayout(box)

        # binds
        b1.clicked.connect(self.ok_clicked)
        b2.clicked.connect(self.switchwindow)

        # window
        self.setFixedSize(220, 210)
        self.setWindowIcon(QtGui.QIcon('red.ico'))
        self.setWindowTitle('Red Bot - Update')
        self.show()
项目:Red-GUI    作者:ScarletRav3n    | 项目源码 | 文件源码
def init_ui(self):

        # v.box
        box = QVBoxLayout()
        box.setSpacing(5)
        box2 = QHBoxLayout()

        l1 = QLabel('Red Requirements', self)
        l1.setFont(QtGui.QFont("Times", 12))
        box.addWidget(l1, 0, Qt.AlignHCenter)
        # box.insertSpacing(1, 10)

        l2 = QLabel("Main Requirements", self)
        box.addWidget(l2, 0, Qt.AlignLeft)
        self.r1 = QRadioButton("Install basic + audio requirements \n(recommended)")
        self.r1.setChecked(True)
        box.addWidget(self.r1, 0, Qt.AlignLeft)
        self.r2 = QRadioButton("Install basic requirements")
        box.addWidget(self.r2, 0, Qt.AlignLeft)
        # box.insertSpacing(1, 10)

        l3 = QLabel("FFMPEG (required for audio)", self)
        box.addWidget(l3, 0, Qt.AlignLeft)
        self.r3 = QRadioButton("Install ffmpeg 32bit")
        box.addWidget(self.r3, 0, Qt.AlignLeft)
        self.r4 = QRadioButton("Install ffmpeg 64bit")
        box.addWidget(self.r4, 0, Qt.AlignLeft)
        # box.insertSpacing(1, 10)

        b1 = QPushButton("OK", self)
        b1.setMinimumWidth(100)
        box2.addWidget(b1, 0, Qt.AlignBottom)
        b2 = QPushButton("Cancel", self)
        b2.setMinimumWidth(100)
        box2.addWidget(b2, 0, Qt.AlignBottom)

        box.setAlignment(Qt.AlignHCenter)
        box.addLayout(box2)
        self.setLayout(box)

        # binds
        b1.clicked.connect(self.ok_clicked)
        b2.clicked.connect(self.switchwindow)

        # window
        self.setFixedSize(220, 210)
        self.setWindowIcon(QtGui.QIcon('red.ico'))
        self.setWindowTitle('Red Bot - Requirements')
        self.show()
项目:Red-GUI    作者:ScarletRav3n    | 项目源码 | 文件源码
def init_ui(self):

        # v.box
        box = QVBoxLayout()
        box.setSpacing(5)
        box2 = QHBoxLayout()

        l1 = QLabel('Maintenance', self)
        l1.setFont(QtGui.QFont("Times", 12))
        box.addWidget(l1, 0, Qt.AlignHCenter)
        # box.insertSpacing(1, 10)

        l2 = QLabel("Repair:", self)
        box.addWidget(l2, 0, Qt.AlignLeft)
        self.r1 = QRadioButton("Repair Red \n(discards code changes, keeps data intact)")
        self.r1.setChecked(True)
        box.addWidget(self.r1, 0, Qt.AlignLeft)
        self.r2 = QRadioButton("Wipe 'data' folder \n(all settings, cogs' data...)")
        box.addWidget(self.r2, 0, Qt.AlignLeft)
        self.r3 = QRadioButton("Wipe 'lib' folder \n(all local requirements / local installed python packages)")
        box.addWidget(self.r3, 0, Qt.AlignLeft)
        self.r4 = QRadioButton("Factory reset")
        box.addWidget(self.r4, 0, Qt.AlignLeft)
        # box.insertSpacing(1, 10)

        b1 = QPushButton("OK", self)
        b1.setMaximumWidth(100)
        box2.addWidget(b1, 0, Qt.AlignBottom)
        b2 = QPushButton("Cancel", self)
        b2.setMaximumWidth(100)
        box2.addWidget(b2, 0, Qt.AlignBottom)

        box.setAlignment(Qt.AlignHCenter)
        box.addLayout(box2)
        self.setLayout(box)

        # binds
        b1.clicked.connect(self.ok_clicked)
        b2.clicked.connect(self.switchwindow)

        # window
        self.setFixedSize(320, 210)
        self.setWindowIcon(QtGui.QIcon('red.ico'))
        self.setWindowTitle('Red Bot - Maintenance')
        self.show()
项目:gpvdm    作者:roderickmackenzie    | 项目源码 | 文件源码
def __init__(self,parent):
        QToolBar.__init__(self)

        #aaa=self.readStyleSheet(os.path.join(get_css_path(),"menu.css"))
        #aaa=str(aaa,'utf-8')
        #self.setStyleSheet(aaa)

        self.setToolButtonStyle( Qt.ToolButtonTextBesideIcon)
        self.setOrientation(Qt.Vertical)
        #self.setWindowFlags(Qt.FramelessWindowHint|Qt.WindowStaysOnTopHint|Qt.WindowStaysOnTopHint)
        self.setIconSize(QSize(42, 42))

        self.configure_configwindow = QAction(QIcon_load("help"), _("Help window"), self)
        self.addAction(self.configure_configwindow)

        self.configure_configwindow = QAction(QIcon_load("help"), _("Manual"), self)
        self.addAction(self.configure_configwindow)

        self.configure_configwindow = QAction(QIcon_load("help"), _("License"), self)
        self.addAction(self.configure_configwindow)

        self.configure_configwindow = QAction(QIcon_load("help"), _("Youtube"), self)
        self.addAction(self.configure_configwindow)

        self.configure_configwindow = QAction(QIcon_load("help"), _("Citing the model"), self)
        self.addAction(self.configure_configwindow)

        self.configure_configwindow = QAction(QIcon_load("help"), _("About"), self)
        self.addAction(self.configure_configwindow)

        l=self.layout()
        for i in range(0,l.count()):
            l.itemAt(i).setAlignment(Qt.AlignLeft)


        self.installEventFilter(self)
        self.setWindowFlags(Qt.Popup)

        self.move(self.mapFromGlobal(QCursor.pos()))
项目:ovirt-desktop-client    作者:nkovacne    | 项目源码 | 文件源码
def initUI(self):
        """
            Description: Simply shows the dialog
            Arguments: None
            Returns: Nothing
        """

        global conf

        self.resize(450, 150)

        # About image
        filename = 'imgs/about.png'
        image = QImage(filename)
        imageLabel = QLabel()
        imageLabel.setPixmap(QPixmap.fromImage(image))
        imageLabel.setAlignment(Qt.AlignCenter)

        # Labels for info
        lab_appname = QLabel("<font color='#0000FF'>" + _('apptitle') + ' ' + VERSION + "</font>")
        lab_appname.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        lab_desc = QLabel(_('appdesc'))
        lab_desc.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        lab_desc.setWordWrap(True)
        lab_author = QLabel(_('written_by') + ' nKn (<a href=\'http://github.com/nkovacne\'>http://github.com/nkovacne</a>)')
        lab_author.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        lab_unoff = QLabel('<b>' + _('unofficial_project') + '</b>')
        lab_unoff.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        lab_unoff.setWordWrap(True)

        # OK button
        okButton = QPushButton(_("ok"))
        okButton.setMaximumWidth(100)
        okButton.setDefault(True)
        okButton.clicked.connect(self.done)

        # Grid layout with all the elements
        grid = QGridLayout()

        grid.addWidget(imageLabel, 1, 0, 4, 1)               # About image

        grid.addWidget(lab_appname, 1, 1, 1, 2)              # Several QLabels
        grid.addWidget(lab_desc, 2, 1, 1, 2)
        grid.addWidget(lab_author, 3, 1, 1, 2)
        grid.addWidget(lab_unoff, 4, 1, 1, 2)

        grid.addWidget(okButton, 6, 1)                       # Button

        self.setLayout(grid) 

        self.setModal(True)
        self.center()
        self.setWindowTitle(_('about'))
        self.show()
项目:srpdfcrawler    作者:DeastinY    | 项目源码 | 文件源码
def __init__(self, parent=None, title='', animation_duration=300):
        """
        References:
            # Adapted from c++ version
            http://stackoverflow.com/questions/32476006/how-to-make-an-expandable-collapsable-section-widget-in-qt
        """
        super(GroupWidget, self).__init__(parent=parent)

        self.animation_duration = animation_duration
        self.toggle_animation = QParallelAnimationGroup()
        self.content_area = QScrollArea()
        self.header_line = QFrame()
        self.toggle_button = QToolButton()
        self.main_layout = QGridLayout()

        toggle_button = self.toggle_button
        toggle_button.setStyleSheet("QToolButton { border: none; }")
        toggle_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        toggle_button.setArrowType(Qt.RightArrow)
        toggle_button.setText(str(title))
        toggle_button.setCheckable(True)
        toggle_button.setChecked(False)

        header_line = self.header_line
        header_line.setFrameShape(QFrame.HLine)
        header_line.setFrameShadow(QFrame.Sunken)
        header_line.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)

        self.content_area.setStyleSheet("QScrollArea { background-color: white; border: none; }")
        self.content_area.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
        # start out collapsed
        self.content_area.setMaximumHeight(0)
        self.content_area.setMinimumHeight(0)
        # let the entire widget grow and shrink with its content
        toggle_animation = self.toggle_animation
        toggle_animation.addAnimation(QPropertyAnimation(self, bytes("minimumHeight", "utf-8")))
        toggle_animation.addAnimation(QPropertyAnimation(self, bytes("maximumHeight", "utf-8")))
        toggle_animation.addAnimation(QPropertyAnimation(self.content_area, bytes("maximumHeight", "utf-8")))
        # don't waste space
        main_layout = self.main_layout
        main_layout.setVerticalSpacing(0)
        main_layout.setContentsMargins(0, 0, 0, 0)
        row = 0
        main_layout.addWidget(self.toggle_button, row, 0, 1, 1, Qt.AlignLeft)
        main_layout.addWidget(self.header_line, row, 2, 1, 1)
        row += 1
        main_layout.addWidget(self.content_area, row, 0, 1, 3)
        self.setLayout(self.main_layout)

        def start_animation(checked):
            arrow_type = Qt.DownArrow if checked else Qt.RightArrow
            direction = QAbstractAnimation.Forward if checked else QAbstractAnimation.Backward
            toggle_button.setArrowType(arrow_type)
            self.toggle_animation.setDirection(direction)
            self.toggle_animation.start()

        self.toggle_button.clicked.connect(start_animation)
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def initUI(self):
        """
        Initialize the Dialog layout.
        """
        self.setWindowTitle(B3_LICENSE)
        self.setFixedSize(GEOMETRY[b3.getPlatform()]['LICENSE_DIALOG_WIDTH'],
                          GEOMETRY[b3.getPlatform()]['LICENSE_DIALOG_HEIGHT'])
        self.setStyleSheet("""
        QDialog {
            background: #F2F2F2;
        }
        """)

        def __get_top_layout(parent):
            message = """
            %(COPYRIGHT)s<br/>
            <br/>
            This program is free software; you can redistribute it and/or modify
            it under the terms of the GNU General Public License as published by
            the Free Software Foundation; either version 2 of the License, or
            (at your option) any later version.<br/>
            <br/>
            This program is distributed in the hope that it will be useful,
            but WITHOUT ANY WARRANTY; without even the implied warranty of
            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
            GNU General Public License for more details.<br/>
            <br/>
            You should have received a copy of the GNU General Public License along
            with this program; if not, write to the Free Software Foundation, Inc.,
            51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
            """ % dict(COPYRIGHT=B3_COPYRIGHT)
            label = QLabel(message, parent)
            label.setWordWrap(True)
            label.setOpenExternalLinks(True)
            label.setAlignment(Qt.AlignLeft)
            layout = QHBoxLayout()
            layout.addWidget(label)
            layout.setAlignment(Qt.AlignTop)
            layout.setContentsMargins(0, 0, 0, 0)
            return layout

        def __get_bottom_layout(parent):
            btn_close = Button(parent=parent, text='Close')
            btn_close.clicked.connect(parent.close)
            btn_close.setVisible(True)
            layout = QHBoxLayout()
            layout.addWidget(btn_close)
            layout.setAlignment(Qt.AlignHCenter|Qt.AlignTop)
            layout.setContentsMargins(0, 20, 0, 0)
            return layout

        main_layout = QVBoxLayout()
        main_layout.addLayout(__get_top_layout(self))
        main_layout.addLayout(__get_bottom_layout(self))
        self.setLayout(main_layout)
        self.setModal(True)
项目:FIRST-plugin-ida    作者:vrtadmin    | 项目源码 | 文件源码
def data(self, index, role):
                if not index.isValid():
                    return None

                if not (0 <= index.row() < self.rowCount()):
                    return None

                elif role == Qt.FontRole:
                    return QtGui.QFont().setPointSize(30)

                elif role == Qt.DecorationRole and index.column() == 0:
                    return None

                elif role == Qt.TextAlignmentRole:
                    return Qt.AlignLeft;

                #   Color background
                if role == Qt.BackgroundRole:
                    function = self._data[index.row()]

                    #   Row is selected
                    if index.row() in self.rows_selected:
                        return FIRST.color_selected

                    #   Data has been updated since original
                    if function.has_changed:
                        return FIRST.color_changed

                    #
                    if function.id is not None:
                        return FIRST.color_unchanged

                    #   Return the default color
                    return FIRST.color_default

                if role == Qt.DisplayRole:
                    function = self._data[index.row()]

                    column = index.column()
                    if 0 == column:
                        return '0x{0:X}'.format(function.address)

                    elif 1 == column:
                        return function.name

                    elif 2 == column:
                        return function.prototype

                    elif 3 == column:
                        return function.comment

                    return None

                return super(FIRST.Model.Upload, self).data(index, role)