from tkinter import *
import tkinter.messagebox as g
from math import *
from random import *
import sys
from easygui import enterbox
import os
global ver
ver=1.0
def sx_main():
def feedback():
import smtplib
import re
from os import environ
from os.path import exists
from platform import system, node
from time import strftime
from email.mime.text import MIMEText
from email.utils import formataddr
from random import randint
from easygui import enterbox
title = ('Math Problem Solver+',ver)
my_sender = 'advance_software@126.com'
my_pass = 'QFAQPLFQZRZBMVWQ'
dt = strftime('%Y-%m-%d %H:%M:%S')
my_user = "taoyuanhang66@outlook.com"
username = environ['USERNAME']
system = system()
computer = node()
number = enterbox("请输入反馈内容:")
err = Exception
def mail():
global err
ret = True
try:
msg = MIMEText(number, 'plain', 'utf-8')
msg['From'] = formataddr([enterbox("请输入名字(昵称):"), my_sender])
msg['To'] = formataddr(["", my_user])
msg['Subject'] = "用户使用反馈"
server = smtplib.SMTP_SSL("smtp.126.com", 465)
server.login(my_sender, my_pass)
server.sendmail(my_sender, [my_user, ], msg.as_string())
server.quit()
except Exception as e:
ret = False
err = str(e)
return ret
def checkmail(email):
reg = "\w+[@][a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+"
result = re.findall(reg, email)
if result:
ret = mail()
if ret:
g.showinfo("反馈", '发送成功!')
else:
g.showerror("反馈", '邮件发送失败!')
else:
g.showerror('Math Problem Solver+', '您的输入不合法,请重新输入!')
if __name__ == '__main__':
checkmail(my_user)
def aboutm():
g.showinfo("About Math Problem Solver+","""Math Problem Solver+ 1.0
Copyright© 2023 陶远航
All Rights Reserved.
警告:
不能过于依赖此工具
程序及源代码仅供学习交流,
未经作者允许不可用于商业用途!""")
def guifan():
g.showinfo("","""由于我的能力有限,无法做出以下的功能,以后可能会修复:
1、数字不能直接写在字母、括号前,比如,把“5x”替换成“5*x”
2、注意,把所有的次方改成“**”,比如,“5³”要替换成“5**3”
3、乘号“×”替换成“*”
上述问题在以后版本会改进,谢谢!
""")
def jhhb():
jhhbpath=os.path.join(os.path.dirname(__file__), 'GSP5chs.exe')
os.system(str('"'+jhhbpath+'"'))
return None
def menuCommand() :
g.showinfo("功能未开放","功能未开放,您可以使用其他功能")
def _quit():
win.quit()
win.destroy()
sys.exit()
def njh(bianshu=None):
try:
if bianshu==None:
bianshu=int(enterbox("请输入边数:",""))
else:
bianshu=int(bianshu)
except:
g.showerror("","请输入正确的值!")
return None
if bianshu<=2:
g.showerror("","请输入正确的值!")
return None
else:
g.showinfo("",("内角和为",str((bianshu-2)*180),"°"))
def waijiao(bianshu=None):
try:
if bianshu==None:
bianshu=int(enterbox("请输入边数:",""))
else:
bianshu=int(bianshu)
except:
g.showerror("","请输入正确的值!")
return None
if bianshu<=2:
g.showerror("","请输入正确的值!")
return None
else:
g.showinfo('',("正",bianshu,"边形的外角为",str(360-(bianshu-2)*180/bianshu)))
def zhouchang(n=None):
if n==None:
try:
n=int(enterbox("请输入边数"))
except:
g.showerror("","请输入正确的值!")
return None
if n<=2:
g.showerror("","边数不能小于二!")
return None
b_list=[]
for i in range(n):
try:
b_list.append(int(enterbox(("请输入第",i+1,"边边长"))))
except:
g.showerror("","请输入正确的值!")
return None
g.showinfo("",str(sum(b_list)))
return None
def sjx_mj_dg():
try:
gao=int(enterbox("请输入高:"))
di=int(enterbox("请输入底:"))
g.showinfo("",("面积为",str(gao*di/2)))
return None
except:
g.showerror("","请输入正确的值!")
return None
def sjx_mj_sb():
try:
s1=int(enterbox("请输入第一边长:"))
s2=int(enterbox("请输入第二边长:"))
s3=int(enterbox("请输入第三边长:"))
p=(s1+s2+s3)/2
s=sqrt(p*(p-s1)*(p-s2)*(p-s3))
g.showinfo("",("p=(",s1,"+",s2,"+",s3,")÷2 =",(s1+s2+s3)/2,
"面积为√",str(p*(p-s1)*(p-s2)*(p-s3)),"即",str(s)))
return None
except:
g.showerror("","请输入正确的值!")
return None
def zjsjx_mj_dg():
try:
a=int(enterbox("直角边长:"))
b=int(enterbox("另一个直角边长:"))
g.showinfo("",str(a*b/2))
return None
except:
g.showerror("","请输入正确的值!")
return None
def zjsjx_xb():
try:
a=int(enterbox("直角边长:"))
b=int(enterbox("另一个直角边长:"))
g.showinfo("",("√",str(pow(a,2)+pow(b,2)),",即",str(sqrt(pow(a,2)+pow(b,2)))))
return None
except:
g.showerror("","请输入正确的值!")
return None
def dysjx_yd_zc():
try:
yao=int(enterbox("腰长:"))
di=int(enterbox("底长:"))
g.showinfo("",("周长为",str(2*yao+di)))
return None
except:
g.showerror("","请输入正确的值!")
return None
def sbx_mj_ty(state=None):
if state=="1":
try:
a=int(enterbox("边长:"))
g.showinfo("",str(a**2))
return None
except:
g.showerror("","请输入正确的值!")
return None
elif state=="2":
try:
a=int(enterbox("长:"))
b=int(enterbox("宽:"))
g.showinfo("",str(a*b))
return None
except:
g.showerror("","请输入正确的值!")
return None
elif state=="3":
try:
a=int(enterbox("底:"))
b=int(enterbox("高:"))
g.showinfo("",str(a*b))
return None
except:
g.showerror("","请输入正确的值!")
return None
elif state=="4":
try:
a=int(enterbox("上底:"))
c=int(enterbox("下底:"))
b=int(enterbox("高:"))
g.showinfo("",str((a+c)*b/2))
return None
except:
g.showerror("","请输入正确的值!")
return None
elif state==None:
return None
def sbx_bc_ty(state=None):
try:
if state=="None":
return None
elif state=="1":
s=int(enterbox("面积:"))
g.showinfo("",str(sqrt(s)))
return None
elif state=="2":
s=int(enterbox("面积:"))
a=int(enterbox("长(或宽):"))
g.showinfo("",str(s/a))
return None
elif state=="3":
s=int(enterbox("面积:"))
a=int(enterbox("底(或高):"))
g.showinfo("",str(s/a))
return None
else:
return None
except:
g.showerror("","请输入正确的值!")
def sbx_zc_ty(state=None):
if state==1:
try:
g.showinfo("",str(4*int(enterbox("请输入边长:"))))
except:
g.showerror("","请输入正确的值!")
elif state==2:
try:
g.showinfo("",str(2*int(enterbox("请输入长:"))+2*int(enterbox("请输入宽:"))))
except:
g.showerror("","请输入正确的值!")
elif state==3:
try:
g.showinfo("",str(2*int(enterbox("请输入其中一组对边的长:"))+2*int(enterbox("请输入另一组对边的长:"))))
except:
g.showerror("","请输入正确的值!")
elif state==4:
try:
g.showinfo("",str(int(enterbox("请输入上底:"))+int(enterbox("请输入下底:"))+int(enterbox("请输入腰:"))+int(enterbox("请输入另一条腰:"))))
except:
g.showerror("","请输入正确的值!")
elif state==5:
try:
g.showinfo("",str(int(enterbox("请输入第一条边长:"))+int(enterbox("请输入第二条边长:"))+int(enterbox("请输入第三条边长:"))+int(enterbox("请输入第四条边长:"))))
except:
g.showerror("","请输入正确的值!")
def sbx_mj_ts():
try:
s1=int(enterbox("请输入第一边长:"))
s2=int(enterbox("请输入第二边长:"))
s3=int(enterbox("请输入第三边长:"))
s4=int(enterbox("请输入第四边长:"))
s5=int(enterbox("请输入第对角线长(第二边长和第三边长的夹角的角平分线在四边形内的长度):"))
p=(s1+s2+s5)/2
p2=(s3+s4+s5)/2
s=sqrt(p*(p-s1)*(p-s2)*(p-s5))+sqrt(p*(p2-s3)*(p2-s4)*(p2-s5))
g.showinfo("",(str(s)))
return None
except:
g.showerror("","请输入正确的值!")
return None
win = Tk()
win.title("Math Problem Solver+ 1.0")
win.geometry('350x150+300+200')
mainmenu = Menu (win)
jihemenu = Menu (mainmenu, tearoff=False)
tongyong=Menu(jihemenu,tearoff=0)
#######################通用###############################
tongyong.add_command(label='内角和',command=njh)
tongyong.add_command(label='外角',command=waijiao)
jihemenu.add_cascade(label="通用",menu=tongyong)
#######################通用###############################
#######################三角形##########################################
sjx=Menu(jihemenu,tearoff=0)
sjx.add_command(label='周长',command=lambda:zhouchang(3))
#######################三角形面积##########################
sjxmianji=Menu(jihemenu,tearoff=0)
sjxmianji.add_command(label='已知底和高',command=lambda:sjx_mj_dg())
sjxmianji.add_command(label='已知三边长',command=lambda:sjx_mj_sb())
zjsjx=Menu(jihemenu,tearoff=0)
zjsjx.add_command(label='求面积',command=zjsjx_mj_dg)
zjsjx.add_command(label='求斜边长',command=zjsjx_xb)
sjxmianji.add_cascade(label='直角三角形(特殊)',menu=zjsjx)
sjx.add_cascade(label='面积',menu=sjxmianji)
#######################三角形面积##########################
#######################直角三角形##########################
#menu在上面
sjx.add_cascade(label='直角三角形',menu=zjsjx)
#######################直角三角形##########################
#######################等腰三角形##########################
dysjx=Menu(jihemenu,tearoff=0)
dysjx.add_command(label='已知腰底求周长',command=dysjx_yd_zc)
sjx.add_cascade(label='等腰三角形',menu=dysjx)
#######################等腰三角形##########################
jihemenu.add_cascade(label="三角形",menu=sjx)
#######################三角形###########################################
#######################四边形###########################################
sbx=Menu(jihemenu,tearoff=0)
#######################正方形###########################################
zfx=Menu(jihemenu,tearoff=0)
zfx.add_command(label='求面积',command=lambda:sbx_mj_ty(state="1"))
zfx.add_command(label='求边长',command=lambda:sbx_bc_ty(state="1"))
zfx.add_command(label='求周长',command=lambda:sbx_zc_ty(state=1))
sbx.add_cascade(label='正方形',menu=zfx)
#######################正方形###########################################
#######################长方形###########################################
cfx=Menu(jihemenu,tearoff=0)
cfx.add_command(label='求面积',command=lambda:sbx_mj_ty(state="2"))
cfx.add_command(label='求长/宽',command=lambda:sbx_bc_ty(state="2"))
cfx.add_command(label='求周长',command=lambda:sbx_zc_ty(state=2))
sbx.add_cascade(label='长方形',menu=cfx)
#######################长方形###########################################
#######################平行四边形########################################
pxsbx=Menu(jihemenu,tearoff=0)
pxsbx.add_command(label='求面积',command=lambda:sbx_mj_ty(state="3"))
pxsbx.add_command(label='求底/高',command=lambda:sbx_bc_ty(state="3"))
pxsbx.add_command(label='求周长',command=lambda:sbx_zc_ty(state=3))
sbx.add_cascade(label='平行四边形',menu=pxsbx)
#######################平行四边形########################################
#######################梯形#############################################
tx=Menu(jihemenu,tearoff=0)
tx.add_command(label='求面积',command=lambda:sbx_mj_ty(state="4"))
tx.add_command(label='求上底/下底/高',command=menuCommand)
tx.add_command(label='求周长',command=lambda:sbx_zc_ty(state=4))
sbx.add_cascade(label='梯形',menu=tx)
#######################梯形#############################################
#######################任意四边形########################################
rysbx=Menu(jihemenu,tearoff=0)
rysbx.add_command(label='求面积',command=lambda:sbx_mj_ts)
rysbx.add_command(label='求周长',command=lambda:sbx_zc_ty(state=4))
sbx.add_cascade(label='任意四边形',menu=rysbx)
#######################任意四边形########################################
jihemenu.add_cascade(label="四边形",menu=sbx)
#######################四边形###########################################
wbx=Menu(jihemenu,tearoff=0)
wbx.add_cascade(label='内角和',command=njh)
jihemenu.add_cascade(label="五边形及以上",menu=wbx)
jihemenu.add_separator()
jihemenu.add_command(label="打开几何画板",command=jhhb)
mainmenu.add_cascade(label="几何",menu=jihemenu)
def calc():
guifan()
try:
g.showinfo("",eval(enterbox("式子:")))
return None
except:
g.showerror("","运行错误!")
def kaifang():
guifan()
a = int(enterbox("请输入你要开方的数:"))
b = int(enterbox("请输入你要开几次方"))
x = 1
b1 = b - 1
while True:
try:
y = (b1 * x + a / (x ** b1)) / b
except OverflowError:
g.showerror("数字可能太大了!")
if y == x:
break
x = y
g.showinfo("",x)
def gaojimoshi():
guifan()
mingling=enterbox("式子或任意命令:")
try:
g.showinfo("",(str(mingling),"执行成功!返回值:",eval(mingling)))
return None
except:
try:
g.showinfo("",(str(mingling),"执行成功!返回值:",exec(mingling)))
return None
except:
g.showerror("","运行错误!请检查输入是否正确!")
return None
class hanshu:
def sin():
try:
g.showinfo("",str(sin(int(enterbox("请输入sin(a)中a的值:")))))
except:
g.showerror("","运行错误!")
daishumenu = Menu (mainmenu, tearoff=False)
daishumenu.add_command(label="简易计算器",command=calc)
daishumenu.add_command(label="开方",command=kaifang)
daishumenu.add_command(label="多项式展开",command=menuCommand)
daishumenu.add_command(label="因数/式分解",command=menuCommand)
daishumenu.add_command(label="随机数生成",command=menuCommand)
daishumenu.add_command(label="质数检测",command=menuCommand)
daishumenu.add_command(label="函数的计算",command=menuCommand)
daishumenu.add_separator()
daishumenu.add_command(label="高级模式",command=gaojimoshi)
mainmenu.add_cascade(label="代数",menu=daishumenu)
mainmenu.add_command(label="退出",command=_quit)
mainmenu.add_command(label="关于",command=aboutm)
def fb():
g.showinfo("","""请联系邮箱“taoyuanhang66@outlook.com”""")
mainmenu.add_command(label="反馈",command=fb)
win.config(menu=mainmenu)
win.mainloop()
sx_main()
不能给大家鱼币了,鱼币实在是没了,大家可以去这里领: