zoukankan      html  css  js  c++  java
  • PyQt: eg2

    #coding:utf-8
    
    from __future__ import division
    import sys
    from math import *
    from PyQt4 import QtCore
    from PyQt4 import QtGui
    
    
    class Form(QtGui.QDialog):
    
        def __init__(self, parent=None):
            super(Form, self).__init__(parent)
            self.browser = QtGui.QTextBrowser()
            self.lineedit = QtGui.QLineEdit("Type an expression and press Enter")
            self.lineedit.selectAll()  #设置文本全选
            layout = QtGui.QVBoxLayout()
            layout.addWidget(self.browser)
            layout.addWidget(self.lineedit)
            self.setLayout(layout)
            self.lineedit.setFocus()  #设置光标定位
            self.connect(self.lineedit, QtCore.SIGNAL("returnPressed()"), self.updateUi)
            self.setWindowTitle("Calculate")
    
        def updateUi(self):
            try:
                text = unicode(self.lineedit.text())
                self.browser.append("{}={}".format(text,eval(text)))
            except:
                self.browser.append(u"{} is invalid".format(text))
    
    app = QtGui.QApplication(sys.argv)
    form = Form()
    form.show()
    app.exec_()
  • 相关阅读:
    爬虫案例
    伪静态
    HTTP0.9、HTTP1.0、HTTP1.1、HTTP2的区别
    正向代理和反向代理
    数据结构继承
    APP 爬虫
    算法基础
    matplotlib
    Java类加载机制及自定义加载器
    SpringBoot war包部署到Tomcat服务器
  • 原文地址:https://www.cnblogs.com/lypy/p/6394194.html
Copyright © 2011-2022 走看看