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

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

项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super(AddressBook, self).__init__(parent)

        nameLabel = QLabel("Name:")
        self.nameLine = QLineEdit()

        addressLabel = QLabel("Address:")
        self.addressText = QTextEdit()

        mainLayout = QGridLayout()
        mainLayout.addWidget(nameLabel, 0, 0)
        mainLayout.addWidget(self.nameLine, 0, 1)
        mainLayout.addWidget(addressLabel, 1, 0, Qt.AlignTop)
        mainLayout.addWidget(self.addressText, 1, 1)

        self.setLayout(mainLayout)
        self.setWindowTitle("Simple Address Book")
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super(AddressBook, self).__init__(parent)

        nameLabel = QLabel("Name:")
        self.nameLine = QLineEdit()

        addressLabel = QLabel("Address:")
        self.addressText = QTextEdit()

        mainLayout = QGridLayout()
        mainLayout.addWidget(nameLabel, 0, 0)
        mainLayout.addWidget(self.nameLine, 0, 1)
        mainLayout.addWidget(addressLabel, 1, 0, Qt.AlignTop)
        mainLayout.addWidget(self.addressText, 1, 1)

        self.setLayout(mainLayout)
        self.setWindowTitle("Simple Address Book")
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super(AddressBook, self).__init__(parent)

        nameLabel = QLabel("Name:")
        self.nameLine = QLineEdit()

        addressLabel = QLabel("Address:")
        self.addressText = QTextEdit()

        mainLayout = QGridLayout()
        mainLayout.addWidget(nameLabel, 0, 0)
        mainLayout.addWidget(self.nameLine, 0, 1)
        mainLayout.addWidget(addressLabel, 1, 0, Qt.AlignTop)
        mainLayout.addWidget(self.addressText, 1, 1)

        self.setLayout(mainLayout)
        self.setWindowTitle("Simple Address Book")
项目:X-Ray_Calibre_Plugin    作者:szarroug3    | 项目源码 | 文件源码
def update_aliases_on_gui(self):
        '''Updates aliases on the dialog using the info in the book's aliases dict'''
        aliases_widget = QWidget()
        aliases_layout = QGridLayout(aliases_widget)
        aliases_layout.setAlignment(Qt.AlignTop)

        # add aliases for current book
        for index, (character, aliases) in enumerate(sorted(self.book.aliases.items())):
            label = QLabel(character + ':')
            label.setFixedWidth(150)
            aliases_layout.addWidget(label, index, 0)
            line_edit = QLineEdit(', '.join([self.TITLE_CASE(alias) for alias in aliases]))
            line_edit.setFixedWidth(350)
            line_edit.textEdited.connect(functools.partial(self.edit_aliases, character))
            aliases_layout.addWidget(line_edit, index, 1)

        self._scroll_area.setWidget(aliases_widget)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super(AddressBook, self).__init__(parent)

        self.contacts = SortedDict()
        self.oldName = ''
        self.oldAddress = ''

        nameLabel = QLabel("Name:")
        self.nameLine = QLineEdit()
        self.nameLine.setReadOnly(True)

        addressLabel = QLabel("Address:")
        self.addressText = QTextEdit()
        self.addressText.setReadOnly(True)

        self.addButton = QPushButton("&Add")
        self.addButton.show()
        self.submitButton = QPushButton("&Submit")
        self.submitButton.hide()
        self.cancelButton = QPushButton("&Cancel")
        self.cancelButton.hide()

        self.addButton.clicked.connect(self.addContact)
        self.submitButton.clicked.connect(self.submitContact)
        self.cancelButton.clicked.connect(self.cancel)

        buttonLayout1 = QVBoxLayout()
        buttonLayout1.addWidget(self.addButton, Qt.AlignTop)
        buttonLayout1.addWidget(self.submitButton)
        buttonLayout1.addWidget(self.cancelButton)
        buttonLayout1.addStretch()

        mainLayout = QGridLayout()
        mainLayout.addWidget(nameLabel, 0, 0)
        mainLayout.addWidget(self.nameLine, 0, 1)
        mainLayout.addWidget(addressLabel, 1, 0, Qt.AlignTop)
        mainLayout.addWidget(self.addressText, 1, 1)
        mainLayout.addLayout(buttonLayout1, 1, 2)

        self.setLayout(mainLayout)
        self.setWindowTitle("Simple Address Book")
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super(AddressBook, self).__init__(parent)

        self.contacts = SortedDict()
        self.oldName = ''
        self.oldAddress = ''

        nameLabel = QLabel("Name:")
        self.nameLine = QLineEdit()
        self.nameLine.setReadOnly(True)

        addressLabel = QLabel("Address:")
        self.addressText = QTextEdit()
        self.addressText.setReadOnly(True)

        self.addButton = QPushButton("&Add")
        self.addButton.show()
        self.submitButton = QPushButton("&Submit")
        self.submitButton.hide()
        self.cancelButton = QPushButton("&Cancel")
        self.cancelButton.hide()

        self.addButton.clicked.connect(self.addContact)
        self.submitButton.clicked.connect(self.submitContact)
        self.cancelButton.clicked.connect(self.cancel)

        buttonLayout1 = QVBoxLayout()
        buttonLayout1.addWidget(self.addButton, Qt.AlignTop)
        buttonLayout1.addWidget(self.submitButton)
        buttonLayout1.addWidget(self.cancelButton)
        buttonLayout1.addStretch()

        mainLayout = QGridLayout()
        mainLayout.addWidget(nameLabel, 0, 0)
        mainLayout.addWidget(self.nameLine, 0, 1)
        mainLayout.addWidget(addressLabel, 1, 0, Qt.AlignTop)
        mainLayout.addWidget(self.addressText, 1, 1)
        mainLayout.addLayout(buttonLayout1, 1, 2)

        self.setLayout(mainLayout)
        self.setWindowTitle("Simple Address Book")
项目:DCheat    作者:DCheat    | 项目源码 | 文件源码
def __init__(self, courseList, socket, parent=None):
        QtWidgets.QDialog.__init__(self, parent)
        self.ui = uic.loadUi(config.config.ROOT_PATH +'view/adminSelectCourse.ui', self)

        self.sock = socket
        self.courseList = []
        self.courseList = self.courseList + courseList
        self.register = object
        self.dataPos = -1
        pListWidget = QtWidgets.QWidget()
        self.ui.scrollArea.setWidgetResizable(True)
        self.ui.scrollArea.setWidget(pListWidget)
        self.pListLayout = QtWidgets.QGridLayout()
        self.pListLayout.setAlignment(Qt.AlignTop)
        pListWidget.setLayout(self.pListLayout)

        self.makeCourseLayout()
项目:OpenTutorials_PyQt    作者:RavenKyu    | 项目源码 | 文件源码
def init_widget(self):
        self.setWindowTitle("Layout Basic")
        self.setFixedWidth(640)
        self.setFixedHeight(480)

        self.lb_1.setText("Label 1")
        self.lb_2.setText("Label 2")
        self.lb_3.setText("Label 3")
        self.lb_4.setText("Label 4")
        self.lb_5.setText("Label 5")

        self.lb_1.setStyleSheet("background-color: yellow")
        self.lb_2.setStyleSheet("background-color: red")
        self.lb_3.setStyleSheet("background-color: blue")
        self.lb_4.setStyleSheet("background-color: pink")
        self.lb_5.setStyleSheet("background-color: grey")

        self.layout_1.addWidget(self.lb_1)
        self.layout_1.addWidget(self.lb_2, alignment=Qt.AlignTop)
        self.layout_1.addWidget(self.lb_3, alignment=Qt.AlignBottom)
        self.layout_1.addWidget(self.lb_4, alignment=Qt.AlignVCenter)
        self.layout_1.addWidget(self.lb_5, alignment=Qt.AlignHCenter)
项目:PRESTO-GUI    作者:padmec-reservoir    | 项目源码 | 文件源码
def make_tab1(self, parent):
        tab1 = QWidget(parent)
        tab1.value = dict((x[0], 0) for x in parameter_list)
        tab1.unit = dict((x[0], "") for x in parameter_list)
        tab1.layout = QGridLayout(tab1)
        tab1.layout.setAlignment(Qt.AlignTop)
        tab1.layout.addWidget(self.tree, 1, 1, 6, 1)
        tab1.labels = self.make_labels(tab1, parameter_list)
        tab1.inputs = self.make_inputs(tab1, parameter_list)
        tab1.boxes = self.make_dropdowns(tab1, parameter_list, self.get_unit)
        i = 0
        j = 2
        for x in parameter_list:
            tab1.layout.addWidget(tab1.labels[x[0]], (i % 6) + 1, j)
            tab1.layout.addWidget(tab1.inputs[x[0]], (i % 6) + 1, j + 1)
            tab1.layout.addWidget(tab1.boxes[x[0]], (i % 6) + 1, j + 2)
            i = i + 1
        return tab1
项目:PRESTO-GUI    作者:padmec-reservoir    | 项目源码 | 文件源码
def make_tab4(self, parent):
        tab4 = QWidget(parent)
        tab4.inpos = {}
        tab4.inwells = {}
        tab4.in_c = 1
        tab4.outpos = {}
        tab4.outwells = {}
        tab4.out_c = 1
        tab4.layout = QGridLayout(tab4)
        tab4.layout.setVerticalSpacing(20)
        tab4.layout.setAlignment(Qt.AlignTop | Qt.AlignCenter)
        tab4.add_inwell_but = QPushButton("New Injection Well", tab4)
        tab4.add_inwell_but.clicked.connect(self.make_inwell)
        tab4.add_outwell_but = QPushButton("New Producer Well", tab4)
        tab4.add_outwell_but.clicked.connect(self.make_outwell)
        tab4.layout.addWidget(tab4.add_inwell_but, 1, 1)
        tab4.layout.addWidget(tab4.add_outwell_but, 2, 1)
        return tab4
项目:PRESTO-GUI    作者:padmec-reservoir    | 项目源码 | 文件源码
def make_tab5(self, parent):
        tab5 = QWidget(parent)
        tab5.value = dict((x[0], 0) for x in mesh)
        tab5.unit = dict((x[0], "") for x in mesh)
        tab5.layout = QGridLayout(tab5)
        tab5.layout.setAlignment(Qt.AlignTop)
        tab5.labels = self.make_labels(tab5, mesh)
        tab5.inputs = self.make_inputs(tab5, mesh)
        tab5.boxes = self.make_dropdowns(tab5, mesh, self.get_unit)
        i = 0
        for x in mesh:
            tab5.layout.addWidget(tab5.labels[x[0]], i, 1)
            tab5.layout.addWidget(tab5.inputs[x[0]], i, 2)
            tab5.layout.addWidget(tab5.boxes[x[0]], i, 3)
            i = i + 1
        return tab5
项目:FIRST-plugin-ida    作者:vrtadmin    | 项目源码 | 文件源码
def init_middle_layout(self):
            if not self.should_show:
                return

            vbox = QtWidgets.QVBoxLayout()
            self.select_all = QtWidgets.QCheckBox('Select All ')
            self.filter_sub_funcs = QtWidgets.QCheckBox('Filter Out "sub_" functions ')
            vbox.addWidget(self.filter_sub_funcs)
            vbox.addWidget(self.select_all)

            format_str = '{} functions'.format(self.total_functions)
            self.function_number = QtWidgets.QLabel(format_str)
            self.function_number.setAlignment(Qt.AlignTop)
            self.middle_layout.addWidget(self.function_number)
            self.middle_layout.addStretch()
            self.middle_layout.addLayout(vbox)
项目:FIRST-plugin-ida    作者:vrtadmin    | 项目源码 | 文件源码
def init_middle_layout(self):
            found = len(self.groups)
            total = len(FIRST.Metadata.get_non_jmp_wrapped_functions())
            s = 's' if 1 != total else ''
            label = 'Matched {0} out of {1} function{2}'

            self.select_highest_ranked = QtWidgets.QCheckBox('Select Highest Ranked ')
            self.filter_sub_funcs_only = QtWidgets.QCheckBox('Show only "sub_" functions')

            vbox = QtWidgets.QVBoxLayout()
            vbox.addWidget(self.filter_sub_funcs_only)
            vbox.addWidget(self.select_highest_ranked)

            self.found_format = label.format('{}', total, s)
            self.found_label = QtWidgets.QLabel(self.found_format.format(found))
            self.found_label.setAlignment(Qt.AlignTop)

            self.middle_layout.addWidget(self.found_label)
            self.middle_layout.addStretch()
            self.middle_layout.addLayout(vbox)
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super(AddressBook, self).__init__(parent)

        self.contacts = SortedDict()
        self.oldName = ''
        self.oldAddress = ''

        nameLabel = QLabel("Name:")
        self.nameLine = QLineEdit()
        self.nameLine.setReadOnly(True)

        addressLabel = QLabel("Address:")
        self.addressText = QTextEdit()
        self.addressText.setReadOnly(True)

        self.addButton = QPushButton("&Add")
        self.addButton.show()
        self.submitButton = QPushButton("&Submit")
        self.submitButton.hide()
        self.cancelButton = QPushButton("&Cancel")
        self.cancelButton.hide()

        self.addButton.clicked.connect(self.addContact)
        self.submitButton.clicked.connect(self.submitContact)
        self.cancelButton.clicked.connect(self.cancel)

        buttonLayout1 = QVBoxLayout()
        buttonLayout1.addWidget(self.addButton, Qt.AlignTop)
        buttonLayout1.addWidget(self.submitButton)
        buttonLayout1.addWidget(self.cancelButton)
        buttonLayout1.addStretch()

        mainLayout = QGridLayout()
        mainLayout.addWidget(nameLabel, 0, 0)
        mainLayout.addWidget(self.nameLine, 0, 1)
        mainLayout.addWidget(addressLabel, 1, 0, Qt.AlignTop)
        mainLayout.addWidget(self.addressText, 1, 1)
        mainLayout.addLayout(buttonLayout1, 1, 2)

        self.setLayout(mainLayout)
        self.setWindowTitle("Simple Address Book")
项目: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)
项目:Red-GUI    作者:ScarletRav3n    | 项目源码 | 文件源码
def token_ui(self):
        self.clear_layout(self.rbox)
        self.clear_layout(self.hbox)
        self.hbox.addStretch()
        self.l1.setText("Input your bot's token")

        self.rbox.insertSpacing(1, 30)
        self.token_print = QLabel(self)
        self.token_print.setText("Token: ")
        self.rbox.addWidget(self.token_print, 0, Qt.AlignTop)
        self.token_edit = QLineEdit(self)
        self.token_edit.setMaximumWidth(300)
        self.rbox.addWidget(self.token_edit, 0, Qt.AlignTop)

        l2 = QLabel("Your token can be found in Discord's "
                    "<a href='https://discordapp.com/developers/applications/me'>App Page</a>")
        l2.setOpenExternalLinks(True)
        l2.setFont(self.small_font)
        self.rbox.addWidget(l2, 0, Qt.AlignBottom)

        if self.settings.token is not None:
            l5 = QLabel(self)
            l5.setText('<font color="#ff0000">"' + self.settings.token[0:10] + '--"</font>\nis your current token')
            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.prefix_ui)

        # buttons
        self.buttons_panel()
        # token1 = token_edit.text()

        # binds
        self.b1.setEnabled(False)
        self.token_edit.textChanged[str].connect(self.token_on_change)
        self.b1.clicked.connect(self.req_ui)
        self.b2.clicked.connect(self.token_save)
        self.b3.clicked.connect(self.close_prompt)
项目:Red-GUI    作者:ScarletRav3n    | 项目源码 | 文件源码
def admin_ui(self):
        self.clear_layout(self.rbox)
        self.clear_layout(self.hbox)
        self.hbox.addStretch()
        self.l1.setText("Set your Administrator roles")

        # admin
        self.rbox.insertSpacing(1, 30)
        self.admin_print = QLabel(self)
        self.admin_print.setText("Admin: ")
        self.admin_print.setWordWrap(True)
        self.rbox.addWidget(self.admin_print, 0, Qt.AlignTop)
        self.admin_edit = QLineEdit(self)
        self.admin_edit.setPlaceholderText("Blank for default")
        self.admin_edit.setMaximumWidth(300)
        self.rbox.addWidget(self.admin_edit, 0, Qt.AlignTop)

        # mod
        self.rbox.insertSpacing(1, 30)
        self.mod_print = QLabel(self)
        self.mod_print.setText("Mod: ")
        self.mod_print.setWordWrap(True)
        self.rbox.addWidget(self.mod_print, 0, Qt.AlignTop)
        self.mod_edit = QLineEdit(self)
        self.mod_edit.setPlaceholderText("Blank for default")
        self.mod_edit.setMaximumWidth(300)
        self.rbox.addWidget(self.mod_edit, 0, Qt.AlignTop)

        # buttons
        self.buttons_panel()

        # binds
        self.b2.setText("Finish")
        self.b1.clicked.connect(self.prefix_ui)
        self.b2.clicked.connect(self.admin_save)
        self.b3.clicked.connect(self.close_prompt)
项目:vidcutter    作者:ozmartian    | 项目源码 | 文件源码
def showTimer(self) -> None:
        self._timerwidget.show()
        # noinspection PyArgumentList
        self.layout().addWidget(self._timerwidget, 1, 0, Qt.AlignHCenter | Qt.AlignTop)
        self._time.start()
        self.updateTimer()
        self._timer.start(1000)
项目:hacked_cnc    作者:hackerspace    | 项目源码 | 文件源码
def run_cmd(self, cmd):
        item = QTreeWidgetItem(self.comtree)

        item.setText(0, time.strftime("%Y.%m.%d. %H:%M:%S", time.localtime()))
        item.setText(1, cmd)

        for i in range(3):
            item.setTextAlignment(i, Qt.AlignTop)

        item.setForeground(1, QtGui.QBrush(green))
        item.setForeground(2, QtGui.QBrush(red))

        self.comtree.scrollToItem(item)
        self.conn.cmd(cmd)
        proc_events()
项目: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 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 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)
项目:DCheat    作者:DCheat    | 项目源码 | 文件源码
def __init__(self, socket, pui, pCourseList, parent=None):
        QtWidgets.QDialog.__init__(self, parent)
        self.ui = uic.loadUi(config.config.ROOT_PATH +'view/registerCourse.ui', self)

        self.sock = socket
        self.pui = pui
        self.pCourseList = pCourseList

        self.banList = []
        self.allowList = []
        self.students = []

        self.ui.dateEdit.setDate(datetime.datetime.now().date())

        pListWidget = QtWidgets.QWidget()
        self.ui.scrollArea.setWidgetResizable(True)
        self.ui.scrollArea.setWidget(pListWidget)
        pListLayout = QtWidgets.QVBoxLayout()
        pListLayout.setAlignment(Qt.AlignTop)
        pListWidget.setLayout(pListLayout)

        for i in range(1, len(config.config.BAN_PROGRAM)):
            checkBox = QtWidgets.QCheckBox(config.config.BAN_PROGRAM[i])
            checkBox.clicked.connect(self.set_ban_list)
            pListLayout.addWidget(checkBox)

        sListWidget = QtWidgets.QWidget()
        self.ui.scrollArea_2.setWidgetResizable(True)
        self.ui.scrollArea_2.setWidget(sListWidget)
        sListLayout = QtWidgets.QVBoxLayout()
        sListLayout.setAlignment(Qt.AlignTop)
        sListWidget.setLayout(sListLayout)

        for i in range(1, len(config.config.ALLOW_SITE)):
            checkBox = QtWidgets.QCheckBox(config.config.ALLOW_SITE[i])
            checkBox.clicked.connect(self.set_allow_list)
            sListLayout.addWidget(checkBox)

        self.ui.show()
项目:srpdfcrawler    作者:DeastinY    | 项目源码 | 文件源码
def init_ui(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)
        self.create_layout()
        window_layout = QVBoxLayout()
        window_layout.addWidget(self.horizontal_groupbox, 1)
        window_layout.addWidget(self.scroll_area, 100)
        window_layout.setAlignment(self.scroll_area, Qt.AlignTop)
        self.setLayout(window_layout)

        self.show()
项目:PRESTO-GUI    作者:padmec-reservoir    | 项目源码 | 文件源码
def make_tab2(self, parent):
        tab2 = QWidget(parent)
        tab2.layout = QGridLayout(tab2)
        tab2.layout.setAlignment(Qt.AlignTop)
        tab2.oil = QLabel("Oil", tab2)
        tab2.oil.value = dict((x[0], 0) for x in fluids)
        tab2.oil.unit = dict((x[0], "") for x in fluids)
        tab2.oil.labels = self.make_labels(tab2, fluids)
        tab2.oil.inputs = self.make_inputs(tab2, fluids)
        tab2.oil.boxes = self.make_dropdowns(tab2, fluids, self.get_unit)
        tab2.water = QLabel("Water", tab2)
        tab2.water.value = dict((x[0], 0) for x in fluids)
        tab2.water.unit = dict((x[0], "") for x in fluids)
        tab2.water.labels = self.make_labels(tab2, fluids)
        tab2.water.inputs = self.make_inputs(tab2, fluids)
        tab2.water.boxes = self.make_dropdowns(tab2, fluids, self.get_unit)
        tab2.layout.addWidget(tab2.oil, 1, 1)
        tab2.layout.addWidget(tab2.water, 1, 4)
        i = 2
        for x in fluids:
            tab2.layout.addWidget(tab2.oil.labels[x[0]], i, 1)
            tab2.layout.addWidget(tab2.oil.inputs[x[0]], i, 2)
            tab2.layout.addWidget(tab2.oil.boxes[x[0]], i, 3)
            tab2.layout.addWidget(tab2.water.labels[x[0]], i, 4)
            tab2.layout.addWidget(tab2.water.inputs[x[0]], i, 5)
            tab2.layout.addWidget(tab2.water.boxes[x[0]], i, 6)
            i = i + 1
        return tab2
项目:PRESTO-GUI    作者:padmec-reservoir    | 项目源码 | 文件源码
def make_tab3(self, parent):
        tab3 = QWidget(parent)
        tab3.layout = QGridLayout(tab3)
        tab3.layout.setAlignment(Qt.AlignTop)
        tab3.value = {}
        tab3.coords = ["X", "Y", "Z"]
        tab3.labels = {}
        tab3.inputs = {}
        tab3.boxes = self.make_dropdowns(tab3, permcamp, self.save_camp)
        i = 1
        for x in tab3.coords:
            tab3.labels[x] = QLabel(x, tab3)
            tab3.inputs[x] = QLineEdit(tab3)
            tab3.inputs[x].textEdited.connect(self.save_camp)
            tab3.boxes[x] = MyComboBox(tab3, start_unit, "Length")
            tab3.boxes[x].currentTextChanged.connect(self.save_camp)
            tab3.layout.addWidget(tab3.labels[x], i, 1)
            tab3.layout.addWidget(tab3.inputs[x], i, 2)
            tab3.layout.addWidget(tab3.boxes[x], i, 3)
            i += 1
        for x in permcamp:
            tab3.labels[x[0]] = QLabel(x[0], tab3)
            tab3.inputs[x[0]] = QLineEdit(tab3)
            tab3.inputs[x[0]].textEdited.connect(self.save_camp)
            tab3.layout.addWidget(tab3.labels[x[0]], i, 1)
            tab3.layout.addWidget(tab3.inputs[x[0]], i, 2)
            tab3.layout.addWidget(tab3.boxes[x[0]], i, 3)
            i += 1
        return tab3
项目: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 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)
项目:Red-GUI    作者:ScarletRav3n    | 项目源码 | 文件源码
def init_ui(self):

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

        l1 = QLabel('Red Discord Bot', self)
        l1.setFont(QtGui.QFont("Times", 14))
        box.addWidget(l1, 0, Qt.AlignTop)
        box.insertSpacing(1, 10)

        b1 = QPushButton("Start Red", self)
        b1.setMinimumWidth(100)
        box.addWidget(b1, 0, Qt.AlignHCenter)
        b2 = QPushButton("Start Red Loop", self)
        b2.setMinimumWidth(100)
        box.addWidget(b2, 0, Qt.AlignHCenter)
        box.insertSpacing(4, 10)

        b3 = QPushButton("Update Red", self)
        b3.setMinimumWidth(80)
        box2.addWidget(b3, 0, Qt.AlignHCenter)
        b4 = QPushButton("Install Requirements", self)
        b4.setMinimumWidth(120)
        box2.addWidget(b4, 0, Qt.AlignHCenter)
        b5 = QPushButton("Maintenance", self)
        b5.setMinimumWidth(100)
        box2.addWidget(b5, 0, Qt.AlignHCenter)

        # b2.setEnabled(False)
        box.setAlignment(Qt.AlignHCenter)
        box2.addStretch(5)
        box.addLayout(box2)
        self.setLayout(box)

        # binds
        b1.clicked.connect(lambda: self.startred(autorestart=False))
        b2.clicked.connect(lambda: self.startred(autorestart=True))
        b3.clicked.connect(lambda: self.switchwindow(window=UpdateWindow()))
        b4.clicked.connect(lambda: self.switchwindow(window=RequirementsWindow()))
        b5.clicked.connect(lambda: self.switchwindow(window=MaintenanceWindow()))

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

        # v.box
        gbox = QtWidgets.QGridLayout()
        box = QtWidgets.QVBoxLayout()
        self.rbox = QtWidgets.QVBoxLayout()
        self.hbox = QtWidgets.QHBoxLayout()

        # padding/margins
        gbox.setContentsMargins(0, 0, 0, 0)
        self.rbox.setContentsMargins(0, 0, 10, 10)
        self.hbox.setContentsMargins(0, 0, 10, 10)
        box.addStretch()
        self.hbox.addStretch()
        gbox.setSpacing(10)
        box.setSpacing(0)
        self.rbox.setSpacing(5)
        self.hbox.setSpacing(0)

        image = QtGui.QImage()
        image.loadFromData(urllib.request.urlopen('http://i.imgur.com/04DUqa3.png').read())
        png = QLabel(self)
        pixmap = QtGui.QPixmap(image)
        png.setPixmap(pixmap)
        gbox.addWidget(png, 0, 0, 1, 1, Qt.AlignTop)

        box.insertSpacing(1, 10)
        self.l1 = QLabel(self)
        self.l1.setWordWrap(True)
        self.large_font.setBold(True)
        self.l1.setFont(self.large_font)
        box.addWidget(self.l1, 0, Qt.AlignTop)

        hline = QtWidgets.QFrame()
        hline.setFrameShape(QtWidgets.QFrame.HLine)
        hline.setFrameShadow(QtWidgets.QFrame.Sunken)
        gbox.addWidget(hline, 0, 0, 1, 3, Qt.AlignBottom)

        # start form
        self.req_ui()

        self.rbox.setAlignment(Qt.AlignTop)
        box.addLayout(self.rbox, 1)
        gbox.addLayout(box, 0, 1, 1, 2)
        gbox.addLayout(self.hbox, 1, 0, 1, 3)
        self.setLayout(gbox)

        # window
        self.setFixedSize(490, 400)
        self.setWindowIcon(QtGui.QIcon('red.ico'))
        self.setWindowTitle('Red Discord Bot - Setup')
        self.show()
项目:Red-GUI    作者:ScarletRav3n    | 项目源码 | 文件源码
def console_ui(self, audio):
        self.clear_layout(self.rbox)
        self.clear_layout(self.hbox)
        self.hbox.addStretch()
        self.l1.setText("Installing requirements")

        self.process = QProcess()
        self.output = QTextEdit()
        self.percent = 0

        self.rbox.insertSpacing(1, 10)
        l2 = QLabel('Press Next when the last line says "Successfully Installed--"')
        self.rbox.addWidget(l2, 0, Qt.AlignTop)
        # this can be uncommented whenever I actually figure out Progress Bars
        # self.pbar = QtWidgets.QProgressBar()
        # self.pbar.setGeometry(30, 40, 200, 25)
        # self.rbox.addWidget(self.pbar)

        b5 = QPushButton("Dialog", self)
        b5.setMaximumWidth(75)

        self.rbox.addWidget(b5)
        self.rbox.addWidget(self.output)
        self.process.readyRead.connect(self.console_data)
        self.output.hide()

        # data flow
        remove_reqs_readonly()
        interpreter = sys.executable

        if interpreter is None:
            QMessageBox.warning(self, "404", "Python interpreter not found.")
            self.close()

        txt = REQS_TXT if audio else REQS_NO_AUDIO_TXT
        args = ["-m", "pip", "install", "--upgrade", "--target", REQS_DIR, "-r", txt]

        if IS_MAC:  # --target is a problem on Homebrew. See PR #552
            args.remove("--target")
            args.remove(REQS_DIR)

        # do call
        self.process.start(interpreter, args)

        # buttons
        self.buttons_panel()

        # binds
        self.b1.setEnabled(True)
        # self.b2.setEnabled(False)
        self.b1.clicked.connect(self.req_ui)
        self.b1.clicked.connect(self.process.close)
        self.b2.clicked.connect(self.token_ui)
        self.b3.clicked.connect(self.close_prompt)
        b5.clicked.connect(self.console_hide)
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super(AddressBook, self).__init__(parent)

        self.contacts = SortedDict()
        self.oldName = ''
        self.oldAddress = ''

        nameLabel = QLabel("Name:")
        self.nameLine = QLineEdit()
        self.nameLine.setReadOnly(True)

        addressLabel = QLabel("Address:")
        self.addressText = QTextEdit()
        self.addressText.setReadOnly(True)

        self.addButton = QPushButton("&Add")
        self.addButton.show()
        self.submitButton = QPushButton("&Submit")
        self.submitButton.hide()
        self.cancelButton = QPushButton("&Cancel")
        self.cancelButton.hide()
        self.nextButton = QPushButton("&Next")
        self.nextButton.setEnabled(False)
        self.previousButton = QPushButton("&Previous")
        self.previousButton.setEnabled(False)

        self.addButton.clicked.connect(self.addContact)
        self.submitButton.clicked.connect(self.submitContact)
        self.cancelButton.clicked.connect(self.cancel)
        self.nextButton.clicked.connect(self.next)
        self.previousButton.clicked.connect(self.previous)

        buttonLayout1 = QVBoxLayout()
        buttonLayout1.addWidget(self.addButton, Qt.AlignTop)
        buttonLayout1.addWidget(self.submitButton)
        buttonLayout1.addWidget(self.cancelButton)
        buttonLayout1.addStretch()

        buttonLayout2 = QHBoxLayout()
        buttonLayout2.addWidget(self.previousButton)
        buttonLayout2.addWidget(self.nextButton)

        mainLayout = QGridLayout()
        mainLayout.addWidget(nameLabel, 0, 0)
        mainLayout.addWidget(self.nameLine, 0, 1)
        mainLayout.addWidget(addressLabel, 1, 0, Qt.AlignTop)
        mainLayout.addWidget(self.addressText, 1, 1)
        mainLayout.addLayout(buttonLayout1, 1, 2)
        mainLayout.addLayout(buttonLayout2, 3, 1)

        self.setLayout(mainLayout)
        self.setWindowTitle("Simple Address Book")
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super(AddressBook, self).__init__(parent)

        self.contacts = SortedDict()
        self.oldName = ''
        self.oldAddress = ''

        nameLabel = QLabel("Name:")
        self.nameLine = QLineEdit()
        self.nameLine.setReadOnly(True)

        addressLabel = QLabel("Address:")
        self.addressText = QTextEdit()
        self.addressText.setReadOnly(True)

        self.addButton = QPushButton("&Add")
        self.addButton.show()
        self.submitButton = QPushButton("&Submit")
        self.submitButton.hide()
        self.cancelButton = QPushButton("&Cancel")
        self.cancelButton.hide()
        self.nextButton = QPushButton("&Next")
        self.nextButton.setEnabled(False)
        self.previousButton = QPushButton("&Previous")
        self.previousButton.setEnabled(False)

        self.addButton.clicked.connect(self.addContact)
        self.submitButton.clicked.connect(self.submitContact)
        self.cancelButton.clicked.connect(self.cancel)
        self.nextButton.clicked.connect(self.next)
        self.previousButton.clicked.connect(self.previous)

        buttonLayout1 = QVBoxLayout()
        buttonLayout1.addWidget(self.addButton, Qt.AlignTop)
        buttonLayout1.addWidget(self.submitButton)
        buttonLayout1.addWidget(self.cancelButton)
        buttonLayout1.addStretch()

        buttonLayout2 = QHBoxLayout()
        buttonLayout2.addWidget(self.previousButton)
        buttonLayout2.addWidget(self.nextButton)

        mainLayout = QGridLayout()
        mainLayout.addWidget(nameLabel, 0, 0)
        mainLayout.addWidget(self.nameLine, 0, 1)
        mainLayout.addWidget(addressLabel, 1, 0, Qt.AlignTop)
        mainLayout.addWidget(self.addressText, 1, 1)
        mainLayout.addLayout(buttonLayout1, 1, 2)
        mainLayout.addLayout(buttonLayout2, 3, 1)

        self.setLayout(mainLayout)
        self.setWindowTitle("Simple Address Book")
项目:DCheat    作者:DCheat    | 项目源码 | 文件源码
def __init__(self, socket, name, testDate, startTime, endTime, banList, allowList, parent=None):
        QtWidgets.QDialog.__init__(self, parent)
        self.ui = uic.loadUi(config.config.ROOT_PATH +'view/updateCourse.ui', self)
        self.sock = socket

        self.name = name
        self.date = testDate.split('-')
        self.startTime = startTime.split(':')
        self.endTime = endTime.split(':')
        self.banList = banList
        self.allowList = allowList

        self.students = []
        self.ui.label_5.setText(self.name)


        self.ui.dateEdit.setDate(QDate(int(self.date[0]), int(self.date[1]), int(self.date[2])))
        self.ui.timeEdit.setTime(QTime(int(self.startTime[0]), int(self.startTime[1])))
        self.ui.timeEdit_2.setTime(QTime(int(self.endTime[0]), int(self.endTime[1])))

        pListWidget = QtWidgets.QWidget()
        self.ui.scrollArea.setWidgetResizable(True)
        self.ui.scrollArea.setWidget(pListWidget)
        pListLayout = QtWidgets.QVBoxLayout()
        pListLayout.setAlignment(Qt.AlignTop)
        pListWidget.setLayout(pListLayout)

        for i in range(1, len(config.config.BAN_PROGRAM)):
            checkBox = QtWidgets.QCheckBox(config.config.BAN_PROGRAM[i])
            checkBox.clicked.connect(self.set_ban_list)

            if i in self.banList:
                checkBox.setChecked(True)

            pListLayout.addWidget(checkBox)


        sListWidget = QtWidgets.QWidget()
        self.ui.scrollArea_2.setWidgetResizable(True)
        self.ui.scrollArea_2.setWidget(sListWidget)
        sListLayout = QtWidgets.QVBoxLayout()
        sListLayout.setAlignment(Qt.AlignTop)
        sListWidget.setLayout(sListLayout)

        for i in range(1, len(config.config.ALLOW_SITE)):
            checkBox = QtWidgets.QCheckBox(config.config.ALLOW_SITE[i])
            checkBox.clicked.connect(self.set_allow_list)

            if i in self.allowList:
                checkBox.setChecked(True)

            sListLayout.addWidget(checkBox)

        self.ui.show()
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def initUI(self):
        """
        Initialize the Central Widget user interface.
        """
        def __get_top_layout(parent):
            image = ImageWidget(parent, B3_BANNER)
            layout = QHBoxLayout()
            layout.addWidget(image)
            layout.setAlignment(Qt.AlignTop)
            layout.setContentsMargins(0, 0, 0, 0)
            return layout

        def __get_middle_layout(parent):
            parent.main_table = MainTable(parent)
            parent.help_label = HelpLabel(parent.main_table)
            layout = QVBoxLayout()
            layout.addWidget(parent.main_table)
            #layout.addWidget(parent.help_label)
            layout.setAlignment(Qt.AlignHCenter | Qt.AlignTop)
            layout.setContentsMargins(0, 2, 0, 0)
            return layout

        def __get_bottom_layout(parent):
            parent.news = MarqueeLabel(parent)
            parent.news.parseFeed()
            btn_new = Button(parent=parent, text='Add', shortcut='Ctrl+N')
            btn_new.clicked.connect(self.parent().new_process_dialog)
            btn_new.setStatusTip('Add a new B3')
            btn_new.setVisible(True)
            btn_quit = Button(parent=parent, text='Quit', shortcut='Ctrl+Q')
            btn_quit.clicked.connect(B3App.Instance().shutdown)
            btn_quit.setStatusTip('Shutdown B3')
            btn_quit.setVisible(True)
            layout = QHBoxLayout()
            layout.addWidget(parent.news)
            layout.addWidget(btn_new)
            layout.addWidget(btn_quit)
            layout.setAlignment(Qt.AlignBottom | Qt.AlignRight)
            layout.setSpacing(10)
            layout.setContentsMargins(0, 0, 11, GEOMETRY[b3.getPlatform()]['CENTRAL_WIDGET_BOTTOM_LAYOUT_MARGIN_BOTTOM'])
            return layout

        main_layout = QVBoxLayout()
        main_layout.addLayout(__get_top_layout(self))
        main_layout.addLayout(__get_middle_layout(self))
        main_layout.addLayout(__get_bottom_layout(self))
        main_layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(main_layout)
        self.setFixedSize(614, 512)
        self.setStyleSheet("""
        QWidget, QDialog, QMessageBox {
            background: #F2F2F2;
        }
        """)
        self.setFocus()
项目: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)
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def initUI(self):
        """
        Initialize the Dialog layout.
        """
        self.setWindowTitle('B3 database update')
        self.setFixedSize(420, 160)
        self.setStyleSheet("""
        QDialog {
            background: #F2F2F2;
        }
        """)

        ## INIT CLOSE BUTTON
        self.btn_close = Button(parent=self, text='Close')
        self.btn_close.clicked.connect(self.close)
        self.btn_close.hide()
        ## INIT UPDATE BUTTON
        self.btn_update = Button(parent=self, text='Update')
        self.btn_update.clicked.connect(self.do_update)
        self.btn_update.show()
        ## CREATE THE PROGRESS BAR
        self.progress = ProgressBar(self)
        self.progress.setAlignment(Qt.AlignHCenter)
        self.progress.hide()
        self.progress.setRange(0, 0)
        self.progress.setValue(-1)
        ## INIT DISPLAY MESSAGE
        self.message = QLabel("This tool will update all your B3 databases to version %s.\n"
                              "The update process should take less than 2 minutes and\n"
                              "cannot be interrupted." % b3.__version__, self)

        def __get_top_layout(parent):
            parent.layout1 = QVBoxLayout()
            parent.layout1.addWidget(parent.progress)
            parent.layout1.addWidget(parent.message)
            parent.layout1.setAlignment(Qt.AlignTop|Qt.AlignHCenter)
            parent.layout1.setContentsMargins(0, 0, 0, 0)
            return parent.layout1

        def __get_bottom_layout(parent):
            parent.layout2 = QHBoxLayout()
            parent.layout2.addWidget(parent.btn_close)
            parent.layout2.addWidget(parent.btn_update)
            parent.layout2.setAlignment(Qt.AlignHCenter)
            parent.layout2.setSpacing(20 if b3.getPlatform() != 'win32' else 10)
            parent.layout2.setContentsMargins(0, 10, 0, 0)
            return parent.layout2

        self.setModal(True)
        self.main_layout = QVBoxLayout()
        self.main_layout.addLayout(__get_top_layout(self))
        self.main_layout.addLayout(__get_bottom_layout(self))
        self.main_layout.setAlignment(Qt.AlignCenter)
        self.setLayout(self.main_layout)
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super(AddressBook, self).__init__(parent)

        self.contacts = SortedDict()
        self.oldName = ''
        self.oldAddress = ''

        nameLabel = QLabel("Name:")
        self.nameLine = QLineEdit()
        self.nameLine.setReadOnly(True)

        addressLabel = QLabel("Address:")
        self.addressText = QTextEdit()
        self.addressText.setReadOnly(True)

        self.addButton = QPushButton("&Add")
        self.addButton.show()
        self.submitButton = QPushButton("&Submit")
        self.submitButton.hide()
        self.cancelButton = QPushButton("&Cancel")
        self.cancelButton.hide()
        self.nextButton = QPushButton("&Next")
        self.nextButton.setEnabled(False)
        self.previousButton = QPushButton("&Previous")
        self.previousButton.setEnabled(False)

        self.addButton.clicked.connect(self.addContact)
        self.submitButton.clicked.connect(self.submitContact)
        self.cancelButton.clicked.connect(self.cancel)
        self.nextButton.clicked.connect(self.next)
        self.previousButton.clicked.connect(self.previous)

        buttonLayout1 = QVBoxLayout()
        buttonLayout1.addWidget(self.addButton, Qt.AlignTop)
        buttonLayout1.addWidget(self.submitButton)
        buttonLayout1.addWidget(self.cancelButton)
        buttonLayout1.addStretch()

        buttonLayout2 = QHBoxLayout()
        buttonLayout2.addWidget(self.previousButton)
        buttonLayout2.addWidget(self.nextButton)

        mainLayout = QGridLayout()
        mainLayout.addWidget(nameLabel, 0, 0)
        mainLayout.addWidget(self.nameLine, 0, 1)
        mainLayout.addWidget(addressLabel, 1, 0, Qt.AlignTop)
        mainLayout.addWidget(self.addressText, 1, 1)
        mainLayout.addLayout(buttonLayout1, 1, 2)
        mainLayout.addLayout(buttonLayout2, 3, 1)

        self.setLayout(mainLayout)
        self.setWindowTitle("Simple Address Book")