當前位置: 首頁>>代碼示例>>Python>>正文


Python QLineEdit.home方法代碼示例

本文整理匯總了Python中PyQt5.QtWidgets.QLineEdit.home方法的典型用法代碼示例。如果您正苦於以下問題:Python QLineEdit.home方法的具體用法?Python QLineEdit.home怎麽用?Python QLineEdit.home使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtWidgets.QLineEdit的用法示例。


在下文中一共展示了QLineEdit.home方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: AddorEditPreset

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import home [as 別名]
class AddorEditPreset(QDialog):
    def __init__(self, xml_element, edit=False, parent=None):
        super(AddorEditPreset, self).__init__(parent)

        nameQL = QLabel(self.tr('Preset name (one word, A-z, 0-9)'))
        self.nameQLE = QLineEdit()
        labelQL = QLabel(self.tr('Preset label'))
        self.labelQLE = QLineEdit()
        commandQL = QLabel(self.tr('Preset command line parameters'))
        self.commandQLE = QLineEdit()
        extQL = QLabel(self.tr('Output file extension'))
        self.extQLE = QLineEdit()
        buttonBox = QDialogButtonBox(
                QDialogButtonBox.Ok|QDialogButtonBox.Cancel)

        final_layout = utils.add_to_layout(
                'v', nameQL, self.nameQLE, labelQL, self.labelQLE,
                commandQL, self.commandQLE, extQL, self.extQLE, buttonBox
                )

        self.setLayout(final_layout)

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

        self.resize(410, 280)

        if edit:
            self.nameQLE.setText(xml_element.tag)
            self.labelQLE.setText(xml_element[0].text)
            self.commandQLE.setText(xml_element[1].text)
            self.commandQLE.home(False)
            self.extQLE.setText(xml_element[2].text)

            title = self.tr('Edit {0}'.format(xml_element.tag))
        else:
            title = self.tr('Add preset')

        self.resize(410, 280)
        self.setWindowTitle(title)

    def validate_data(self):
        """
        Extract data from GUI and check if everything is ok to continue.

        Check if:
        - Any lineEdit is empty.
        - Preset name and extension meet the qualifications.

        Return True if all tests pass, else False.
        """
        self.name_text = self.nameQLE.text().strip()
        self.label_text = self.labelQLE.text().strip()
        self.command_text = self.commandQLE.text().strip()
        self.ext_text = self.extQLE.text().strip()

        if not self.name_text:
            QMessageBox.warning(
                    self, 'Edit Preset - ' + self.tr('Error!'),
                    self.tr("Preset name can't be left blank.")
                    )
            self.nameQLE.setFocus()
            return False
        if not re.match('^(?![xX][mM][lL])[A-Za-z][A-Za-z0-9_.-:]*$',
                self.name_text):
            QMessageBox.warning(
                    self, 'Edit Preset - ' + self.tr('Error!'),
                    self.tr(
                    'Preset name must be one word, start with a letter and '
                    'contain only letters, digits, underscores, hyphens, '
                    'colons and periods. It cannot also start with xml.')
                    )
            self.nameQLE.selectAll()
            self.nameQLE.setFocus()
            return False
        if not self.label_text:
            QMessageBox.warning(
                    self, 'Edit Preset - ' + self.tr('Error!'),
                    self.tr("Preset label can't be left blank.")
                    )
            self.labelQLE.setFocus()
            return False
        if not self.command_text:
            QMessageBox.warning(
                    self, 'Edit Preset - ' + self.tr('Error!'),
                    self.tr("Command label can't be left blank.")
                    )
            self.commandQLE.setFocus()
            return False
        if not self.ext_text:
            QMessageBox.warning(
                    self, 'Edit Preset - ' + self.tr('Error!'),
                    self.tr("Extension label can't be left blank.")
                    )
            self.extQLE.setFocus()
            return False
        if len(self.ext_text.split()) != 1 or self.ext_text[0] == '.':
            QMessageBox.warning(
                    self, 'Edit Preset - ' + self.tr('Error!'),
                    self.tr(
#.........這裏部分代碼省略.........
開發者ID:Ilias95,項目名稱:FF-Multi-Converter,代碼行數:103,代碼來源:presets_dlgs.py

示例2: AudioVideoTab

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import home [as 別名]

#.........這裏部分代碼省略.........
        self.chan2QRB.setChecked(False)
        self.group.setExclusive(True)
        # setExclusive(False) in order to be able to uncheck checkboxes and
        # then setExclusive(True) so only one radio button can be set

    def fill_video_comboboxes(self, vcodecs, acodecs, extraformats):
        self.vidcodecQCB.currentIndexChanged.disconnect()
        self.audcodecQCB.currentIndexChanged.disconnect()

        self.vidcodecQCB.clear()
        self.audcodecQCB.clear()
        self.extQCB.clear()
        self.vidcodecQCB.addItems([self.defaultStr, self.DisableStream] + vcodecs)
        self.audcodecQCB.addItems([self.defaultStr, self.DisableStream] + acodecs)
        self.extQCB.addItems(sorted(self.formats + extraformats))

        self.vidcodecQCB.currentIndexChanged.connect(self.command_update_vcodec)
        self.audcodecQCB.currentIndexChanged.connect(self.command_update_acodec)

    def ok_to_continue(self):
        """
        Check if everything is ok with audiovideotab to continue conversion.
        Returns boolean.
        """
        if not self.parent.ffmpeg_path:
            QMessageBox.warning(self, 'FF Multi Converter - ' + self.tr(
                'Error!'), self.tr('FFmpeg is not installed!'))
            return False
        return True

    def open_subtitle_file(self):
        fname = QFileDialog.getOpenFileName(
                self, 'FF Multi Converter - ' + self.tr('Choose File'),
                config.home, 'Subtitles (*.srt *.sub *.ssa *.ass)'
                )[0]
        if fname:
            self.embedQLE.setText(fname)

    def set_default_command(self):
        """Set the default value to self.commandQLE."""
        self.clear()
        self.commandQLE.setText(self.parent.default_command)

    def choose_preset(self):
        """
        Open the presets dialog and update self.commandQLE,
        and self.extQCB and with the appropriate values.
        """
        dialog = presets_dlgs.ShowPresets(choose=True)
        if dialog.exec_() and dialog.the_command is not None:
            self.clear()
            self.commandQLE.setText(dialog.the_command)
            self.commandQLE.home(False)
            find = self.extQCB.findText(dialog.the_extension)
            if find >= 0:
                self.extQCB.setCurrentIndex(find)

    def command_update_size(self):
        command = self.commandQLE.text()
        text1 = self.widthQLE.text()
        text2 = self.heightQLE.text()

        if not (text1 == '-1' or text2 == '-1'):
            self.preserveaspectQChB.setChecked(False)

        if (text1 or text2) and not (text1 and text2) or (text1 == '-' or
開發者ID:Ilias95,項目名稱:FF-Multi-Converter,代碼行數:70,代碼來源:audiovideotab.py

示例3: ShowPresets

# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import home [as 別名]

#.........這裏部分代碼省略.........
        self.root = self.tree.getroot()

    def set_buttons_clear_lineEdits(self):
        """Enable or disable button's and clear lineEdits."""
        enable = bool(self.presQLW)
        self.editQPB.setEnabled(enable)
        self.deleteQPB.setEnabled(enable)
        self.delete_allQPB.setEnabled(enable)
        if not enable:
            self.labelQLE.clear()
            self.commandQLE.clear()
            self.extQLE.clear()

    def fill_presQLW(self):
        """Clear self.presQLW and to it presets' tags."""
        self.presQLW.clear()
        for i in sorted([y.tag for y in self.root]):
            elem = self.root.find(i)
            self.presQLW.addItem(utils.XmlListItem(i, elem))

        self.presQLW.setCurrentRow(0)
        self.set_buttons_clear_lineEdits()
        self.searchQLE.clear()

    def show_preset(self):
        """Fill LineEdits with current xml element's values."""
        try:
            xml_elem = self.presQLW.currentItem().xml_element
        except AttributeError:
            return

        self.labelQLE.setText(xml_elem[0].text)
        self.commandQLE.setText(xml_elem[1].text)
        self.commandQLE.home(False)
        self.extQLE.setText(xml_elem[2].text)

    def add_preset(self):
        """Open AddorEditPreset() dialog and add a preset xml root."""
        dialog = AddorEditPreset(None, False, self)
        if dialog.exec_():
            element = etree.Element(dialog.name_text)
            label = etree.Element('label')
            label.text = dialog.label_text
            command = etree.Element('params')
            command.text = dialog.command_text
            ext = etree.Element('extension')
            ext.text = dialog.ext_text
            category = etree.Element('category')
            category.text = 'Scattered'

            for num, elem in enumerate([label, command, ext, category]):
                element.insert(num, elem)
            index = sorted(
                    [i.tag for i in self.root] + [dialog.name_text]
                    ).index(dialog.name_text)
            self.root.insert(index, element)
            self.save_tree()
            self.fill_presQLW()

    def delete_preset(self):
        """
        Ask user wether he wants to delete the selected preset.
        If so, delete the preset from xml root.
        """
        try:
            xml_elem = self.presQLW.currentItem().xml_element
開發者ID:Ilias95,項目名稱:FF-Multi-Converter,代碼行數:70,代碼來源:presets_dlgs.py


注:本文中的PyQt5.QtWidgets.QLineEdit.home方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。