【问题标题】:pyqt Qtextbrowser updatepyqt Qtextbrowser更新
【发布时间】:2016-01-26 22:31:48
【问题描述】:
def sort_domain():
    if self.cb1.isChecked():
        for line in f:
            line= line.strip()
            if line.endswith('.com') is True:
                self.textBrowser.append(line)
            else:
                pass
    elif not self.cb1.isChecked() and not self.cb2.isChecked():
        for line in f:
            line=line.strip()
            self.textBrowser.append(line)
    if self.cb2.isChecked():
        for line in f:
            line= line.strip()
            if line.endswith('.net') is True:
                self.textBrowser.append(line)
            else:
                pass
    elif not self.cb1.isChecked() and not self.cb2.isChecked():
        for line in f:
            line=line.strip()
            self.textBrowser.append(line)

self.btn2.clicked.connect(sort_domain)

如果我检查了 cb1 和 cb2 ((checkbox1 和 chekbok2)) 结果是所有扩展名为 .com 的域。

当您按下 chekBox1 ".com" 和 chekBox2 ".net" 时,编写一个显示所有域的函数的正确方法是什么?

【问题讨论】:

  • 如果这张图片对您的问题有帮助,您应该将其添加到您的问题文本中。您可以在发布任意次数后编辑您的问题 :)
  • 你说“我的问题:”但我没有看到问题。

标签: python pyqt qtextbrowser


【解决方案1】:

您的实现效率并不高:它多次读取文件的内容。这也是你程序的问题。在第一个 for 循环之后,文件对象指向文件的末尾并使其工作,您必须再次寻找开始:f.seek(0)

【讨论】:

    猜你喜欢
    • 2019-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-22
    相关资源
    最近更新 更多