zoukankan      html  css  js  c++  java
  • Python——PyQt GUI编程(python programming)

    Python——PyQt GUI编程(python programming)

    import sys
    from math import *
    from PyQt5.QtCore import *
    from PyQt5.QtGui import *
    from PyQt5.QtWidgets import *
    
    class Form(QDialog):
        def __init__(self, parent=None):
            super().__init__(parent)
            self.browser = QTextBrowser()
            self.lineedit = QLineEdit("Type an expression.")
            self.lineedit.selectAll()
            layout = QVBoxLayout()
            layout.addWidget(self.browser)
            layout.addWidget(self.lineedit)
            self.setLayout(layout)
            self.lineedit.setFocus()
            self.lineedit.returnPressed.connect(self.updateUi)
            self.setWindowTitle("Calculate")
        def updateUi(self):
            try:
                text = str(self.lineedit.text())
                self.browser.append("%s = <b>%s</b>" % (text, eval(text)))
            except:
                self.browser.append("<font color=red>%s is invalid!</font>" % text)
    
    app = QApplication(sys.argv)
    form = Form()
    form.show()
    app.exec_()

  • 相关阅读:

    链表
    Codeforces 1290A/1291C
    Codeforces 1291B
    Codeforces 1291A
    Codeforces 1295C
    Codeforces 1295B
    ZJNU 2356
    ZJNU 2354
    ZJNU 2353
  • 原文地址:https://www.cnblogs.com/caiyishuai/p/13270773.html
Copyright © 2011-2022 走看看