栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Python简易计算器GUI编程项目

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Python简易计算器GUI编程项目

目录

1.界面效果及主要作用

2.项目代码


1.界面效果及主要作用

1.1简单的计算机开发和设计

包括:Python的基本数字运算(加法、减法、乘法和除法、平方、除法、sin、cos等)、Python字符串相关运算、Python选择语句、循环语句、函数和其他相关设计。

1.2项目界面

 

2.项目代码(关注me得到另一半哦~)
import sqlite3
import tkinter
import tkinter.ttk
import tkinter.messagebox
import re
import math

root=tkinter.Tk()
root.geometry('320x300+300+300')
root.resizable(False,False)
root.title('Calaculator-ljl')   #set the title

contentVar=tkinter.StringVar(root,'') #Place text box set to readable
contentEntry=tkinter.Entry(root,textvariable=contentVar)  #Single line text box type
contentEntry['state']='readonly'
contentEntry.place(x=10,y=10,width=300,height=20)

btnClear=tkinter.Button(root,text='Clear',command=lambda:buttonClick('C'))
btnClear.place(x=20,y=40,width=80,height=20)
btnCompute=tkinter.Button(root,text='=',command=lambda:buttonClick('='))
btnCompute.place(x=110,y=40,width=80,height=20)
btnPI=tkinter.Button(root,text='PI',command=lambda:buttonClick('PI'))
btnPI.place(x=200,y=40,width=80,height=20)
#Place the clear, =, PI buttons

digits=list('0123456789.')+['Sqrt']
index=0
for row in range(4):
    for col in range(3):
        d=digits[index]
        index +=1
        btnDigit=tkinter.Button(root,text=d,command=lambda x=d:buttonClick(x))
        btnDigit.place(x=20+col*70,y=80+row*50,width=50,height=20)
#Place number, decimal point and square root button

#set the place of Sin and Cos
btnSin=tkinter.Button(root,text='Sin',command=lambda:buttonClick('Sin'))
btnSin.place(x=20,y=260,width=80,height=20)
btnCos=tkinter.Button(root,text='Cos',command=lambda:buttonClick('Cos'))
btnCos.place(x=120,y=260,width=80,height=20)

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/857934.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号