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_()

Python——PyQt GUI编程(python programming)的更多相关文章

  1. Python的GUI编程(TK)

    TK在大多数 Unix平台.Windows平台和Macintosh系统都是预装好的,TKinter 模块是 Tk GUI 套件的标准Python接口.可实现Python的GUI编程. Tkinter模 ...

  2. Python笔记_第四篇_高阶编程_GUI编程之Tkinter_1.使用Python进行GUI编程的概述

    1. GUI概述: GUI全称为Graphical User Interface,叫做图形用户界面,也是一种交互方式(Interaction).早期计算机使用的命令行界面(command-line i ...

  3. Python之GUI编程(Tkinter))

    不足之处,还请海涵,请指出不足.本人发布过的文章,会不断更改,力求减少错误信息. 一.重要放在开头:模块 如出现这种错误 ModuleNotFoundError: No module named 'n ...

  4. Python进阶--GUI编程

    一.图形用户图面(GUI编程) 1. wxpython下载和安装: 下载url: http://wxpython.org/download.php 2.创建示例GUI应用程序 : ①开始需要导入wx ...

  5. 【Python】Python PYQT4 GUI编程与exe打包

    本篇文章承接http://www.cnblogs.com/zhang-zhi/p/7646923.html#3807385,上篇文章描述了对文本文件的简单处理,本章节结合PYQT4实现该功能的GUI图 ...

  6. python中gui编程的模块之一:tkinter(python3.x中是tkinter,小写的t)

    一.tkinter是python的标准gui库,tkinter是内置在python的安装包之中的,所以安装好python之后就可以import导入tkinter模块了 二.创建一个GUI程序 1.导入 ...

  7. python之GUI编程(二)win10 64位 pygame的安装

    pygame的下载网址: http://www.pygame.org/download.shtml 我下载了第一个 很显然,安装的时候出现了如图中的尴尬,更改了安装目录后,在Python shell中 ...

  8. python之GUI编程-tkinter学习

    推荐几个学习网址:https://www.cnblogs.com/shwee/p/9427975.html https://cloud.tencent.com/developer/section/13 ...

  9. python之Gui编程事件绑定 2014-4-8

    place() 相对定位与绝对定位 相对定位 拖动会发生变化 绝对定位不会from Tkinter import *root = Tk()# Absolute positioningButton(ro ...

随机推荐

  1. nw 引用 sqlite

    0.好吧,这对于我这个c 小白来说,真的有点难度. 1.安装Python 2.7.14 https://www.python.org/downloads/ 2.安装最新的nodejs+npm http ...

  2. MHA(上)

    一.mysql-mha环境准备 1.准备工作 1.1 实验环境: 1.2 软件包 用到的所有包 链接:https://pan.baidu.com/s/19tiKXNEW4C6oWi9OFmcDYA 提 ...

  3. react native原生模块引用本地jar包

    比如module目录结构是这样的: 然后libs中的目录是这样的: 只要在build.gradle中加入这段代码就行了 sourceSets { main { manifest.srcFile 'An ...

  4. Spring源码学习笔记1

    1.Spring中最核心的两个类 1)DefaultListableBeanFactory XmlBeanFactory继承自DefaultListableBeanFactory,DefaultLis ...

  5. Container 组件

      Container 组件       padding: const EdgeInsets.fromLTRB(10, 0, 30, 0),//内边距 margin: const EdgeInsets ...

  6. npm install详解

    package.json中dependencies和devDependencies的部分都会被安装,区别在于前者用于生产环境,后者用于开发环境-g 表示全局安装,通常用于安装脚手架等工具–save(- ...

  7. XAF创建一个DashBoard

    1.首先启动windows程序之后点击DashBoard导航栏 2.接着点击新建按钮,开始创建一个DashBoard 3.接着根据你的数据来源选择数据源,这里我选择了数据库 4.接着填好你的服务器和数 ...

  8. JMeter中Ultimate Thread Group插件使用

    JMeter下载地址:  http://jmeter.apache.org/Ultimate Thread Group插件下载地址: https://jmeter-plugins.org/get/ 一 ...

  9. linux 在后台常驻运行php脚本

    php a.php &

  10. D类IP地址和组播传输

    在224.0.0.0-239.255.255.255范围内的地址称为D类IP组播地址.其中,224.0.0.0-224.0.0.255为预留的组播地址(永久组地址),地址224.0.0.0保留不做分配 ...