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. 1--Test NG--常见测试和注解

    第一:注解 (1)@test (2)@BeforeMethod,@AfterMethod (3)@BeforeClass,@AfterClass (4)@BeforeSuite,@AfterSuite ...

  2. python中的字典

    字典:由多个键及与其对应的键-值对组成,用:隔开,用花括号 括起来  phone_book={'Daming':'2202','Amy':'5462','Sam':'4785'} dict函数:

  3. 微信小程序页面跳转,带参数跳转

    1.  wx.navigateTo  (保留当前页面,跳转到应用内的某个页面,使用wx.navigateBack可以返回到原页面.) 路径:只能跳转非tabbar路径 参数:  'path?key=v ...

  4. 不使用循环或递归判断一个数是否为3的幂(leetcode 326)

    326. Power of ThreeGiven an integer, write a function to determine if it is a power of three. Follow ...

  5. python学习6---排序问题

    1.对列表排序 一维列表: sorted():可用于任何可迭代对象,如数组.列表.字典等. sort():list.sort()返回None,这是因为sort在函数内部修改了list的值,当再次访问l ...

  6. 在LINUX(Ubuntu 18.04.x、CentOS)下配置MySQL8.0.x

    安装教程:Installing MySQL on Unix/Linux Using Generic Binaries MySQL下载链接:https://dev.mysql.com/downloads ...

  7. XAF创建一个DashBoard

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

  8. vue cli3.0配制axios代理

    今天学习时,想访问网易新闻接口,结果显而易见,因为跨域被浏览器拒绝了. 去网上找一下结果一开始找到的是2.x版本的配置,生硬的放进去,给我各种报错.编译阶段就炸了.浪费好多时间 再按3.0版本去搜索才 ...

  9. Python 斗地主发牌

    #coding = utf-8 import random def Creat_Card(): card_type = ['♥','♠','♦','♣'] card_values= ['A', '2' ...

  10. 2_PY基本数据类型

    python的数据类型和R差不多,但是需要注意的是字符访问方式与R不一样,另外,python中的“真”和“假”是True False(首字母大写). 1.字符串 字符串和R的定义差不多比如: data ...