PyQT4编程实例之小财务软件
编写一个计算复利的对话框应用程序。做好的效果如下图
先上代码,然后讲解。
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *class interest(QDialog):def __init__(self,parent=None):super(interest,self).__init__(parent)PrincipalLabel = QLabel("&Princinpal:")self.PrincipalDoublespinBox = QDoubleSpinBox()self.PrincipalDoublespinBox.setRange(0,10000) #set rangeself.PrincipalDoublespinBox.setValue(0) #set valueself.PrincipalDoublespinBox.setPrefix("$") #set PrefixPrincipalLabel.setBuddy(self.PrincipalDoublespinBox)# the first paragraph
RateLabel = QLabel("&Rate:")self.RateDoublespinBox = QDoubleSpinBox()self.RateDoublespinBox.setRange(0,100)self.RateDoublespinBox.setValue(0)self.RateDoublespinBox.setSuffix('%') #set suffixRateLabel.setBuddy(self.RateDoublespinBox) #the second paragraph
self.list={"1years":1,"2years":2,"3years":3,"4years":4,"5years":5} #create a dictitem = sorted(self.list.keys())YearsLabel = QLabel("&Years:")self.YearsComboBox = QComboBox()self.YearsComboBox.addItems(item) #get the keys of list,set items of ComboBoxYearsLabel.setBuddy(self.YearsComboBox) #the third paragraphAmountTextLabel = QLabel("Amount")self.AmountNumLabel = QLabel("0") #the fourth paragraphlayout = QGridLayout()layout.addWidget(PrincipalLabel,0,0)layout.addWidget(self.PrincipalDoublespinBox,0,1)layout.addWidget(RateLabel,1,0)layout.addWidget(self.RateDoublespinBox,1,1)layout.addWidget(YearsLabel,2,0)layout.addWidget(self.YearsComboBox,2,1)layout.addWidget(AmountTextLabel,3,0)layout.addWidget(self.AmountNumLabel,3,1)self.setLayout(layout) #set the layout the fifth paragraph
self.connect(self.RateDoublespinBox,SIGNAL("valueChanged(double)"),self.updateUi) #value of DoublespinBoxself.connect(self.PrincipalDoublespinBox,SIGNAL("valueChanged(double)"),self.updateUi) #value of DoublespinBox,the type must be correct,or else can't connectself.connect(self.YearsComboBox,SIGNAL("currentIndexChanged(int)"),self.updateUi) #the index value,is numbers:0,1,2,3,4,and also take care of the signalself.setWindowTitle("compound interest") #the sixth paragraphdef updateUi(self):principal = self.PrincipalDoublespinBox.value() #get the value with the function of "value()"rate = self.RateDoublespinBox.value()years = unicode(self.YearsComboBox.currentText()) #get the Text of the "text ComboBox" with the function of "currentText()"amount = principal*((1+(rate/100.0))**self.list[years])self.AmountNumLabel.setText(unicode(amount)) #setText_function,Qstring argument #the seventh paragraphapp = QApplication(sys.argv)
computer = interest()
computer.show()
app.exec_() #the eighth paragraph
开始讲解框架
PyQT4编程实例之小财务软件相关推荐
- 小企业财务软件哪个最好用,该如何选择?
市面上的财务软件分类众多,单看品牌都看得眼花缭乱,对于小企业来说,财务软件哪个最好用?又该如何选择一款合适自己的财务软件呢?可以从这三点来选择. 1.可信赖的服务项目分销商和映像的财务软件 图为简道云 ...
- 兴旺小企业财务软件 v2.0 官方
Welcome to my blog! <script language="javascript" src="http://avss.b15.cnwg.cn/cou ...
- 财务管控轻松搞定:适合小企业的财务软件推荐!
小企业总是在寻找改善运营和保持竞争力的方法.他们可以做出重大改进的一个关键领域是他们的财务管理.通过实施财务软件,小企业主可以简化他们的会计流程,节省时间和金钱,并提高准确性. 小企业财务软件的好处 ...
- 全栈工程师15年经验分享:40个改变编程技能的小技巧
白交 发自 凹非寺 量子位 报道 | 公众号 QbitAI 编程如何节省更多的时间,犯更少的错误? 最近,这样一份「心得」火了.这位名叫Kesk Noren的软件工程师在Medium上分享了一篇博文 ...
- 15年经验分享:40个改变编程技能的小技巧
点击上方"小白学视觉",选择加"星标"或"置顶" 重磅干货,第一时间送达 本文转自|机器学习算法那些事 编程如何节省更多的时间,犯更少的错误 ...
- modbus通讯协议编程实例_三菱PLC CC-LINK通讯编程实例分享,看完你就会了
前言:小蓝上次分享了三菱PLC编程指令文章,有一位粉丝说还有标签,FB模块,以太网通讯,MODBUS,TCP通讯这些有的学的.所以今天就给大家带来CC-LINK通讯编程实例.如果看完还是不太明白怎么办 ...
- LiteOS通信模组教程05-LiteOS的SAL及socket编程实例
1. SAL套接字抽象层 SAL全称Socket Abstract Layer,即套接字抽象层,主要作用是对上层应用提供一层统一的 socket 编程接口,屏蔽底层网络硬件的差异. LiteOS的SA ...
- 058_《突破Delphi7.0编程实例五十讲》
<突破Delphi7.0编程实例五十讲> Delphi 教程 系列书籍 (058) <突破Delphi7.0编程实例五十讲> 网友(邦)整理 EMail: shuaihj@16 ...
- 40个提升自己编程能力的小技巧
40 个改变编程技能的小技巧 1.将大块代码分解成小函数 2.今日事今日毕,如果没毕,就留到明天. 如果下班之前还没有解决的问题,那么你需要做的,就是关闭电脑,把它留到明天. 中途不要再想着问题了! ...
最新文章
- 网页制作-表单元素2
- LIstview滑动时不加载图片,停止时加载!
- 概率编程库Pymc3案例之神经网络(批量训练)
- NLP之word2vec:利用 Wikipedia Text(中文维基百科)语料+Word2vec工具来训练简体中文词向量
- 4.0.13 mysql 注入_Windows2000下整合Mysql4.0.13与Tomcat4.1.24搭建Jsp环境
- 【Python生成readme文件】——Markdown语法
- python django部署docker_centos利用docker部署django项目
- Python读写txt
- php更改txt文件,如何使用php对txt文件进行修改
- apt编译java_自动生成代码工具--APT
- .vue文件怎么使用_手机技巧:被人忽视OTG功能怎么使用?复制文件到U盘的新方法...
- android后厨打印机漏单,后厨打印丢单解决方案
- OI生涯回忆录(Part8:至高一省选Day1)
- 数据挖掘与数据分析项目链家租房数据(一)数据爬虫
- python写android的App(kivy框架)的实践(1)
- Web(七)CSS页面布局-网页布局页面的制作
- gps wifi信号测试软件,搜星+WiFi+EMI 导航平板信号性能横评
- autojs查找图片相似轮廓
- layer打开iframe弹层,传递与接收参数
- 乐山市计算机学校蔡老师,各展所长,切磋琢磨——乐山市计算机学校召开班主任经验交流会...