资源简介
python 简单计算器实现,GUI界面,带上下两种显示,上边显示过程加结果如 1+1=2 ,下边直接显示结果2 带有日历显示,背景图片。鼠标键盘双输入
代码片段和文件信息
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sysstring
from PyQt4 import QtCoreQtGuiuic
while True:
try:
form_class=uic.loadUiType(“music.ui“)[0]
break
except SyntaxError:
print(“ok“)
class mywindowsclass(QtGui.QMainWindowform_class):
def __init__(selfparent=None):
QtGui.QMainWindow.__init__(selfparent)
self.setupUi(self)
self.sign = ‘‘
self.num = ‘‘
self.num1 = ‘‘
self.result = 0.0
palette = QtGui.QPalette()
icon = QtGui.QPixmap(‘34.jpg‘)
palette.setBrush(self.backgroundRole() QtGui.QBrush(icon)) # 添加背景图片
self.setPalette(palette)
exit = QtGui.QAction(QtGui.QIcon(‘icons/exit.png‘) ‘Exit‘ self) #菜单(退出)
exit.setShortcut(‘Ctrl+Q‘)
self.connect(exit QtCore.SIGNAL(‘triggered()‘) QtCore.SLOT(‘close()‘))
menubar = self.menuBar()
file = menubar.addMenu(‘&File‘)
file.addAction(exit)
self.button_add.clicked.connect(self.add_clicked)
self.button_equal.clicked.connect(self.equal_clicked)
self.button_sub.clicked.connect(self.sub_clicked)
self.button_mul.clicked.connect(self.mul_clicked)
self.button_div.clicked.connect(self.div_clicked)
self.button_cls.clicked.connect(self.cls_clicked)
self.button_one.clicked.connect(self.one_clicked)
self.button_two.clicked.connect(self.two_clicked)
self.button_three.clicked.connect(self.three_clicked)
self.button_four.clicked.connect(self.four_clicked)
self.button_five.clicked.connect(self.five_clicked)
self.button_six.clicked.connect(self.six_clicked)
self.button_seven.clicked.connect(self.seven_clicked)
self.button_eight.clicked.connect(self.eight_clicked)
self.button_nine.clicked.connect(self.nine_clicked)
self.button_zero.clicked.connect(self.zero_clicked)
def add_clicked(self):
self.sign=‘+‘
self.num=self.line_num.text()
self.line_num.setText(‘‘)
def sub_clicked(self):
self.sign=‘-‘
self.num=self.line_num.text()
self.line_num.setText(‘‘)
def mul_clicked(self):
self.sign=‘*‘
self.num = self.line_num.text()
self.line_num.setText(‘‘)
def div_clicked(self):
self.sign=‘/‘
self.num = self.line_num.text()
self.line_num.setText(‘‘)
def one_clicked(self):
self.shu = self.line_num.text()
self.shu = self.shu + “1“
self.line_num.setText(self.shu)
def two_clicked(self):
self.shu = self.line_num.text()
self.shu = self.shu + “2“
self.line_num.setText(self.shu)
def three_clicked(self):
self.shu = self.line_num.text()
self.shu = self.shu + “3“
self.line_num.setText(self.shu)
def four_clicked(self):
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 26189 2016-11-24 16:28 计算器\34.jpg
文件 10552 2018-06-21 17:35 计算器\music.ui
文件 5089 2018-07-05 16:35 计算器\计算器.py
目录 0 2018-07-07 11:28 计算器
----------- --------- ---------- ----- ----
41830 4
相关资源
- python实现SGBM图像匹配算法
- python实现灰度直方图均衡化
- scrapy_qunar_one
- Python学习全系列教程永久可用
- python简明教程.chm
- 抽奖大转盘python的图形化界面
- 双边滤波器实验报告及代码python
- python +MYSQL+HTML实现21蛋糕网上商城
- Python-直播答题助手自动检测出题搜索
- OpenCV入门教程+OpenCV官方教程中文版
- Python 串口工具源码+.exe文件
- Python开发的全栈股票系统.zip
- Python操作Excel表格并将其中部分数据写
- python书籍 PDF
- 利用python绘制散点图
- python+labview+No1.vi
- 老男孩python项目实战
- python源码制作whl文件.rar
- python3.5可用的scipy
- PYTHON3 经典50案例.pptx
- 计算机科学导论-python.pdf
- python模拟鼠标点击屏幕
- windows鼠标自动点击py脚本
- 鱼c小甲鱼零基础学python全套课后题和
- Python 练习题100道
- Practical Programming 2nd Edition
- wxPython Application Development Cookbook
- python 3.6
- Python 3.5.2 中文文档 互联网唯一CHM版本
- python3.5.2.chm官方文档
评论
共有 条评论