实例介绍
【实例简介】Python开发计算器-多功能版,精简版1.0可以进入我的主页查找
【实例截图】
【核心代码】部分代码展示:
【实例截图】

【核心代码】部分代码展示:
# ----Memory clear
button1_1 = tkinter.Button(text='MC', bg='#666', bd=2, command=lambda:pressOperator('MC'))
button1_1.place(x=20, y=110, width=50, height=35)
# ----Memory read
button1_2 = tkinter.Button(text='MR', bg='#666', bd=2, command=lambda:pressOperator('MR'))
button1_2.place(x=77.5, y=110, width=50, height=35)
# ----Memory save
button1_3 = tkinter.Button(text='MS', bg='#666', bd=2, command=lambda:pressOperator('MS'))
button1_3.place(x=135, y=110, width=50, height=35)
# ----Memory
button1_4 = tkinter.Button(text='M ', bg='#666', bd=2, command=lambda:pressOperator('M '))
button1_4.place(x=192.5, y=110, width=50, height=35)
# ----Memory -
button1_5 = tkinter.Button(text='M-', bg='#666', bd=2, command=lambda:pressOperator('M-'))
button1_5.place(x=250, y=110, width=50, height=35)
# --第二行
# ----删除单个数字
button2_1 = tkinter.Button(text='del', bg='#666', bd=2, command=lambda:delOne())
button2_1.place(x=20, y=155, width=50, height=35)
# ----清除当前显示框内所有数字
button2_2 = tkinter.Button(text='CE', bg='#666', bd=2, command=lambda:clearCurrent())
button2_2.place(x=77.5, y=155, width=50, height=35)
# ----清零(相当于重启)
button2_3 = tkinter.Button(text='C', bg='#666', bd=2, command=lambda:clearAll())
button2_3.place(x=135, y=155, width=50, height=35)
# ----取反
button2_4 = tkinter.Button(text=' /-', bg='#666', bd=2, command=lambda:pressOperator(' /-'))
button2_4.place(x=192.5, y=155, width=50, height=35)
# ----开根号
button2_5 = tkinter.Button(text='sqrt', bg='#666', bd=2, command=lambda:pressOperator('sqrt'))
button2_5.place(x=250, y=155, width=50, height=35)
# --第三行
# ----7
button3_1 = tkinter.Button(text='7', bg='#bbbbbb', bd=2, command=lambda:pressNumber('7'))
button3_1.place(x=20, y=200, width=50, height=35)
# ----8
button3_2 = tkinter.Button(text='8', bg='#bbbbbb', bd=2, command=lambda:pressNumber('8'))
button3_2.place(x=77.5, y=200, width=50, height=35)
# ----9
button3_3 = tkinter.Button(text='9', bg='#bbbbbb', bd=2, command=lambda:pressNumber('9'))
button3_3.place(x=135, y=200, width=50, height=35)
# ----除
button3_4 = tkinter.Button(text='/', bg='#708069', bd=2, command=lambda:pressOperator('/'))
button3_4.place(x=192.5, y=200, width=50, height=35)
# ----取余
button3_5 = tkinter.Button(text='%', bg='#708069', bd=2, command=lambda:pressOperator('%'))
button3_5.place(x=250, y=200, width=50, height=35)
# --第四行
# ----4
button4_1 = tkinter.Button(text='4', bg='#bbbbbb', bd=2, command=lambda:pressNumber('4'))
button4_1.place(x=20, y=245, width=50, height=35)
# ----5
button4_2 = tkinter.Button(text='5', bg='#bbbbbb', bd=2, command=lambda:pressNumber('5'))
button4_2.place(x=77.5, y=245, width=50, height=35)
# ----6
button4_3 = tkinter.Button(text='6', bg='#bbbbbb', bd=2, command=lambda:pressNumber('6'))
button4_3.place(x=135, y=245, width=50, height=35)
# ----乘
button4_4 = tkinter.Button(text='*', bg='#708069', bd=2, command=lambda:pressOperator('*'))
button4_4.place(x=192.5, y=245, width=50, height=35)
# ----取导数
button4_5 = tkinter.Button(text='1/x', bg='#708069', bd=2, command=lambda:pressOperator('1/x'))
button4_5.place(x=250, y=245, width=50, height=35)
# --第五行
# ----3
button5_1 = tkinter.Button(text='3', bg='#bbbbbb', bd=2, command=lambda:pressNumber('3'))
button5_1.place(x=20, y=290, width=50, height=35)
# ----2
button5_2 = tkinter.Button(text='2', bg='#bbbbbb', bd=2, command=lambda:pressNumber('2'))
button5_2.place(x=77.5, y=290, width=50, height=35)
# ----1
button5_3 = tkinter.Button(text='1', bg='#bbbbbb', bd=2, command=lambda:pressNumber('1'))
button5_3.place(x=135, y=290, width=50, height=35)
# ----减
button5_4 = tkinter.Button(text='-', bg='#708069', bd=2, command=lambda:pressOperator('-'))
button5_4.place(x=192.5, y=290, width=50, height=35)
# ----等于
button5_5 = tkinter.Button(text='=', bg='#708069', bd=2, command=lambda:pressOperator('='))
button5_5.place(x=250, y=290, width=50, height=80)
# --第六行
# ----0
button6_1 = tkinter.Button(text='0', bg='#bbbbbb', bd=2, command=lambda:pressNumber('0'))
button6_1.place(x=20, y=335, width=107.5, height=35)
# ----小数点
button6_2 = tkinter.Button(text='.', bg='#bbbbbb', bd=2, command=lambda:pressDP())
button6_2.place(x=135, y=335, width=50, height=35)
# ----加
button6_3 = tkinter.Button(text=' ', bg='#708069', bd=2, command=lambda:pressOperator(' '))
button6_3.place(x=192.5, y=335, width=50, height=35)
root.mainloop()
好例子网口号:伸出你的我的手 — 分享!
网友评论
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
支持(0) 盖楼(回复)