当前位置: 首页>>代码示例>>Python>>正文


Python QTextEdit.setText方法代码示例

本文整理汇总了Python中PyQt5.Qt.QTextEdit.setText方法的典型用法代码示例。如果您正苦于以下问题:Python QTextEdit.setText方法的具体用法?Python QTextEdit.setText怎么用?Python QTextEdit.setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.Qt.QTextEdit的用法示例。


在下文中一共展示了QTextEdit.setText方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ThemeCreateDialog

# 需要导入模块: from PyQt5.Qt import QTextEdit [as 别名]
# 或者: from PyQt5.Qt.QTextEdit import setText [as 别名]
class ThemeCreateDialog(Dialog):

    def __init__(self, parent, report):
        self.report = report
        Dialog.__init__(self, _('Create an icon theme'), 'create-icon-theme', parent)

    def setup_ui(self):
        self.splitter = QSplitter(self)
        self.l = l = QVBoxLayout(self)
        l.addWidget(self.splitter)
        l.addWidget(self.bb)
        self.w = w = QGroupBox(_('Theme Metadata'), self)
        self.splitter.addWidget(w)
        l = w.l = QFormLayout(w)
        l.setFieldGrowthPolicy(l.ExpandingFieldsGrow)
        self.missing_icons_group = mg = QGroupBox(self)
        self.mising_icons = mi = QListWidget(mg)
        mi.setSelectionMode(mi.NoSelection)
        mg.l = QVBoxLayout(mg)
        mg.l.addWidget(mi)
        self.splitter.addWidget(mg)
        self.title = QLineEdit(self)
        l.addRow(_('&Title:'), self.title)
        self.author = QLineEdit(self)
        l.addRow(_('&Author:'), self.author)
        self.version = v = QSpinBox(self)
        v.setMinimum(1), v.setMaximum(1000000)
        l.addRow(_('&Version:'), v)
        self.license = lc = QLineEdit(self)
        l.addRow(_('&License:'), lc)
        self.url = QLineEdit(self)
        l.addRow(_('&URL:'), self.url)
        lc.setText(_(
            'The license for the icons in this theme. Common choices are'
            ' Creative Commons or Public Domain.'))
        self.description = QTextEdit(self)
        l.addRow(self.description)
        self.refresh_button = rb = self.bb.addButton(_('&Refresh'), self.bb.ActionRole)
        rb.setIcon(QIcon(I('view-refresh.png')))
        rb.clicked.connect(self.refresh)

        self.apply_report()

    def sizeHint(self):
        return QSize(900, 670)

    @property
    def metadata(self):
        self.report.theme.title = self.title.text().strip()  # Needed for report.name to work
        return {
            'title': self.title.text().strip(),
            'author': self.author.text().strip(),
            'version': self.version.value(),
            'description': self.description.toPlainText().strip(),
            'number': len(self.report.name_map) - len(self.report.extra),
            'date': utcnow().date().isoformat(),
            'name': self.report.name,
            'license': self.license.text().strip() or 'Unknown',
            'url': self.url.text().strip() or None,
        }

    def save_metadata(self):
        with open(os.path.join(self.report.path, THEME_METADATA), 'wb') as f:
            json.dump(self.metadata, f, indent=2)

    def refresh(self):
        self.save_metadata()
        self.report = read_theme_from_folder(self.report.path)
        self.apply_report()

    def apply_report(self):
        theme = self.report.theme
        self.title.setText((theme.title or '').strip())
        self.author.setText((theme.author or '').strip())
        self.version.setValue(theme.version or 1)
        self.description.setText((theme.description or '').strip())
        self.license.setText((theme.license or 'Unknown').strip())
        self.url.setText((theme.url or '').strip())
        if self.report.missing:
            title =  _('%d icons missing in this theme') % len(self.report.missing)
        else:
            title = _('No missing icons')
        self.missing_icons_group.setTitle(title)
        mi = self.mising_icons
        mi.clear()
        for name in sorted(self.report.missing):
            QListWidgetItem(QIcon(I(name, allow_user_override=False)), name, mi)

    def accept(self):
        mi = self.metadata
        if not mi.get('title'):
            return error_dialog(self, _('No title specified'), _(
                'You must specify a title for this icon theme'), show=True)
        if not mi.get('author'):
            return error_dialog(self, _('No author specified'), _(
                'You must specify an author for this icon theme'), show=True)
        return Dialog.accept(self)
开发者ID:davidfor,项目名称:calibre,代码行数:99,代码来源:icon_theme.py

示例2: CheckLibraryDialog

# 需要导入模块: from PyQt5.Qt import QTextEdit [as 别名]
# 或者: from PyQt5.Qt.QTextEdit import setText [as 别名]
class CheckLibraryDialog(QDialog):

    def __init__(self, parent, db):
        QDialog.__init__(self, parent)
        self.db = db

        self.setWindowTitle(_('Check Library -- Problems Found'))
        self.setWindowIcon(QIcon(I('debug.png')))

        self._tl = QHBoxLayout()
        self.setLayout(self._tl)
        self.splitter = QSplitter(self)
        self.left = QWidget(self)
        self.splitter.addWidget(self.left)
        self.helpw = QTextEdit(self)
        self.splitter.addWidget(self.helpw)
        self._tl.addWidget(self.splitter)
        self._layout = QVBoxLayout()
        self.left.setLayout(self._layout)
        self.helpw.setReadOnly(True)
        self.helpw.setText(_('''\
        <h1>Help</h1>

        <p>calibre stores the list of your books and their metadata in a
        database. The actual book files and covers are stored as normal
        files in the calibre library folder. The database contains a list of the files
        and covers belonging to each book entry. This tool checks that the
        actual files in the library folder on your computer match the
        information in the database.</p>

        <p>The result of each type of check is shown to the left. The various
        checks are:
        </p>
        <ul>
        <li><b>Invalid titles</b>: These are files and folders appearing
        in the library where books titles should, but that do not have the
        correct form to be a book title.</li>
        <li><b>Extra titles</b>: These are extra files in your calibre
        library that appear to be correctly-formed titles, but have no corresponding
        entries in the database</li>
        <li><b>Invalid authors</b>: These are files appearing
        in the library where only author folders should be.</li>
        <li><b>Extra authors</b>: These are folders in the
        calibre library that appear to be authors but that do not have entries
        in the database</li>
        <li><b>Missing book formats</b>: These are book formats that are in
        the database but have no corresponding format file in the book's folder.
        <li><b>Extra book formats</b>: These are book format files found in
        the book's folder but not in the database.
        <li><b>Unknown files in books</b>: These are extra files in the
        folder of each book that do not correspond to a known format or cover
        file.</li>
        <li><b>Missing cover files</b>: These represent books that are marked
        in the database as having covers but the actual cover files are
        missing.</li>
        <li><b>Cover files not in database</b>: These are books that have
        cover files but are marked as not having covers in the database.</li>
        <li><b>Folder raising exception</b>: These represent folders in the
        calibre library that could not be processed/understood by this
        tool.</li>
        </ul>

        <p>There are two kinds of automatic fixes possible: <i>Delete
        marked</i> and <i>Fix marked</i>.</p>
        <p><i>Delete marked</i> is used to remove extra files/folders/covers that
        have no entries in the database. Check the box next to the item you want
        to delete. Use with caution.</p>

        <p><i>Fix marked</i> is applicable only to covers and missing formats
        (the three lines marked 'fixable'). In the case of missing cover files,
        checking the fixable box and pushing this button will tell calibre that
        there is no cover for all of the books listed. Use this option if you
        are not going to restore the covers from a backup. In the case of extra
        cover files, checking the fixable box and pushing this button will tell
        calibre that the cover files it found are correct for all the books
        listed. Use this when you are not going to delete the file(s). In the
        case of missing formats, checking the fixable box and pushing this
        button will tell calibre that the formats are really gone. Use this if
        you are not going to restore the formats from a backup.</p>

        '''))

        self.log = QTreeWidget(self)
        self.log.itemChanged.connect(self.item_changed)
        self.log.itemExpanded.connect(self.item_expanded_or_collapsed)
        self.log.itemCollapsed.connect(self.item_expanded_or_collapsed)
        self._layout.addWidget(self.log)

        self.check_button = QPushButton(_('&Run the check again'))
        self.check_button.setDefault(False)
        self.check_button.clicked.connect(self.run_the_check)
        self.copy_button = QPushButton(_('Copy &to clipboard'))
        self.copy_button.setDefault(False)
        self.copy_button.clicked.connect(self.copy_to_clipboard)
        self.ok_button = QPushButton(_('&Done'))
        self.ok_button.setDefault(True)
        self.ok_button.clicked.connect(self.accept)
        self.mark_delete_button = QPushButton(_('Mark &all for delete'))
        self.mark_delete_button.setToolTip(_('Mark all deletable subitems'))
        self.mark_delete_button.setDefault(False)
#.........这里部分代码省略.........
开发者ID:Aliminator666,项目名称:calibre,代码行数:103,代码来源:check_library.py

示例3: LedgerAuthDialog

# 需要导入模块: from PyQt5.Qt import QTextEdit [as 别名]
# 或者: from PyQt5.Qt.QTextEdit import setText [as 别名]

#.........这里部分代码省略.........
        vbox.addWidget(self.cardbox)
        
        self.pairbox = QWidget()
        pairlayout = QVBoxLayout()
        self.pairbox.setLayout(pairlayout)
        pairhelp = QTextEdit(helpTxt[5])
        pairhelp.setStyleSheet("QTextEdit { background-color: lightgray; }")
        pairhelp.setReadOnly(True)
        pairlayout.addWidget(pairhelp, 1)
        self.pairqr = QRCodeWidget()
        pairlayout.addWidget(self.pairqr, 4)
        self.pairbox.setVisible(False)
        vbox.addWidget(self.pairbox)
        self.update_dlg()
        
        if self.cfg['mode'] > 1 and not self.ws:
            self.req_validation()
        
    def populate_modes(self):
        self.modes.blockSignals(True)
        self.modes.clear()
        self.modes.addItem(_("Summary Text PIN (requires dongle replugging)") if self.txdata['confirmationType'] == 1 else _("Summary Text PIN is Disabled"))
        if self.txdata['confirmationType'] > 1:
            self.modes.addItem(_("Security Card Challenge"))
            if not self.cfg['pair']:
                self.modes.addItem(_("Mobile - Not paired")) 
            else:
                self.modes.addItem(_("Mobile - %s") % self.cfg['pair'][1]) 
        self.modes.blockSignals(False)
        
    def update_dlg(self):
        self.modes.setCurrentIndex(self.cfg['mode'])
        self.modebox.setVisible(True)
        self.addPair.setText(_("Pair") if not self.cfg['pair'] else _("Re-Pair"))
        self.addPair.setVisible(self.txdata['confirmationType'] > 2)
        self.helpmsg.setText(helpTxt[self.cfg['mode'] if self.cfg['mode'] < 2 else 2 if self.cfg['pair'] else 4])
        self.helpmsg.setMinimumHeight(180 if self.txdata['confirmationType'] == 1 else 100)
        self.pairbox.setVisible(False)
        self.helpmsg.setVisible(True)
        self.pinbox.setVisible(self.cfg['mode'] == 0)
        self.cardbox.setVisible(self.cfg['mode'] == 1)
        self.pintxt.setFocus(True) if self.cfg['mode'] == 0 else self.cardtxt.setFocus(True)
        self.setMaximumHeight(200)
        
    def do_pairing(self):
        rng = os.urandom(16)
        pairID = (hexlify(rng) + hexlify(hashlib.sha256(rng).digest()[0:1])).decode('utf-8')
        self.pairqr.setData(pairID)
        self.modebox.setVisible(False)
        self.helpmsg.setVisible(False)
        self.pinbox.setVisible(False)
        self.cardbox.setVisible(False)
        self.pairbox.setVisible(True)
        self.pairqr.setMinimumSize(300,300)
        if self.ws:
            self.ws.stop()
        self.ws = LedgerWebSocket(self, pairID)
        self.ws.pairing_done.connect(self.pairing_done)
        self.ws.start() 
               
    def pairing_done(self, data):
        if data is not None:
            self.cfg['pair'] = [ data['pairid'], data['name'], data['platform'] ]
            self.cfg['mode'] = 2
            self.handler.win.wallet.get_keystore().cfg = self.cfg
            self.handler.win.wallet.save_keystore()
开发者ID:JustinTArthur,项目名称:electrum,代码行数:70,代码来源:auth2fa.py

示例4: show_side_pane

# 需要导入模块: from PyQt5.Qt import QTextEdit [as 别名]
# 或者: from PyQt5.Qt.QTextEdit import setText [as 别名]
    def show_side_pane(self):
        if self.count() < 2 or not self.is_side_index_hidden:
            return
        if self.desired_side_size == 0:
            self.desired_side_size = self.initial_side_size
        self.apply_state((True, self.desired_side_size))

    def hide_side_pane(self):
        if self.count() < 2 or self.is_side_index_hidden:
            return
        self.apply_state((False, self.desired_side_size))

    def double_clicked(self, *args):
        self.toggle_side_pane()

    # }}}

# }}}


if __name__ == '__main__':
    from PyQt5.Qt import QTextEdit
    app = QApplication([])
    w = QTextEdit()
    s = PythonHighlighter(w)
    # w.setSyntaxHighlighter(s)
    w.setText(open(__file__, 'rb').read().decode('utf-8'))
    w.show()
    app.exec_()
开发者ID:JimmXinu,项目名称:calibre,代码行数:31,代码来源:widgets.py

示例5: EditQDialog

# 需要导入模块: from PyQt5.Qt import QTextEdit [as 别名]
# 或者: from PyQt5.Qt.QTextEdit import setText [as 别名]
class EditQDialog(QDialog):
    """
        Class who create Edit QDialog to edit text in Alignak-app
    """

    def __init__(self, parent=None):
        super(EditQDialog, self).__init__(parent)
        self.setWindowTitle('Edit Dialog')
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setStyleSheet(settings.css_style)
        self.setWindowIcon(QIcon(settings.get_image('icon')))
        self.setObjectName('dialog')
        self.setFixedSize(300, 300)
        # Fields
        self.text_edit = QTextEdit()
        self.old_text = ''

    def initialize(self, title, text):
        """
        Initialize QDialog for UserNotesQDialog

        :param title: title of the QDialog
        :type title: str
        :param text: text to edit
        :type text: str
        """

        self.old_text = text
        center_widget(self)

        # Main status_layout
        main_layout = QVBoxLayout(self)
        main_layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(main_layout)

        main_layout.addWidget(get_logo_widget(self, title))

        text_title = QLabel(_("Edit your text:"))
        text_title.setObjectName('subtitle')
        main_layout.addWidget(text_title)
        main_layout.setAlignment(text_title, Qt.AlignCenter)

        main_layout.addWidget(self.get_text_widget())

    def get_text_widget(self):
        """
        Return text QWidget with QTextEdit

        :return: text QWidget
        :rtype: QWidget
        """

        text_widget = QWidget()
        text_widget.setObjectName('dialog')
        text_layout = QVBoxLayout()
        text_widget.setLayout(text_layout)

        self.text_edit.setPlaceholderText(_('type your text...'))
        self.text_edit.setText(self.old_text)
        text_layout.addWidget(self.text_edit)

        # Accept button
        accept_btn = QPushButton(_('Confirm'), self)
        accept_btn.clicked.connect(self.accept_text)
        accept_btn.setObjectName('valid')
        accept_btn.setMinimumHeight(30)
        text_layout.addWidget(accept_btn)

        return text_widget

    def accept_text(self):
        """
        Set Edit QDialog to Rejected or Accepted (prevent to patch for nothing)

        """

        if self.old_text == self.text_edit.toPlainText():
            self.reject()
        elif not self.old_text or self.old_text.isspace():
            if not self.text_edit.toPlainText() or self.text_edit.toPlainText().isspace():
                self.reject()
            else:
                self.accept()
        else:
            self.accept()
开发者ID:Alignak-monitoring-contrib,项目名称:alignak-app,代码行数:87,代码来源:dialogs.py

示例6: ExportToSqlite

# 需要导入模块: from PyQt5.Qt import QTextEdit [as 别名]
# 或者: from PyQt5.Qt.QTextEdit import setText [as 别名]

#.........这里部分代码省略.........
            result = self.database.select("*","gm_perso",True,'name=="'+heros+'" AND ID_groupe=='+str(id_groupe))
            self.nb_heros_inserted[1] = self.nb_heros_inserted[1] + 1
        else:
            self.nb_heros_unchanged[1] = self.nb_heros_unchanged[1] + 1 
        return result
    
    @staticmethod
    def hasSubGroup (path):
        sub_list = os.listdir (path)
        print ('hasSubGroup',sub_list)
        if len(sub_list)!= 0 and os.path.isdir(os.path.join(path,sub_list[0])):
            sub_list2 = os.listdir(os.path.join(path,sub_list[0]))
            print ('sub_list_2',sub_list2)
            if os.path.isdir(os.path.join(path,sub_list[0],sub_list2[0])):
                print ('return true')
                return True
        return False
    


    def process (self, faction,empire,kingdom):
        super(ExportToSqlite,self).process(faction,empire,kingdom)
        self.progress.setLabelText("Export to sqlite")
        self.progress.setMinimum(0)
        self.progress.setMaximum(self.total_heros)
        
        self.success = False
        nb_heros = 0        
        #si la faction n existe pas encore la creer
        result = self.addFaction (self.faction)
        result.next()
        print ('result',result.value("name"))
        id_faction = result.value("ID")
        print ('ID faction',id_faction)
        #si l empire n existe pas encore le creer
        color = ""
        empire = self.empire
        if len(self.empire.split["-"])>=2 :
            color = self.empire.split["-"][1]
            empire = self.empire.split["-"][0]
        result = self.addEmpire(empire,id_faction,color)
        result.next()
        id_empire= result.value("ID")
        print ('ID empire',id_empire)
        #si le royaume n existe pas encore le creer
        result = self.addKingdom(self.kingdom,id_empire)
        result.next() 
        id_kingdom= result.value("ID")            
        print ('ID kingdom',id_kingdom)
        list_group = list(filter(SqliteModel.isValid,os.listdir (self.fullPath)))
        for group in list_group : 
            result = self.addGroupe(group,id_kingdom)
            result.next()
            id_groupe= result.value("ID")            
            currentPath = os.path.join(self.fullPath,group)
            if (ExportToSqlite.hasSubGroup(currentPath)):
                list_sub_group = list(filter(SqliteModel.isValid,os.listdir(currentPath))) 
                id_master_group = id_groupe
                for sub in list_sub_group :
                    result = self.addGroupe(sub, id_kingdom, id_master_group)
                    result.next()
                    id_groupe= result.value("ID")
                    list_heros = list(filter(SqliteModel.isValid,os.listdir(os.path.join(currentPath,sub))))
                    for heros in list_heros :
                        self.createDescriptionFile(heros,os.path.join(currentPath,sub,heros))
                        self.addHeros(heros,id_groupe)
                        nb_heros+=1
                        self.progress.setValue(nb_heros)      
            else:
                list_heros = list(filter(SqliteModel.isValid,os.listdir(currentPath)))
                for heros in list_heros :
                    self.createDescriptionFile(heros,os.path.join(currentPath,heros))
                    self.success = True
                    self.addHeros(heros,id_groupe)
                    nb_heros+=1       
                    self.progress.setValue(nb_heros)
            if self.stop == True :
                break
            
        self.progress.setValue(self.total_heros)
        result_info = [self.nb_faction_inserted,self.nb_empire_inserted,self.nb_kingdom_inserted,self.nb_groupes_inserted,self.nb_heros_inserted,self.nb_faction_unchanged,self.nb_empire_unchanged,self.nb_kingdom_unchanged,self.nb_groupes_unchanged,self.nb_heros_unchanged]
        self.showResultInfos(result_info)



    def createDescriptionFile(self, name, path_file):
        file_name = "description.html"

        file = open(os.path.join(Config().instance.settings.value("global/resources_path"),"template_profil.html"))
        ddd = file.read()
        print ('ooooo',type(ddd))
        ddd = ddd.replace("tname",name)
        print ('mmmm',ddd)
        chemin = os.path.join(path_file,file_name)
        if (not os.path.exists(chemin)):
            self.textEdit = QTextEdit()

            self.textEdit.setText(ddd)
            writer = QTextDocumentWriter(chemin)
            success = writer.write(self.textEdit.document())
开发者ID:cyril711,项目名称:git-MythicWar,代码行数:104,代码来源:export_to_sqlite.py

示例7: ConfigWidget

# 需要导入模块: from PyQt5.Qt import QTextEdit [as 别名]
# 或者: from PyQt5.Qt.QTextEdit import setText [as 别名]
class ConfigWidget(QWidget):

    def __init__(self):
        QWidget.__init__(self)
        
        self.setWindowTitle('exlibris preferences')
        
        row = 0
        self.l = QGridLayout()
        self.setLayout(self.l)
        
        self.label_xhtml_filename = QLabel('Ex libris XHTML filename:')
        self.xhtml_filename = QLineEdit(self)
        self.xhtml_filename.setText(prefs['xhtml_filename'])
        self.button_xhtml_filename = QPushButton('Change', self)
        self.button_xhtml_filename.clicked.connect(self.button_xhtml_filename_handler)
        
        self.l.addWidget(self.label_xhtml_filename, row, 1)
        row += 1
        self.l.addWidget(self.xhtml_filename, row, 1)
        self.l.addWidget(self.button_xhtml_filename, row, 2)
        row += 1
        
        self.l.addWidget(QLabel(''), row, 1)
        row += 1

        self.label_include_dir = QLabel('Include additional files from directory:')
        self.checkbox_include_dir = QCheckBox('', self)
        self.checkbox_include_dir.setChecked(prefs['checkbox_include_dir'] == 'True')
        self.include_dir = QLineEdit(self)
        self.include_dir.setText(prefs['include_dir'])
        self.button_include_dir = QPushButton('Change', self)
        self.button_include_dir.clicked.connect(self.button_include_dir_handler)
        
        self.l.addWidget(self.checkbox_include_dir, row, 0)
        self.l.addWidget(self.label_include_dir, row, 1)
        row += 1
        self.l.addWidget(self.include_dir, row, 1)
        self.l.addWidget(self.button_include_dir, row, 2)
        row += 1
        
        self.l.addWidget(QLabel(''), row, 1)
        row += 1
        
        self.label_include_guide_text = QLabel('Include in guide with string:')
        self.checkbox_include_guide_text = QCheckBox('', self)
        self.checkbox_include_guide_text.setChecked(prefs['checkbox_include_guide_text'] == 'True')
        self.include_guide_text = QLineEdit(self)
        self.include_guide_text.setText(prefs['include_guide_text'])
        
        self.l.addWidget(self.checkbox_include_guide_text, row, 0)
        self.l.addWidget(self.label_include_guide_text, row, 1)
        row += 1
        self.l.addWidget(self.include_guide_text, row, 1)
        row += 1
        
        self.l.addWidget(QLabel(''), row, 1)
        row += 1
        
        self.label_include_toc_text = QLabel('Include in TOC with string:')
        self.checkbox_include_toc_text = QCheckBox('', self)
        self.checkbox_include_toc_text.setChecked(prefs['checkbox_include_toc_text'] == 'True')
        self.include_toc_text = QLineEdit(self)
        self.include_toc_text.setText(prefs['include_toc_text'])
        
        self.l.addWidget(self.checkbox_include_toc_text, row, 0)
        self.l.addWidget(self.label_include_toc_text, row, 1)
        row += 1
        self.l.addWidget(self.include_toc_text, row, 1)
        row += 1
        
        self.l.addWidget(QLabel(''), row, 1)
        row += 1
        
        self.label_ask_replace = QLabel('Ask before replacing book in library')
        self.checkbox_ask_replace = QCheckBox('', self)
        self.checkbox_ask_replace.setChecked(prefs['checkbox_ask_replace'] == 'True')
        self.l.addWidget(self.checkbox_ask_replace, row, 0)
        self.l.addWidget(self.label_ask_replace, row, 1)
        row += 1
        
        self.label_disable_first_last_only = QLabel('When multiple EPUB files are selected, allow insertion points other than "1", "first", and "last"')
        self.checkbox_disable_first_last_only = QCheckBox('', self)
        self.checkbox_disable_first_last_only.setChecked(prefs['checkbox_disable_first_last_only'] == 'True')
        self.l.addWidget(self.checkbox_disable_first_last_only, row, 0)
        self.l.addWidget(self.label_disable_first_last_only, row, 1)
        row += 1
        
        self.l.addWidget(QLabel(''), row, 1)
        row += 1
        
        self.label_replace_strings = QLabel('Replace strings:')
        self.replace_strings = QTextEdit(self)
        self.replace_strings.setText(prefs['replace_strings'])
        self.label_supportedMetadata = QLabel('Supported metadata:')
        self.supportedMetadata = QListWidget(self)
        #QtCore.QObject.connect(self.supportedMetadata, QtCore.SIGNAL("doubleClicked()"), self.add_replace_string)
        self.supportedMetadata.doubleClicked.connect(self.add_replace_string)
        
        producer = exlibris()
#.........这里部分代码省略.........
开发者ID:pettarin,项目名称:exlibris,代码行数:103,代码来源:config.py

示例8: DownQDialog

# 需要导入模块: from PyQt5.Qt import QTextEdit [as 别名]
# 或者: from PyQt5.Qt.QTextEdit import setText [as 别名]

#.........这里部分代码省略.........
            )
        )
        fixed_info.setWordWrap(True)
        downtime_layout.addWidget(fixed_info, 3, 0, 1, 3)

        duration_label = QLabel(_('Duration'))
        duration_label.setObjectName('subtitle')
        downtime_layout.addWidget(duration_label, 4, 0, 1, 1)

        duration_clock = QLabel()
        duration_clock.setPixmap(QPixmap(settings.get_image('time')))
        downtime_layout.addWidget(duration_clock, 4, 1, 1, 1)
        duration_clock.setFixedSize(16, 16)
        duration_clock.setScaledContents(True)

        self.duration.setTime(QTime(4, 00))
        self.duration.setDisplayFormat("HH'h'mm")
        downtime_layout.addWidget(self.duration, 4, 2, 1, 1)

        duration_info = QLabel(
            _('Sets the duration if it is a non-fixed downtime.')
        )
        downtime_layout.addWidget(duration_info, 5, 0, 1, 3)

        date_range_label = QLabel(_('Downtime date range'))
        date_range_label.setObjectName('subtitle')
        downtime_layout.addWidget(date_range_label, 6, 0, 1, 1)

        calendar_label = QLabel()
        calendar_label.setPixmap(QPixmap(settings.get_image('calendar')))
        calendar_label.setFixedSize(16, 16)
        calendar_label.setScaledContents(True)
        downtime_layout.addWidget(calendar_label, 6, 1, 1, 1)

        start_time_label = QLabel(_('Start time:'))
        downtime_layout.addWidget(start_time_label, 7, 0, 1, 1)

        self.start_time.setCalendarPopup(True)
        self.start_time.setDateTime(datetime.datetime.now())
        self.start_time.setDisplayFormat("dd/MM/yyyy HH'h'mm")
        downtime_layout.addWidget(self.start_time, 7, 1, 1, 2)

        end_time_label = QLabel(_('End time:'))
        downtime_layout.addWidget(end_time_label, 8, 0, 1, 1)

        self.end_time.setCalendarPopup(True)
        self.end_time.setDateTime(datetime.datetime.now() + datetime.timedelta(hours=2))
        self.end_time.setDisplayFormat("dd/MM/yyyy HH'h'mm")
        downtime_layout.addWidget(self.end_time, 8, 1, 1, 2)

        self.comment_edit.setText(comment)
        self.comment_edit.setMaximumHeight(60)
        downtime_layout.addWidget(self.comment_edit, 9, 0, 1, 3)

        request_btn = QPushButton(_('REQUEST DOWNTIME'), self)
        request_btn.clicked.connect(self.handle_accept)
        request_btn.setObjectName('valid')
        request_btn.setMinimumHeight(30)
        request_btn.setDefault(True)
        downtime_layout.addWidget(request_btn, 10, 0, 1, 3)

        main_layout.addWidget(downtime_widget)

    def duration_to_seconds(self):
        """
        Return "duration" QTimeEdit value in seconds

        :return: "duration" in seconds
        :rtype: int
        """

        return QTime(0, 0).secsTo(self.duration.time())

    def handle_accept(self):
        """
        Check if end_time timestamp is not lower than start_time

        """

        if self.start_time.dateTime().toTime_t() > self.end_time.dateTime().toTime_t():
            logger.warning('Try to add Downtime with "End Time" lower than "Start Time"')
        else:
            self.accept()

    def mousePressEvent(self, event):  # pragma: no cover
        """ QWidget.mousePressEvent(QMouseEvent) """

        self.offset = event.pos()

    def mouseMoveEvent(self, event):  # pragma: no cover
        """ QWidget.mousePressEvent(QMouseEvent) """

        try:
            x = event.globalX()
            y = event.globalY()
            x_w = self.offset.x()
            y_w = self.offset.y()
            self.move(x - x_w, y - y_w)
        except AttributeError as e:
            logger.warning('Move Event %s: %s', self.objectName(), str(e))
开发者ID:Alignak-monitoring-contrib,项目名称:alignak-app,代码行数:104,代码来源:actions.py

示例9: AckQDialog

# 需要导入模块: from PyQt5.Qt import QTextEdit [as 别名]
# 或者: from PyQt5.Qt.QTextEdit import setText [as 别名]
class AckQDialog(QDialog):
    """
        Class who create Acknowledge QDialog for hosts/services
    """

    def __init__(self, parent=None):
        super(AckQDialog, self).__init__(parent)
        self.setWindowTitle(_('Request an Acknowledge'))
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setStyleSheet(settings.css_style)
        self.setWindowIcon(QIcon(settings.get_image('icon')))
        self.setMinimumSize(370, 480)
        self.setObjectName('dialog')
        # Fields
        self.sticky = True
        self.sticky_toggle_btn = ToggleQWidgetButton()
        self.notify = False
        self.notify_toggle_btn = ToggleQWidgetButton()
        self.ack_comment_edit = None
        self.offset = None

    def initialize(self, item_type, item_name, comment):  # pylint: disable=too-many-locals
        """
        Initialize Acknowledge QDialog

        :param item_type: type of item to acknowledge : host | service
        :type item_type: str
        :param item_name: name of the item to acknowledge
        :type item_name: str
        :param comment: the default comment of action
        :type comment: str
        """

        logger.debug("Create Acknowledge QDialog...")

        # Main status_layout
        center_widget(self)
        main_layout = QVBoxLayout(self)
        main_layout.setContentsMargins(0, 0, 0, 0)

        main_layout.addWidget(get_logo_widget(self, _('Request Acknowledge')))

        ack_widget = QWidget()
        ack_widget.setObjectName('dialog')
        ack_layout = QGridLayout(ack_widget)

        ack_title = QLabel(_('Request an acknowledge'))
        ack_title.setObjectName('itemtitle')
        ack_layout.addWidget(ack_title, 0, 0, 1, 2)

        host_label = QLabel('<b>%s:</b> %s' % (item_type.capitalize(), item_name))
        ack_layout.addWidget(host_label, 1, 0, 1, 1)

        sticky_label = QLabel(_('Acknowledge is sticky:'))
        sticky_label.setObjectName('subtitle')
        ack_layout.addWidget(sticky_label, 2, 0, 1, 1)

        self.sticky_toggle_btn.initialize()
        self.sticky_toggle_btn.update_btn_state(self.sticky)
        ack_layout.addWidget(self.sticky_toggle_btn, 2, 1, 1, 1)

        sticky_info = QLabel(
            _(
                'If checked, '
                'the acknowledge will remain until the element returns to an "OK" state.'
            )
        )
        sticky_info.setWordWrap(True)
        ack_layout.addWidget(sticky_info, 3, 0, 1, 2)

        notify_label = QLabel(_('Acknowledge notifies:'))
        notify_label.setObjectName('subtitle')
        ack_layout.addWidget(notify_label, 4, 0, 1, 1)

        self.notify_toggle_btn.initialize()
        self.notify_toggle_btn.update_btn_state(self.notify)
        ack_layout.addWidget(self.notify_toggle_btn, 4, 1, 1, 1)

        notify_info = QLabel(
            _('If checked, a notification will be sent out to the concerned contacts.')
        )
        notify_info.setWordWrap(True)
        ack_layout.addWidget(notify_info, 5, 0, 1, 2)

        ack_comment = QLabel(_('Acknowledge comment:'))
        ack_comment.setObjectName('subtitle')
        ack_layout.addWidget(ack_comment, 6, 0, 1, 1)

        self.ack_comment_edit = QTextEdit()
        self.ack_comment_edit.setText(comment)
        self.ack_comment_edit.setMaximumHeight(60)
        ack_layout.addWidget(self.ack_comment_edit, 7, 0, 1, 2)

        request_btn = QPushButton(_('REQUEST ACKNOWLEDGE'), self)
        request_btn.clicked.connect(self.accept)
        request_btn.setObjectName('valid')
        request_btn.setMinimumHeight(30)
        request_btn.setDefault(True)
        ack_layout.addWidget(request_btn, 8, 0, 1, 2)

#.........这里部分代码省略.........
开发者ID:Alignak-monitoring-contrib,项目名称:alignak-app,代码行数:103,代码来源:actions.py


注:本文中的PyQt5.Qt.QTextEdit.setText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。