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


Python QTextEdit.append方法代码示例

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


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

示例1: DownloadDialog

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

    def __init__(self, gui, icon, do_user_config):
        QDialog.__init__(self, gui)
        self.gui = gui
        self.do_user_config = do_user_config

        # The current database shown in the GUI
        self.db = gui.current_db

        self.prefs = PrefsFacade(self.db)

        self.version = Downloader.version

        # The GUI, created and layouted by hand...
        self.layout = QVBoxLayout()
        self.setLayout(self.layout)

        self.setWindowTitle('Beam EBooks Downloader')
        self.setWindowIcon(icon)

        self.log_area = QTextEdit('Log output', self)
        self.log_area.setReadOnly(True)
        self.log_area.setLineWrapMode(QTextEdit.NoWrap);
        self.log_area.setText("")
        self.layout.addWidget(self.log_area)

        self.download_button = QPushButton('Download books', self)
        self.download_button.clicked.connect(self.download)
        self.layout.addWidget(self.download_button)

        self.conf_button = QPushButton('Configure this plugin', self)
        self.conf_button.clicked.connect(self.config)
        self.layout.addWidget(self.conf_button)

        self.resize(self.sizeHint())


    def config(self):
        self.do_user_config(parent=self)
        # Apply the changes
        # Not necessary, the downloader will obtain fresh config anyway...
        # self.label.setText(prefs['hello_world_msg'])


    def notify(self, message = None):
        if message is not None:
            # insertPlainText inserts at the beginning of the log area...
            self.log_area.append(message)
            sb = self.log_area.verticalScrollBar()
            sb.setValue(sb.maximum())


    def download(self):
        prefs = self.prefs

        self.download_button.setEnabled(False)
        self.conf_button.setEnabled(False)

        downloader = BeamEbooksDownloader(self.prefs, self.version, caller = self)
        self.notify("Downloader is: %s" % (downloader))

        # Loop over all accounts until we have support for selection
        for account_id in prefs[prefs.ACCOUNTS]:
            account = prefs[prefs.ACCOUNTS][account_id]
            account[prefs.ACCOUNT_ID] = account_id

            if account[prefs.ENABLED]:
                self.enqueue(account, downloader)

        self.hide()


    def enqueue(self, account, downloader):
        prefs = self.prefs

        self.notify("Account: '%s'" % account[prefs.USERNAME])
        # downloader.login(account)

        func = 'arbitrary_n'
        # func = 'arbitrary'
        cpus = self.gui.job_manager.server.pool_size
        print "CPUs: %s" % (cpus)
        args = ['calibre_plugins.beam_ebooks_downloader.jobs', 'do_obtain_new_books', (cpus, account)]
        desc = 'Beam EBooks Downloader'
        job = self.gui.job_manager.run_job(Dispatcher(self._done), func, args=args, description=desc)
        print "Job: %s" % (job)

        self.notify("  Start parsing OPDS catalog")

        # if downloader.successful_login == False:
        #     self.notify("Failed to log in...")
        # else:
        #     self.notify("Scanning (beam) private library now...")
        #     downloader.recursive_descent(norms(prefs[prefs.URLBASE]))

    def _done(self, job):
        print "Done Downloading"
        print "Self: %s" % (self)
        print "Job: %s" % (job)
#.........这里部分代码省略.........
开发者ID:hakan42,项目名称:calibre-beam-ebooks-downloader-plugin,代码行数:103,代码来源:gui.py


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