Algebra_Systemctl.py 72 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798
  1. import tkinter,tkinter.messagebox
  2. import tkinter.font as tkFont
  3. from DSGC.Algebra import Algebra_Polynomial
  4. #删除系统
  5. #树状图打印核心组件
  6. def Draw_An_Alg():
  7. global alg,Can_Input,kd_bool,logkd_bool
  8. name = get_AlgName()
  9. get = alg.Draw(name)
  10. try:
  11. wh = Can_Input.get().split(',')
  12. w = int(wh[0])
  13. h = int(wh[1])
  14. except:
  15. w = 1000
  16. h = 300
  17. kd = bool(kd_bool.get())
  18. logkd = bool(logkd_bool.get())
  19. Draw_Alg(get,w,h,kd,logkd)
  20. def Draw_Alg(n,w,h,kh=True,logkh=True):
  21. new_top = tkinter.Toplevel(bg=bg)
  22. new_top.resizable(width=False, height=False)
  23. new_top.geometry('+10+10') # 设置所在位置
  24. Can = tkinter.Canvas(new_top,bg=bg, width=w, height=h)
  25. Can.pack()
  26. size = 20
  27. F2 = ('Fixdsys', size)
  28. x = 30
  29. y = 150
  30. l = (size/16)*5.5
  31. print(f'n={n}')
  32. for i in n:
  33. if i[0] == 'A':
  34. print(f'A.={i}')
  35. te = f'{i[1]}'
  36. x += len(te) * l
  37. Can.create_text(x, y,font=F2, text=te)
  38. x += len(te) * l
  39. elif i[0] == 'B':
  40. print(f'B.={i}')
  41. if kh:x, y, q = Draw_Son([['A', '[']], Can, x, y, size - 5, [],kh,logkh) # 递归呼叫儿子
  42. x, y,h = Draw_Son(i[1], Can, x, y, size,[],kh,logkh) # 底数
  43. dy = y
  44. y = h-10
  45. x, y,q = Draw_Son(i[2], Can, x, y, size - 5,[],kh,logkh) # 指数
  46. y = dy
  47. if kh:x, y, q = Draw_Son([['A', ']']], Can, x, y, size - 5, [],kh,logkh) # 递归呼叫儿子
  48. elif i[0] == 'C':
  49. print(f'C.={i}')
  50. if kh:x, y, q = Draw_Son([['A', '[']], Can, x, y, size - 5, [],kh,logkh) # 递归呼叫儿子
  51. x, y, h = Draw_Son(i[1], Can, x, y, size, [],kh,logkh) # log符号
  52. # y += 10
  53. # if logkh:x, y, q = Draw_Son([['A', '(']], Can, x, y, size - 5, [],kh,logkh) # 递归呼叫儿子
  54. # x, y, q = Draw_Son(i[2], Can, x, y, size - 5, [],kh,logkh) # 递归呼叫儿子
  55. # if logkh:x, y, q = Draw_Son([['A', ')']], Can, x, y, size - 5, [],kh,logkh) # 递归呼叫儿子
  56. # y -= 10
  57. if logkh:x, y, q = Draw_Son([['A', '(']], Can, x, y, size - 5, [],kh,logkh) # 递归呼叫儿子
  58. x, y, q = Draw_Son(i[2], Can, x, y, size, [],kh,logkh) # 递归呼叫儿子
  59. if logkh:x, y, q = Draw_Son([['A', ')']], Can, x, y, size - 5, [],kh,logkh) # 递归呼叫儿子
  60. if kh:x, y, q = Draw_Son([['A', ']']], Can, x, y, size - 5, [],kh,logkh) # 递归呼叫儿子
  61. elif i[0] == 'D':
  62. print(f'D.={i}')
  63. if kh:x, y, q = Draw_Son([['A', '[']], Can, x, y, size - 5, [],kh,logkh) # 递归呼叫儿子
  64. y -= 20
  65. a_x, y, h = Draw_Son(i[1], Can, x, y, size, [],kh,logkh) # log符号
  66. y += 40
  67. b_x, y, h = Draw_Son(i[2], Can, x, y, size, [],kh,logkh) # log符号
  68. n_x = max([a_x, b_x]) - x
  69. y -= 20
  70. x, y, h = Draw_Son([('A', '-' * int((n_x /(2*l))))], Can, x, y, size, [],kh,logkh) # log符号
  71. if kh:x, y, q = Draw_Son([['A', ']']], Can, x, y, size - 5, [],kh,logkh) # 递归呼叫儿子
  72. addNews('运算完毕')
  73. def Draw_Son(n,Can,x,y,size,max_y,kh=True,logkh=True):
  74. F2 = ('Fixdsys', size)
  75. l = (size/16)*5.5
  76. print(f'n={n}')
  77. for i in n:
  78. if i[0] == 'A':#只有A才是真的画图,其他是移动坐标
  79. max_y.append(y)
  80. print(f'A={i}')
  81. te = f'{i[1]}'
  82. x += len(te) * l
  83. Can.create_text(x, y,font=F2, text=te)
  84. x += len(te) * l
  85. elif i[0] == 'B':
  86. print(f'B={i}')
  87. if kh:x, y, q = Draw_Son([['A', '[']], Can, x, y, size - 5, [],kh,logkh) # 递归呼叫儿子
  88. x, y, h = Draw_Son(i[1], Can, x, y, size,max_y,kh,logkh) # 底数
  89. dy = y
  90. y = h-10
  91. x, y,q = Draw_Son(i[2], Can, x, y, size - 5,max_y,kh,logkh) # 递归呼叫儿子
  92. y = dy
  93. if kh:x, y, q = Draw_Son([['A', ']']], Can, x, y, size - 5, [],kh,logkh) # 递归呼叫儿子
  94. elif i[0] == 'C':
  95. print(f'C={i}')
  96. if kh:x, y, q = Draw_Son([['A', '[']], Can, x, y, size - 5, [],kh,logkh) # 递归呼叫儿子
  97. x, y, h = Draw_Son(i[1], Can, x, y, size, [],kh,logkh) # log符号
  98. # y += 10
  99. # if logkh:x, y, q = Draw_Son([['A', '(']], Can, x, y, size - 5, [],kh,logkh) # 递归呼叫儿子
  100. # x, y, q = Draw_Son(i[2], Can, x, y, size - 5, [],kh,logkh) # 递归呼叫儿子
  101. # if logkh:x, y, q = Draw_Son([['A', ')']], Can, x, y, size - 5, [],kh,logkh) # 递归呼叫儿子
  102. # y -= 10
  103. if logkh:x, y, q = Draw_Son([['A', '(']], Can, x, y, size - 5, [],kh,logkh) # 递归呼叫儿子
  104. x, y, q = Draw_Son(i[2], Can, x, y, size, [],kh,logkh) # 递归呼叫儿子
  105. if logkh:x, y, q = Draw_Son([['A', ')']], Can, x, y, size - 5, [],kh,logkh) # 递归呼叫儿子
  106. if kh:x, y, q = Draw_Son([['A', ']']], Can, x, y, size - 5, [],kh,logkh) # 递归呼叫儿子
  107. elif i[0] == 'D':
  108. print(f'D={i}')
  109. if kh:x, y, q = Draw_Son([['A', '[']], Can, x, y, size - 5, [],kh,logkh) # 递归呼叫儿子
  110. y -= 20
  111. a_x, y, h = Draw_Son(i[1], Can, x, y, size, [],kh,logkh) # log符号
  112. y += 40
  113. b_x, y, h = Draw_Son(i[2], Can, x, y, size, [],kh,logkh) # log符号
  114. n_x = max([a_x, b_x]) - x
  115. y -= 20
  116. x, y, h = Draw_Son([('A', '-' * int((n_x/(2*l))))], Can, x, y, size, [],kh,logkh) # log符号
  117. if kh:x, y, q = Draw_Son([['A', ']']], Can, x, y, size - 5, [],kh,logkh) # 递归呼叫儿子
  118. try:
  119. re = min(max_y)
  120. except:
  121. re = 150
  122. return x,y,re
  123. def Print_Sym_Core(str_,w=40,h=20,jh=True):
  124. global New_Text,alg,bg
  125. if jh:
  126. try:
  127. str_ = alg.rprint_expression(str_)
  128. addNews('树状图计算成功')
  129. except:
  130. addNews('树状图计算失败')
  131. return False
  132. addNews('系统运算中')
  133. new_top = tkinter.Toplevel(bg=bg)
  134. new_top.resizable(width=False, height=False)
  135. new_top.geometry('+10+10') # 设置所在位置
  136. New_Text = tkinter.Text(new_top, width=w, height=h)
  137. New_Text.pack()
  138. New_Text.delete(1.0, tkinter.END)
  139. New_Text.insert(tkinter.END,str_)
  140. New_Text.config(state=tkinter.DISABLED)
  141. addNews('运算完毕')
  142. #打印接口(按钮)
  143. def Print_Sym():
  144. global New_Text,alg,Can_Input
  145. n = get_AlgName()
  146. print(n)
  147. try:
  148. str_ = alg.print_expression(n)
  149. except:
  150. # raise
  151. return False
  152. try:
  153. wh = Can_Input.get().split(',')
  154. w = int(wh[0])/10
  155. h = int(wh[1])/10
  156. except:
  157. w = 40
  158. h = 20
  159. Print_Sym_Core(str_,w,h,False)
  160. def Tra_Alg():
  161. global alg
  162. try:
  163. alg.Tra_Alg()
  164. update_BOX()
  165. addNews('删除完成')
  166. except:
  167. addNews('删除失败')
  168. def Del_Alg():
  169. global alg
  170. name = get_AlgName()
  171. try:
  172. alg.del_Alg(name)
  173. update_BOX()
  174. addNews('删除完成')
  175. except:
  176. addNews('删除失败')
  177. def Del_Symbol():
  178. global alg
  179. try:
  180. value = Value_List[Value_BOX.curselection()[0]]
  181. except:
  182. addNews('请选定符号')
  183. return False
  184. try:
  185. alg.del_Symbol(value)
  186. update_BOX()
  187. addNews('删除完成')
  188. except:
  189. # raise
  190. addNews('删除失败')
  191. #画图系统
  192. def Plotting():
  193. global alg, p2D_Value, p3D_Value, Plot_Type
  194. try:
  195. ty = Plot_Type.get()
  196. if p2D_Value == None:raise Exception
  197. if ty == 1 and p3D_Value == None:raise Exception
  198. name = get_AlgName()
  199. alg.Plot(name,p2D_Value,p3D_Value)
  200. except:
  201. addNews('画图失败')
  202. def add_PlotValue():
  203. global alg,p2D_Value,p3D_Value,Range_Input,Plot_Type,Value_List,Value_BOX
  204. try:
  205. try:
  206. value = Value_List[Value_BOX.curselection()[0]]
  207. except:
  208. addNews('请选定符号')
  209. return False
  210. R = Range_Input.get().split(',')
  211. if R == ['']:R = [-10,10]
  212. Range = [min((float(R[0]),float(R[1]))),max((float(R[0]),float(R[1])))]
  213. tup = [value]+Range
  214. ty = Plot_Type.get()
  215. except:
  216. addNews('修改失败')
  217. return False
  218. if p2D_Value == None:
  219. p2D_Value = tup
  220. elif p3D_Value == None and ty == 1:
  221. if p2D_Value[0] != tup[0]:
  222. p3D_Value = tup
  223. else:
  224. p2D_Value = tup
  225. else:
  226. if ty == 0:#2D
  227. p2D_Value = tup
  228. p3D_Value = None
  229. else:#3D
  230. if p2D_Value[0] == tup[0]:
  231. p2D_Value = tup
  232. elif p3D_Value[0] == tup[0]:
  233. p3D_Value = tup
  234. else:
  235. p2D_Value = p3D_Value
  236. p3D_Value = tup
  237. addNews('修改完成')
  238. Update_PlotValue()
  239. def Update_PlotValue():
  240. global PlotValue_BOX,Plot_Type,p2D_Value,p3D_Value
  241. ty = Plot_Type.get()
  242. re = []
  243. try:
  244. if ty == 0:#2D
  245. re = [f'二维:{p2D_Value[0]} -> ({p2D_Value[1]},{p2D_Value[2]})']
  246. else:
  247. re = [f'三维:{p2D_Value[0]} -> ({p2D_Value[1]},{p2D_Value[2]})']
  248. re.append(f'三维:{p3D_Value[0]} -> ({p3D_Value[1]},{p3D_Value[2]})')
  249. except:pass
  250. PlotValue_BOX.delete(0, tkinter.END)
  251. PlotValue_BOX.insert(tkinter.END, *re)
  252. #重写代数式
  253. def Rewrite():
  254. global alg,Rewrite_Input,Rewrite_F_Input,Rewrite_deep
  255. Func = Rewrite_Input.get()
  256. DX = Rewrite_F_Input.get().split(',')
  257. if DX == ['']:DX = []
  258. deep = bool(Rewrite_deep.get())
  259. name = get_AlgName()
  260. try:
  261. get = alg.Rewrite(name,Func,DX,deep)
  262. addNews('运行完成')
  263. except:
  264. addNews('运行失败')
  265. After_Func(get, f'代数式重写的结果为:{get},是否应用?')
  266. #解不等式
  267. def Update_Inequality_BOX():
  268. global Z_Inequality,Y_Inequality,Inequality_Type,Inequality_BOX
  269. re = []
  270. if Z_Inequality != None and Y_Inequality != None:
  271. Type = ['>', '<', '>=', '<='][Inequality_Type.get()]
  272. re.append(f'{Z_Inequality} {Type} {Y_Inequality}')
  273. else:
  274. if Z_Inequality != None:
  275. re.append(f'左代数式:{Z_Inequality}')
  276. if Y_Inequality != None:
  277. re.append(f'右代数式:{Y_Inequality}')
  278. Inequality_BOX.delete(0, tkinter.END)
  279. Inequality_BOX.insert(tkinter.END, *re)
  280. def Inequality_Solve():
  281. global alg,Z_Inequality,Y_Inequality,Inequality_Type,AnswerInequality_BOX
  282. if Z_Inequality != None and Y_Inequality != None:
  283. type = Inequality_Type.get()
  284. try:
  285. get = alg.Solve_Inequality([Z_Inequality,Y_Inequality],type)
  286. AnswerInequality_BOX.delete(0, tkinter.END)
  287. AnswerInequality_BOX.insert(tkinter.END, *get)
  288. addNews('运行完成')
  289. except:
  290. addNews('解不等式失败')
  291. def In_add_Z():
  292. global Z_Inequality
  293. Z_Inequality = get_AlgName()
  294. Update_Inequality_BOX()
  295. def In_add_Y():
  296. global Y_Inequality
  297. Y_Inequality = get_AlgName()
  298. Update_Inequality_BOX()
  299. #解方程
  300. def To_Alg():
  301. global Answer_BOX, Answer_List
  302. get = Answer_List[Answer_BOX.curselection()[0]][1]#[1]取结果
  303. After_Func(get, f'联立结果为:{get},是否应用?')
  304. def To_Sub():
  305. global Answer_BOX, Answer_List,Sub_Dic
  306. get = Answer_List[Answer_BOX.curselection()[0]]
  307. Sub_Dic[get[0]] = get[1]
  308. Update_Sub()
  309. def To_RSub():
  310. global Answer_BOX, Answer_List,RSub_Dic
  311. get = Answer_List[Answer_BOX.curselection()[0]]
  312. RSub_Dic[get[1]] = get[0]
  313. Update_RSub()
  314. def alg_Solve():
  315. global Solve_list,Answer_BOX,Answer_List
  316. try:
  317. get = alg.Solve(Solve_list)
  318. addNews('运行成功')
  319. except:
  320. addNews('解方程失败')
  321. return False
  322. Answer_List = []
  323. re = []
  324. for i in get:
  325. re.append(f'{i[0]} = {i[1]}')
  326. Answer_List.append((i[0],i[1]))
  327. Answer_BOX.delete(0, tkinter.END)
  328. Answer_BOX.insert(tkinter.END, *re)
  329. def Del_Solve():
  330. global Solve_list,Z_alg, Y_alg,Solve_BOX
  331. num = Solve_BOX.curselection()[0]
  332. if Z_alg != None or Y_alg != None:
  333. if num == 0:
  334. Z_alg = None
  335. Y_alg = None
  336. else:
  337. num -= 1
  338. del Solve_list[num]
  339. else:
  340. del Solve_list[num]
  341. Update_SolveBOX()
  342. def Update_SolveBOX():
  343. global Solve_list,Solve_BOX,Z_alg, Y_alg
  344. BOX = []
  345. if Z_alg != None or Y_alg != None:
  346. BOX.append(f'(选定){Z_alg} = {Y_alg}')
  347. for i in Solve_list:
  348. BOX.append(f'{i[0]} = {i[1]}')
  349. Solve_BOX.delete(0, tkinter.END)
  350. Solve_BOX.insert(tkinter.END, *BOX)
  351. def add_ZY():
  352. global Z_alg, Y_alg, Solve_list, Answer_List
  353. if Z_alg != None and Y_alg != None:
  354. Solve_list.append((Z_alg,Y_alg))
  355. Z_alg = None
  356. Y_alg = None
  357. Update_SolveBOX()
  358. def add_Z():
  359. global Z_alg, Y_alg, Solve_list, Answer_List
  360. Z_alg = get_AlgName()
  361. Update_SolveBOX()
  362. def add_Y():
  363. global Z_alg, Y_alg, Solve_list, Answer_List
  364. Y_alg = get_AlgName()
  365. Update_SolveBOX()
  366. #代数运算
  367. def Alg_Sub_Num():
  368. global alg,Value_Sub_Dic
  369. name = get_AlgName()
  370. try:
  371. get = alg.SubNum_Value(name,Value_Sub_Dic)
  372. addNews('运算成功')
  373. except:
  374. addNews('代数运算失败')
  375. return False
  376. After_Func(get, f'联立结果为:{get},是否应用?')
  377. def Update_Sub_Num():
  378. global alg, Value_Sub_Dic,ValueNUM_BOX
  379. BOX = []
  380. for v in Value_Sub_Dic:
  381. BOX.append(f'{v} = {Value_Sub_Dic[v]}')
  382. ValueNUM_BOX.delete(0, tkinter.END)
  383. ValueNUM_BOX.insert(tkinter.END, *BOX)
  384. def Del_Sub_Num():
  385. global alg,Value_Sub_Dic,ValueNUM_BOX
  386. num = ValueNUM_BOX.curselection()[0]
  387. del Value_Sub_Dic[list(Value_Sub_Dic.keys())[num]]
  388. Update_Sub_Num()
  389. def Add_Sub_Num():
  390. global ValueNUM_Input,Value_Sub_Dic,Num_Type
  391. try:
  392. value_name = Value_List[Value_BOX.curselection()[0]]
  393. except:
  394. addNews('请选定符号')
  395. return False
  396. value_num = alg.Creat_Num(ValueNUM_Input.get(),Num_Type.get())#不同类型
  397. Value_Sub_Dic[value_name] = value_num
  398. Update_Sub_Num()
  399. #反向联立
  400. def Alg_RSub():
  401. global alg,RSub_Dic
  402. name = get_AlgName()
  403. try:
  404. get = alg.RSub_Value(name,RSub_Dic)
  405. addNews('反向联立完成')
  406. except:
  407. addNews('无法联立')
  408. return False
  409. After_Func(get, f'联立结果为:{get},是否应用?')
  410. def Update_RSub():
  411. global alg, RSub_Dic, RSub_Alg, RSub_Value, RSub_BOX
  412. BOX = []
  413. if RSub_Value != None or RSub_Alg != None:
  414. BOX.append(f'选定:{RSub_Alg} = {RSub_Value}')
  415. for v in RSub_Dic:
  416. BOX.append(f'{v} = {RSub_Dic[v]}')
  417. RSub_BOX.delete(0, tkinter.END)
  418. RSub_BOX.insert(tkinter.END, *BOX)
  419. def Del_RSub():
  420. global alg,RSub_Dic, RSub_Alg, RSub_Value
  421. num = RSub_BOX.curselection()[0]
  422. if RSub_Value != None or RSub_Alg != None:
  423. if num == 0:
  424. RSub_Value = None
  425. RSub_Alg = None
  426. else:
  427. num -= 1
  428. del RSub_Dic[list(RSub_Dic.keys())[num]]
  429. else:
  430. del RSub_Dic[list(RSub_Dic.keys())[num]]
  431. Update_RSub()
  432. def Add_RSub():
  433. global alg, RSub_Dic, RSub_Alg,RSub_Value
  434. if RSub_Value != None and RSub_Alg != None:
  435. RSub_Dic[RSub_Alg] = RSub_Value
  436. RSub_Value,RSub_Alg = None,None
  437. Update_RSub()
  438. def Add_RSub_Alg():
  439. global alg,RSub_Alg
  440. alg_name = get_AlgName()
  441. RSub_Alg = alg_name
  442. Update_RSub()
  443. def Add_RSub_Value():
  444. global alg,Value_List,Value_BOX,RSub_Value
  445. try:
  446. value_name = Value_List[Value_BOX.curselection()[0]]
  447. except:
  448. addNews('请选定符号')
  449. return False
  450. RSub_Value = value_name
  451. Update_RSub()
  452. #执行符号->代数式联立
  453. def Alg_Sub():
  454. global alg,Sub_Dic
  455. name = get_AlgName()
  456. try:
  457. get = alg.Sub_Value(name,Sub_Dic)
  458. addNews('联立完成')
  459. except:
  460. addNews('无法联立')
  461. return False
  462. After_Func(get, f'联立结果为:{get},是否应用?')
  463. def Update_Sub():
  464. global alg, Value_List, Value_BOX, Sub_Dic, Sub_Alg, Sub_Value, Sub_BOX
  465. BOX = []
  466. if Sub_Value != None or Sub_Alg != None:
  467. BOX.append(f'选定:{Sub_Value} = {Sub_Alg}')
  468. for v in Sub_Dic:
  469. BOX.append(f'{v} = {Sub_Dic[v]}')
  470. Sub_BOX.delete(0, tkinter.END)
  471. Sub_BOX.insert(tkinter.END, *BOX)
  472. def Del_Sub():
  473. global alg, Value_List, Value_BOX, Sub_Dic, Sub_Alg, Sub_Value
  474. num = Sub_BOX.curselection()[0]
  475. if Sub_Value != None or Sub_Alg != None:
  476. if num == 0:
  477. Sub_Value = None
  478. Sub_Alg = None
  479. else:
  480. num -= 1
  481. del Sub_Dic[list(Sub_Dic.keys())[num]]
  482. else:
  483. del Sub_Dic[list(Sub_Dic.keys())[num]]
  484. Update_Sub()
  485. def Add_Sub():
  486. global alg, Value_List, Value_BOX, Sub_Dic, Sub_Alg,Sub_Value
  487. if Sub_Value != None and Sub_Alg != None:
  488. Sub_Dic[Sub_Value] = Sub_Alg
  489. Sub_Value,Sub_Alg = None,None
  490. Update_Sub()
  491. def Add_Sub_Alg():
  492. global alg,Value_List,Value_BOX,Sub_Alg
  493. alg_name = get_AlgName()
  494. Sub_Alg = alg_name
  495. Update_Sub()
  496. def Add_Sub_Value():
  497. global alg,Value_List,Value_BOX,Sub_Value
  498. try:
  499. value_name = Value_List[Value_BOX.curselection()[0]]
  500. except:
  501. addNews('请选定符号')
  502. return False
  503. Sub_Value = value_name
  504. Update_Sub()
  505. def alg_to_Num():
  506. global alg,Num_Input
  507. try:
  508. num = int(Num_Input.get())
  509. except:
  510. num = 5
  511. try:
  512. get = alg.to_num(num)
  513. addNews('数字化完成')
  514. except:
  515. addNews('数字化失败')
  516. return False
  517. After_Func(get, f'数字化的结果为:{get},是否应用?')
  518. def Ex_Func():
  519. global alg
  520. name = get_AlgName()
  521. try:
  522. get = alg.func_Ex(name)
  523. addNews('运算成功')
  524. except:
  525. addNews('运算失败')
  526. return False
  527. After_Func(get, f'展开特殊函数的结果为:{get},是否应用?')
  528. def Ex_I():
  529. global alg
  530. name = get_AlgName()
  531. try:
  532. get = alg.complex_Ex(name)
  533. addNews('运算成功')
  534. except:
  535. addNews('运算失败')
  536. return False
  537. After_Func(get, f'展开虚数的结果为:{get},是否应用?')
  538. def Coll():
  539. global alg,CollX_Input
  540. x = CollX_Input.get().split('#')
  541. name = get_AlgName()
  542. try:
  543. get = alg.Collect(name,x)
  544. addNews('运算成功')
  545. except:
  546. addNews('运算失败')
  547. return False
  548. After_Func(get,f'合并同类项的结果为:{get},是否应用?')
  549. def Expansion():
  550. global alg,EX_IM
  551. IM = bool(EX_IM.get())
  552. name = get_AlgName()
  553. try:
  554. get = alg.expansion(name,IM)
  555. addNews('运算成功')
  556. except:
  557. addNews('运算失败')
  558. return False
  559. After_Func(get, f'普遍展开的结果为:{get},是否应用?')
  560. def Factor():
  561. global alg,GAOSI, FactorM_Input,Factor_Deep,Factor_Rat
  562. name = get_AlgName()
  563. GS = bool(GAOSI.get())
  564. Deep = bool(Factor_Deep.get())
  565. Rat = bool(Factor_Rat.get())
  566. try:
  567. M = int(FactorM_Input.get())
  568. except:
  569. M = None
  570. try:
  571. get = alg.factor(name,M,GS,Deep,Rat)
  572. addNews('运算成功')
  573. except:
  574. addNews('运算失败')
  575. return False
  576. After_Func(get, f'因式分解的结果为:{get},是否应用?')
  577. def Simp():
  578. global alg,Simpratio_Input,SimpFunc_Input,simp_in,simp_rat
  579. try:
  580. radio = float(Simpratio_Input.get())
  581. except:radio = 1.7
  582. rat = bool(simp_rat.get())
  583. inverse = bool(simp_in.get())
  584. name = get_AlgName()
  585. try:
  586. get = alg.simplify(name,radio,rat=rat,inv=inverse)
  587. addNews('运算成功')
  588. except:
  589. addNews('运算失败')
  590. return False
  591. After_Func(get, f'化简(标准化)为:{get},是否应用?')
  592. def After_Func(re,message):
  593. if tkinter.messagebox.askokcancel('提示', message):
  594. alg.addAlgebra('', re)
  595. update_BOX()
  596. def log_Ex():
  597. global alg,Fo_log,Deep_log
  598. Fo = not bool(Fo_log.get())
  599. Deep = bool(Deep_log.get())
  600. name = get_AlgName()
  601. try:
  602. get = alg.log_Expansion(name,Fo,Deep)
  603. addNews('运算成功')
  604. except:
  605. addNews('运算失败')
  606. return False
  607. After_Func(get, f'展开对数结果为:{get},是否应用?')
  608. def log_Simp():
  609. global alg,Fo_log
  610. Fo = not bool(Fo_log.get())
  611. name = get_AlgName()
  612. try:
  613. get = alg.log_Simp(name,Fo)
  614. addNews('运算成功')
  615. except:
  616. addNews('运算失败')
  617. return False
  618. After_Func(get, f'化简对数结果为:{get},是否应用?')
  619. def mul_Ex():
  620. global alg,Fo_exp
  621. name = get_AlgName()
  622. try:
  623. get = alg.Mul_Expansion(name)
  624. addNews('运算成功')
  625. except:
  626. addNews('运算失败')
  627. return False
  628. After_Func(get, f'展开乘法结果为:{get},是否应用?')
  629. def multinomial_Ex():
  630. global alg,Fo_exp
  631. name = get_AlgName()
  632. try:
  633. get = alg.Multinomial_Expansion(name)
  634. addNews('运算成功')
  635. except:
  636. addNews('运算失败')
  637. return False
  638. After_Func(get, f'展开加法式幂结果为:{get},是否应用?')
  639. def multinomial_Simp():
  640. global alg,Fo_exp
  641. name = get_AlgName()
  642. try:
  643. get = alg.Pow_Simp_Multinomial(name)
  644. addNews('运算成功')
  645. except:
  646. addNews('运算失败')
  647. return False
  648. After_Func(get, f'合成幂指数的结果为:{get},是否应用?(彻底化简加法式幂可以使用因式分解)')
  649. def exp_Ex_Mul():
  650. global alg,Fo_exp
  651. deep = bool(Deep_exp.get())
  652. name = get_AlgName()
  653. try:
  654. get = alg.Pow_Expansion_base(name,deep)
  655. addNews('运算成功')
  656. except:
  657. addNews('运算失败')
  658. return False
  659. After_Func(get, f'展开指数底数结果为:{get},是否应用?')
  660. def exp_Ex_base():
  661. global alg,Fo_exp
  662. deep = bool(Deep_exp.get())
  663. name = get_AlgName()
  664. try:
  665. get = alg.Pow_Expansion_base(name,deep)
  666. addNews('运算成功')
  667. except:
  668. addNews('运算失败')
  669. return False
  670. After_Func(get, f'展开指数底数结果为:{get},是否应用?')
  671. def exp_Ex_exp():
  672. global alg,Deep_exp
  673. deep = bool(Deep_exp.get())
  674. name = get_AlgName()
  675. try:
  676. get = alg.Pow_Expansion_exp(name,deep)
  677. except:
  678. addNews('运算失败')
  679. return False
  680. After_Func(get, f'展开指数幂结果为:{get},是否应用?')
  681. def exp_Ex():
  682. global alg,Deep_exp
  683. deep = bool(Deep_exp.get())
  684. name = get_AlgName()
  685. try:
  686. get = alg.Pow_Expansion(name,deep)
  687. addNews('运算成功')
  688. except:
  689. addNews('运算失败')
  690. return False
  691. After_Func(get, f'展开指数结果为:{get},是否应用?')
  692. def exp_Simp_base():
  693. global alg,Fo_exp
  694. Fo = not bool(Fo_exp.get())
  695. name = get_AlgName()
  696. try:
  697. get = alg.Pow_Simp_base(name,Fo)
  698. addNews('运算成功')
  699. except:
  700. addNews('运算失败')
  701. return False
  702. After_Func(get, f'化简指数底数结果为:{get},是否应用?')
  703. def exp_Simp_exp():
  704. global alg,Fo_exp
  705. Fo = not bool(Fo_exp.get())
  706. name = get_AlgName()
  707. try:
  708. get = alg.Pow_Simp_exp(name,Fo)
  709. addNews('运算成功')
  710. except:
  711. addNews('运算失败')
  712. return False
  713. After_Func(get, f'化简指数幂结果为:{get},是否应用?')
  714. def exp_Simp():
  715. global alg,Fo_exp
  716. Fo = not bool(Fo_exp.get())
  717. name = get_AlgName()
  718. try:
  719. get = alg.Pow_Simp(name,Fo)
  720. addNews('运算成功')
  721. except:
  722. addNews('运算失败')
  723. return False
  724. After_Func(get, f'化简指数结果为:{get},是否应用?')
  725. def trig_Simp():#三角函数化简
  726. global alg
  727. name = get_AlgName()
  728. try:
  729. get = alg.Trig_Simp(name)
  730. addNews('运算成功')
  731. except:
  732. addNews('运算失败')
  733. return False
  734. After_Func(get,f'三角化简结果为:{get},是否应用?')
  735. def trig_Expand():#三角展开
  736. global alg,simp_deep
  737. deep = bool(simp_deep.get())
  738. name = get_AlgName()
  739. try:
  740. get = alg.Trig_Expansion(name,deep)
  741. addNews('运算成功')
  742. except:
  743. addNews('运算失败')
  744. return False
  745. After_Func(get, f'三角展开结果为:{get},是否应用?')
  746. def rat():#通分
  747. global alg
  748. name = get_AlgName()
  749. try:
  750. get = alg.Fractional_merge(name)
  751. addNews('运算成功')
  752. except:
  753. addNews('运算失败')
  754. return False
  755. After_Func(get,f'分式通分结果为:{get},是否应用?')
  756. def canc():#约分
  757. global alg
  758. name = get_AlgName()
  759. try:
  760. get = alg.Fraction_reduction(name)
  761. addNews('运算成功')
  762. except:
  763. addNews('运算失败')
  764. return False
  765. After_Func(get,f'分式约分结果为:{get},是否应用?')
  766. def apart():#裂项
  767. global alg,apart_Input
  768. x = apart_Input.get().replace(' ','')
  769. if x == '':x = None
  770. name = get_AlgName()
  771. try:
  772. get = alg.Fractional_fission(name,x)
  773. addNews('运算成功')
  774. except:
  775. addNews('运算失败')
  776. return False
  777. After_Func(get,f'分式裂项结果为:{get},是否应用?')
  778. def as_Fraction():#together
  779. global alg,together_deep
  780. deep = bool(together_deep.get())
  781. name = get_AlgName()
  782. try:
  783. get = alg.as_Fraction(name,deep)
  784. addNews('运算成功')
  785. except:
  786. addNews('运算失败')
  787. return False
  788. After_Func(get, f'合成分式结果为:{get},是否应用?')
  789. def Fraction_rat():#分母有理化
  790. global alg,radsymbol,radMax_Input
  791. #Max
  792. try:M = int(radMax_Input.get())
  793. except:M=4
  794. #Symbol
  795. s = bool(radsymbol.get())
  796. name = get_AlgName()
  797. try:
  798. get = alg.Fractional_rat(name,s,M)
  799. addNews('运算成功')
  800. except:
  801. addNews('运算失败')
  802. return False
  803. After_Func(get, f'分母有理化结果为:{get},是否应用?')
  804. def Option_Add():
  805. global alg,Option_BOX,Option_List
  806. name = get_AlgName()
  807. if name == None:return False
  808. Option_List.append(name)
  809. Update_Option_BOX()
  810. def Option_Del():
  811. global Option_BOX, Option_List
  812. del Option_List[Option_BOX.curselection()[0]]
  813. Update_Option_BOX()
  814. def Option_Tra():
  815. global Option_BOX, Option_List
  816. update_BOX()
  817. def Update_Option_BOX():
  818. global Option_BOX, Option_List
  819. re = []
  820. for i in range(len(Option_List)):
  821. re.append(f'({i + 1}) --> {Option_List[i]}')
  822. Option_BOX.delete(0, tkinter.END)
  823. Option_BOX.insert(tkinter.END, *re)
  824. def Merge_Func():
  825. global alg, Option_List,Merge_Func_Input
  826. name = Option_List.copy()
  827. if len(name) < 2: raise Exception
  828. try:
  829. re = alg.Merge_Func(name,Merge_Func_Input.get())
  830. addNews('合成成功')
  831. except:
  832. addNews('合成失败')
  833. return False
  834. if tkinter.messagebox.askokcancel('提示', f'合成结果为:{re},是否应用?'):
  835. alg.addAlgebra('', re)
  836. update_BOX()
  837. def Merge_Mul():
  838. global alg, Option_List
  839. name = Option_List.copy()
  840. if len(name)<2:raise Exception
  841. try:
  842. re = alg.Merge_Mul(name)
  843. addNews('合成成功')
  844. except:
  845. addNews('合成失败')
  846. return False
  847. if tkinter.messagebox.askokcancel('提示', f'合成结果为:{re},是否应用?'):
  848. alg.addAlgebra('',re)
  849. update_BOX()
  850. def Merge_Add():
  851. global alg,Option_List
  852. name = Option_List.copy()
  853. if len(name)<2:raise Exception
  854. try:
  855. re = alg.Merge_Add(name)
  856. addNews('合成成功')
  857. except:
  858. addNews('合成失败')
  859. return False
  860. if tkinter.messagebox.askokcancel('提示', f'合成结果为:{re},是否应用?'):
  861. alg.addAlgebra('',re)
  862. update_BOX()
  863. def Func_Split():
  864. global alg,Deep_Split,Func_Input,Split_XS
  865. name = get_AlgName()
  866. Deep = Deep_Split.get()
  867. f = Func_Input.get().split(',')
  868. m = Split_XS.get()
  869. if m == 1:must = False
  870. else:must = True
  871. try:
  872. re = alg.Split_Func(name,Deep,f,must)
  873. addNews('拆分成功')
  874. except:
  875. addNews('拆分失败')
  876. return False
  877. if tkinter.messagebox.askokcancel('提示', f'{name}分解结果为:{re[1]},拆分之后:{re[0]},是否应用?'):
  878. for in_alg in re[0]:
  879. alg.addAlgebra('',in_alg)
  880. update_BOX()
  881. def Split_Add():
  882. global alg,Object_Input,Split_XS
  883. name = get_AlgName()
  884. Value = Object_Input.get().split('#')
  885. f = Split_XS.get()
  886. try:
  887. re = alg.Split_Add(name,Value,f)
  888. addNews('拆分成功')
  889. except:
  890. addNews('拆分失败')
  891. return False
  892. if tkinter.messagebox.askokcancel('提示', f'{name}分解结果为:{re[1]},拆分之后:{re[0]},是否应用?'):
  893. for in_alg in re[0]:
  894. alg.addAlgebra('',in_alg)
  895. update_BOX()
  896. def Split_Mul():
  897. global alg,Split_XS
  898. name = get_AlgName()
  899. all = Split_XS.get()
  900. if all == 0:
  901. k = [True,False]
  902. elif all == 1:
  903. k = [False, False]
  904. else:
  905. k = [True, True]
  906. try:
  907. re = alg.Split_Mul(name,*k)
  908. addNews('拆分成功')
  909. except:
  910. addNews('拆分失败')
  911. return False
  912. if tkinter.messagebox.askokcancel('提示', f'{name}分解结果为:{re[1]},拆分之后:{re[0]},是否应用?'):
  913. for in_alg in re[0]:
  914. alg.addAlgebra('',in_alg)
  915. update_BOX()
  916. #统一接口:得到alg的名字(提取第一个)
  917. def get_AlgName():
  918. global alg_list,Alg_BOX
  919. try:
  920. print(alg_list)
  921. name = alg_list[Alg_BOX.curselection()[0]]
  922. print(name)
  923. except:
  924. name = None
  925. addNews('请选定代数式')
  926. return name
  927. #结果显示统一接口
  928. def Re(list,str_= None):#结果显示
  929. global alg,Re_BOX
  930. Re_BOX.delete(0, tkinter.END)
  931. Re_BOX.insert(tkinter.END, *list)
  932. if str_ != None:
  933. Print_Sym_Core(str_)
  934. def Add_Alg():
  935. global AlgName_Input,Alg_Input,Alg_BOX,simp_in,simp_rat,ratio_Input,simp_bool
  936. try:
  937. in_alg = Alg_Input.get()
  938. name = AlgName_Input.get().replace(' ','')
  939. if bool(simp_bool.get()):
  940. radio_list = ratio_Input.get().split('#')
  941. radio = float(radio_list[0])
  942. rat = bool(simp_rat.get())
  943. inverse = bool(simp_in.get())
  944. new_alg = alg.Simplify(in_alg,radio=radio,rat=rat,inv=inverse)
  945. if new_alg != None and tkinter.messagebox.askokcancel('提示', f'约简函数为:{new_alg},是否应用?'):
  946. in_alg = new_alg
  947. if not alg.addAlgebra(name,in_alg):raise Exception
  948. update_BOX()
  949. addNews('代数式新增成功')
  950. except:
  951. addNews('新增代数式无法应用')
  952. #获取预测
  953. def get_JS():
  954. global Value_BOX,Value_List,alg,JS_BOX
  955. try:
  956. try:
  957. n = Value_List[Value_BOX.curselection()[0]]
  958. except:
  959. addNews('请选定符号')
  960. return False
  961. JS_BOX.delete(0, tkinter.END)
  962. JS_BOX.insert(tkinter.END, *alg.Value_assumptions0(n))
  963. addNews('性质预测成功')
  964. except:
  965. addNews('性质预测失败')
  966. #更新列表显示
  967. def update_BOX():
  968. global alg,Value_BOX,Value_List,Alg_BOX,alg_list,Option_List,Option_BOX
  969. #保存符号
  970. re = alg()#0-value,1-alg
  971. Value_List = re[0][1]
  972. #显示符号
  973. Value_BOX.delete(0, tkinter.END)
  974. Value_BOX.insert(tkinter.END, *re[0][0])
  975. #保存代数式
  976. alg_list = re[1][1]
  977. #显示代数式
  978. Alg_BOX.delete(0, tkinter.END)
  979. Alg_BOX.insert(tkinter.END, *re[1][0])
  980. Option_List = []
  981. Option_BOX.delete(0, tkinter.END)
  982. def AddSymbol():#添加自定义Symbol
  983. global AT, RI, PC, EO, FI, CIR, NZ, ValueName_Input,Value_BOX,NONE,INT
  984. #复选框系统
  985. C = []
  986. n = 0
  987. for i in CIR:
  988. C.append(i.get())
  989. n += C[-1]
  990. if n == 1:#选一个设为True
  991. RCIR = [['complex','real','imaginary'][C.index(1)],True]#对象,布尔
  992. elif n == 2:#选两个设为False
  993. RCIR = [['complex','real','imaginary'][C.index(0)],False]#对象,布尔
  994. else:
  995. RCIR = None#其余
  996. C = []
  997. n = 0
  998. for i in CIR:
  999. C.append(i.get())
  1000. n += C[-1]
  1001. if n == 1: # 选一个设为True
  1002. RNZ = [['positive', 'negative', 'zero'][C.index(1)], True] # 对象,布尔
  1003. elif n == 2: # 选两个设为False
  1004. RNZ = [['positive', 'negative', 'zero'][C.index(0)], False] # 对象,布尔
  1005. else:
  1006. RNZ = None # 其余
  1007. try:
  1008. __addSymbot_Core(AT.get(),RI.get(),PC.get(),EO.get(),FI.get(),RCIR,RNZ,INT.get())
  1009. except:
  1010. addNews('自定义符号新增失败')
  1011. def addRSymbol():#添加实数符号
  1012. __addSymbot_Core(RCIR=['real',True],ms='实数(且复数)符号')
  1013. def addZSymbol():#添加整数符号
  1014. __addSymbot_Core(INT=1,ms='整数(且实数)符号')
  1015. def addNPSymbol():#非负实数
  1016. __addSymbot_Core(RNZ=['negative',False],RCIR=['real',True],ms='非负实数符号')
  1017. def addevenSymbol():#偶数
  1018. __addSymbot_Core(EO=1,ms='偶数(且整数)符号')
  1019. def addoddSymbol():#奇数
  1020. __addSymbot_Core(EO=2,ms='奇数(且整数)符号')
  1021. def addZRSymbol():#正实数
  1022. __addSymbot_Core(RNZ=['positive',True],RCIR=['real',True],ms='正实数符号')
  1023. def addZZSymbol():#正整数
  1024. __addSymbot_Core(RNZ=['positive',True],INT=1,ms='正整数符号')
  1025. def addNSymbol():#自然数
  1026. __addSymbot_Core(RNZ=['negative',False],INT=1,ms='自然数(非负整数)符号')
  1027. def addWSymbol():#无约束
  1028. __addSymbot_Core(NONE=1,ms='仅满足交换律的无约束符号')
  1029. #添加Symbol的统一接口
  1030. def __addSymbot_Core(AT=0,RI=0,PC=0,EO=0,FI=0,RCIR=None,RNZ=None,INT=0, NONE=0,ms='自定义符号'):
  1031. global alg
  1032. #代数,有理,质数,偶数,有限实数,复数,正负,整数,取消
  1033. name_list = ValueName_Input.get().split(',')
  1034. for name in name_list:
  1035. try:
  1036. if not alg.addSymbol(name, AT, RI, PC, EO, FI, RCIR, RNZ, INT, NONE,ms): raise Exception
  1037. except:
  1038. addNews(f'新增“{name}”失败')
  1039. addNews(f'新增“{ms}”完成')
  1040. update_BOX()
  1041. def addNews(News):
  1042. global News_BOX,T,top
  1043. T += 1
  1044. News = str(News)
  1045. News_BOX.insert(0, News+f'({T})')
  1046. top.update()
  1047. def Alg():
  1048. global alg,top,Value_List,alg_list,Option_List,Sub_Dic,Sub_Value,Sub_Alg,RSub_Dic,RSub_Value,RSub_Alg,Value_Sub_Dic
  1049. global Z_alg,Y_alg,Solve_list,Answer_List,Z_Inequality,Y_Inequality,p2D_Value,p3D_Value,T
  1050. global bg,bbg,fg,F2,FONT,F3
  1051. alg = Algebra_Polynomial(addNews)
  1052. alg_list = []
  1053. Value_List = []
  1054. top = tkinter.Tk()
  1055. bg = '#FFFAFA'#主颜色
  1056. bbg = '#FFFAFA'#按钮颜色
  1057. fg = '#000000'#文字颜色
  1058. top["bg"] = bg
  1059. FONT = ('Font\ZKST.ttf', 11)#设置字体
  1060. # F2 = tkFont.Font(family='Fixdsys', size=16)
  1061. F2 = ('Fixdsys',16)
  1062. F3 = tkFont.Font(family='Fixdsys', size=11)
  1063. top.title('CoTan代数工厂')
  1064. top.resizable(width=False, height=False)
  1065. top.geometry('+10+10')#设置所在位置
  1066. Option_List = []
  1067. Sub_Dic = {}#Sub替换字典
  1068. Sub_Value = None#选定的Sub符号
  1069. Sub_Alg = None#选定的Sub代数式
  1070. RSub_Dic = {} # Sub替换字典
  1071. RSub_Value = None # 选定的Sub符号
  1072. RSub_Alg = None # 选定的Sub代数式
  1073. Value_Sub_Dic = {}#代数运算空列表
  1074. Z_alg = None
  1075. Y_alg = None
  1076. Solve_list = []
  1077. Answer_List = []
  1078. Z_Inequality = None
  1079. Y_Inequality = None
  1080. p2D_Value = None#画图
  1081. p3D_Value = None
  1082. T = 0
  1083. width_B = 13#标准宽度
  1084. height_B=2
  1085. global Name_Input,FZ_Input,FM_Input,NUM_BOX,AT, RI, PC, EO, FI, CIR, NZ, ValueName_Input, Value_BOX, NONE, INT
  1086. a_y = 0
  1087. a_x = 0
  1088. tkinter.Label(top, text='符号名字:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  1089. ValueName_Input = tkinter.Entry(top, width=width_B * 2)
  1090. ValueName_Input.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
  1091. a_y += 1
  1092. tkinter.Button(top, bg=bbg, fg=fg, text='实数符号(R)', command=addRSymbol, font=FONT, width=width_B,
  1093. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  1094. tkinter.Button(top, bg=bbg, fg=fg, text='整数符号(Z)', command=addZSymbol, font=FONT, width=width_B,
  1095. height=height_B).grid(column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W)
  1096. tkinter.Button(top, bg=bbg, fg=fg, text='非负实数符号', command=addNPSymbol, font=FONT, width=width_B,
  1097. height=height_B).grid(column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W)
  1098. a_y += 1
  1099. tkinter.Button(top, bg=bbg, fg=fg, text='偶数符号', command=addevenSymbol, font=FONT, width=width_B,
  1100. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  1101. tkinter.Button(top, bg=bbg, fg=fg, text='奇数符号', command=addoddSymbol, font=FONT, width=width_B,
  1102. height=height_B).grid(column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W)
  1103. tkinter.Button(top, bg=bbg, fg=fg, text='正数符号', command=addZRSymbol, font=FONT, width=width_B,
  1104. height=height_B).grid(column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1105. a_y += 1
  1106. tkinter.Button(top, bg=bbg, fg=fg, text='自然数符号', command=addNSymbol, font=FONT, width=width_B,
  1107. height=height_B).grid(column=a_x , row=a_y, sticky=tkinter.E + tkinter.W)
  1108. tkinter.Button(top, bg=bbg, fg=fg, text='正整数符号', command=addZZSymbol, font=FONT, width=width_B,
  1109. height=height_B).grid(column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W)
  1110. tkinter.Button(top, bg=bbg, fg=fg, text='无约束符号', command=addWSymbol, font=FONT, width=width_B,
  1111. height=height_B).grid(column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1112. a_y += 1
  1113. AT = tkinter.IntVar()#代数或者超越数
  1114. lable = ['均可','代数','超越数']
  1115. for i in range(3):
  1116. tkinter.Radiobutton(top,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg, text=lable[i], variable=AT, value=i).grid(column=a_x+i, row=a_y, sticky=tkinter.W)
  1117. a_y += 1
  1118. RI = tkinter.IntVar()#有理数或者无理数
  1119. lable = ['均可','有理数','无理数']
  1120. for i in range(3):
  1121. tkinter.Radiobutton(top,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg, text=lable[i], variable=RI, value=i).grid(column=a_x+i, row=a_y, sticky=tkinter.W)
  1122. a_y += 1
  1123. PC = tkinter.IntVar()#质数合数
  1124. lable = ['均可','质数','合数']
  1125. for i in range(3):
  1126. tkinter.Radiobutton(top,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg, text=lable[i], variable=PC, value=i).grid(column=a_x+i, row=a_y, sticky=tkinter.W)
  1127. a_y += 1
  1128. EO = tkinter.IntVar()#奇数偶数
  1129. lable = ['均可','偶数','奇数']
  1130. for i in range(3):
  1131. tkinter.Radiobutton(top,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg, text=lable[i], variable=EO, value=i).grid(column=a_x+i, row=a_y, sticky=tkinter.W)
  1132. a_y += 1
  1133. CIR = []#实数虚数
  1134. lable = ['复数','实数','虚数']
  1135. for i in range(3):
  1136. CIR.append(tkinter.IntVar())
  1137. tkinter.Checkbutton(top,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg, text=lable[i], variable=CIR[-1]).grid(column=a_x+i, row=a_y, sticky=tkinter.W)
  1138. a_y += 1
  1139. NZ = []#正,负,0
  1140. lable = ['正数','负数','零']#复选框
  1141. for i in range(3):
  1142. NZ.append(tkinter.IntVar())
  1143. tkinter.Checkbutton(top,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg, text=lable[i], variable=NZ[-1]).grid(column=a_x+i, row=a_y, sticky=tkinter.W)
  1144. a_y += 1
  1145. FI = tkinter.IntVar()#实数
  1146. lable = ['均可','有限实数','无穷数','广义实数']
  1147. for i in range(3):
  1148. tkinter.Radiobutton(top,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg, text=lable[i], variable=FI, value=i).grid(column=a_x+i, row=a_y, sticky=tkinter.W)
  1149. a_y += 1
  1150. tkinter.Radiobutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text=lable[3],
  1151. variable=FI, value=3).grid(column=a_x, row=a_y, sticky=tkinter.W)#同上的
  1152. INT = tkinter.IntVar()
  1153. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='整数',
  1154. variable=INT).grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
  1155. a_y += 1
  1156. Value_BOX = tkinter.Listbox(top, width=width_B * 3,height = height_B*4) # 显示符号
  1157. Value_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=6,sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  1158. a_y += 6
  1159. tkinter.Button(top, bg=bbg, fg=fg, text='自定义符号', command=AddSymbol, font=FONT, width=width_B,
  1160. height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W) # 添加函数
  1161. tkinter.Button(top, bg=bbg, fg=fg, text='查看假设',command = get_JS, font=FONT, width=width_B, height=height_B).grid(
  1162. column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W) # 添加函数
  1163. tkinter.Button(top, bg=bbg, fg=fg, text='删除符号',command = Del_Symbol, font=FONT, width=width_B, height=height_B).grid(
  1164. column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W) # 添加函数
  1165. global JS_BOX
  1166. a_y += 1
  1167. JS_BOX = tkinter.Listbox(top, width=width_B * 3,height = height_B*5) # 显示函数假设
  1168. JS_BOX.grid(column=a_x, row=a_y,columnspan = 3,rowspan=5, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  1169. a_x += 3
  1170. tkinter.Label(top, text='', bg=bg, fg=fg, font=FONT, width=1).grid(column=a_x, row=0)
  1171. a_x += 1
  1172. global AlgName_Input,Alg_Input,Alg_BOX,simp_in,simp_rat,ratio_Input,simp_bool
  1173. a_y = 0
  1174. tkinter.Label(top, text='代数式:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
  1175. row=a_y) # 设置说明
  1176. Alg_Input = tkinter.Entry(top, width=width_B * 2)
  1177. Alg_Input.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
  1178. a_y += 1
  1179. tkinter.Label(top, text='标识:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
  1180. row=a_y) # 设置说明
  1181. AlgName_Input = tkinter.Entry(top, width=width_B * 2)
  1182. AlgName_Input.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
  1183. a_y += 1
  1184. tkinter.Label(top, text='标准:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
  1185. row=a_y) # 设置说明
  1186. ratio_Input = tkinter.Entry(top, width=width_B * 2)
  1187. ratio_Input.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
  1188. a_y += 1
  1189. simp_rat = tkinter.IntVar()
  1190. tkinter.Checkbutton(top,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg, text='有理化', variable=simp_rat).grid(
  1191. column=a_x, row=a_y, sticky=tkinter.W)
  1192. simp_in = tkinter.IntVar()
  1193. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='忽略假设',
  1194. variable=simp_in).grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
  1195. simp_bool = tkinter.IntVar()
  1196. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='标准化',
  1197. variable=simp_bool).grid(column=a_x + 1, row=a_y, sticky=tkinter.W)
  1198. a_y += 1
  1199. tkinter.Button(top, bg=bbg, fg=fg, text='清空代数式',command=Tra_Alg, font=FONT, width=width_B, height=height_B).grid(
  1200. column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  1201. tkinter.Button(top, bg=bbg, fg=fg, text='生成代数式', command=Add_Alg, font=FONT, width=width_B, height=height_B).grid(
  1202. column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W) # 添加函数
  1203. tkinter.Button(top, bg=bbg, fg=fg, text='删除代数式',command=Del_Alg, font=FONT, width=width_B, height=height_B).grid(
  1204. column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1205. a_y += 1
  1206. Alg_BOX = tkinter.Listbox(top, width=width_B * 3) # 显示代数式
  1207. Alg_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=4, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  1208. global Object_Input,Split_XS,Deep_Split,Func_Input,Rewrite_Input,Rewrite_F_Input,Rewrite_deep
  1209. a_y += 4
  1210. tkinter.Label(top, text='重写对象:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
  1211. row=a_y) # 设置说明
  1212. Rewrite_F_Input = tkinter.Entry(top, width=width_B*2)
  1213. Rewrite_F_Input.grid(column=a_x + 1,columnspan=2, row=a_y, sticky=tkinter.W + tkinter.E)
  1214. a_y += 1
  1215. tkinter.Label(top, text='重写方法:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  1216. Rewrite_Input = tkinter.Entry(top, width=width_B*2)
  1217. Rewrite_Input.grid(column=a_x + 1,columnspan=2, row=a_y, sticky=tkinter.W + tkinter.E)
  1218. a_y += 1
  1219. Rewrite_deep = tkinter.IntVar()
  1220. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='重写子代数式',
  1221. variable=Rewrite_deep).grid(column=a_x+2, row=a_y, sticky=tkinter.W)
  1222. tkinter.Button(top, bg=bbg, fg=fg, text='重写代数式', command=Rewrite, font=FONT, width=width_B, height=height_B).grid(
  1223. column=a_x, row=a_y,columnspan=2, sticky=tkinter.E + tkinter.W)
  1224. a_y += 1
  1225. tkinter.Label(top, text='同类项:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  1226. Object_Input = tkinter.Entry(top, width=width_B * 2)
  1227. Object_Input.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
  1228. a_y += 1
  1229. Split_XS = tkinter.IntVar()#正,负,0
  1230. lable = ['仅系数(同类项)','仅代数式','均保留']#复选框
  1231. for i in range(3):
  1232. tkinter.Radiobutton(top,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg, text=lable[i], variable=Split_XS, value=i).grid(column=a_x+i, row=a_y, sticky=tkinter.W)
  1233. a_y += 1
  1234. tkinter.Label(top, text='拆分函数:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
  1235. row=a_y) # 设置说明
  1236. Func_Input = tkinter.Entry(top, width=width_B)
  1237. Func_Input.grid(column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W)
  1238. Deep_Split = tkinter.IntVar()
  1239. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='完全拆分',
  1240. variable=Deep_Split).grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
  1241. a_y += 1
  1242. tkinter.Button(top, bg=bbg, fg=fg, text='同类项拆分',command=Split_Add, font=FONT, width=width_B, height=height_B).grid(
  1243. column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  1244. tkinter.Button(top, bg=bbg, fg=fg, text='乘法拆分', command=Split_Mul, font=FONT, width=width_B, height=height_B).grid(
  1245. column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W) # 添加函数
  1246. tkinter.Button(top, bg=bbg, fg=fg, text='函数拆分',command=Func_Split, font=FONT, width=width_B, height=height_B).grid(
  1247. column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1248. global Option_BOX
  1249. a_y += 1
  1250. Option_BOX = tkinter.Listbox(top, width=width_B * 3,height = height_B*4) # 显示代数式
  1251. Option_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=4, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  1252. a_y += 4
  1253. tkinter.Button(top, bg=bbg, fg=fg, text='添加',command=Option_Add, font=FONT, width=width_B, height=height_B).grid(
  1254. column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  1255. tkinter.Button(top, bg=bbg, fg=fg, text='清空', command=Option_Tra, font=FONT, width=width_B, height=height_B).grid(
  1256. column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W) # 添加函数
  1257. tkinter.Button(top, bg=bbg, fg=fg, text='删除',command=Option_Del, font=FONT, width=width_B, height=height_B).grid(
  1258. column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1259. global Merge_Func_Input
  1260. a_y += 1
  1261. tkinter.Label(top, text='合成函数:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  1262. Merge_Func_Input = tkinter.Entry(top, width=width_B * 2)
  1263. Merge_Func_Input.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
  1264. a_y += 1
  1265. tkinter.Button(top, bg=bbg, fg=fg, text='多项式合成',command=Merge_Add, font=FONT, width=width_B, height=height_B).grid(
  1266. column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  1267. tkinter.Button(top, bg=bbg, fg=fg, text='因式合成', command=Merge_Mul, font=FONT, width=width_B, height=height_B).grid(
  1268. column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W) # 添加函数
  1269. tkinter.Button(top, bg=bbg, fg=fg, text='函数合成',command=Merge_Func, font=FONT, width=width_B, height=height_B).grid(
  1270. column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1271. global Num_Input
  1272. a_y += 1
  1273. tkinter.Label(top, text='有效数字:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x+1,
  1274. row=a_y) # 设置说明
  1275. Num_Input = tkinter.Entry(top, width=width_B)
  1276. Num_Input.grid(column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1277. tkinter.Button(top, bg=bbg, fg=fg, text='代数式数字化', command=alg_to_Num, font=FONT, width=width_B, height=height_B).grid(
  1278. column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  1279. a_x += 3
  1280. tkinter.Label(top, text='', bg=bg, fg=fg, font=FONT, width=1).grid(column=a_x, row=0)
  1281. a_x += 1
  1282. a_y = 0
  1283. tkinter.Label(top, text='【分式恒等变形】', bg=bg, fg=fg, font=FONT, width=width_B*3, height=height_B).grid(
  1284. column=a_x,row=a_y,columnspan=3) # 设置说明
  1285. global apart_Input,together_deep,radsymbol,radMax_Input
  1286. a_y += 1
  1287. together_deep = tkinter.IntVar()
  1288. tkinter.Label(top, text='裂项关注对象:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  1289. apart_Input = tkinter.Entry(top, width=width_B)
  1290. apart_Input.grid(column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W)
  1291. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='完全转化分式',
  1292. variable=together_deep).grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
  1293. a_y += 1
  1294. radsymbol = tkinter.IntVar()
  1295. tkinter.Label(top, text='最大无理项:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  1296. radMax_Input = tkinter.Entry(top, width=width_B)
  1297. radMax_Input.grid(column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W)
  1298. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='有理化符号分母',
  1299. variable=radsymbol).grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
  1300. a_y += 1
  1301. tkinter.Button(top, bg=bbg, fg=fg, text='最小公分母',command=rat, font=FONT, width=width_B, height=height_B).grid(
  1302. column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  1303. tkinter.Button(top, bg=bbg, fg=fg, text='分式约分',command=canc, font=FONT, width=width_B, height=height_B).grid(
  1304. column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W)
  1305. tkinter.Button(top, bg=bbg, fg=fg, text='分式裂项',command=apart, font=FONT, width=width_B, height=height_B).grid(
  1306. column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W)
  1307. a_y += 1
  1308. tkinter.Button(top, bg=bbg, fg=fg, text='分母有理化',command=Fraction_rat, font=FONT, width=width_B, height=height_B).grid(
  1309. column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  1310. tkinter.Button(top, bg=bbg, fg=fg, text='转化为分式(小改动)',command=as_Fraction, font=FONT, width=width_B, height=height_B).grid(
  1311. column=a_x+1,columnspan=2, row=a_y, sticky=tkinter.E + tkinter.W)
  1312. a_y += 1
  1313. tkinter.Label(top, text='【三角恒等变换】', bg=bg, fg=fg, font=FONT, width=width_B*3, height=height_B).grid(
  1314. column=a_x,row=a_y,columnspan=3) # 设置说明
  1315. global simp_deep
  1316. a_y += 1
  1317. simp_deep = tkinter.IntVar()
  1318. tkinter.Button(top, bg=bbg, fg=fg, text='展开三角函数',command=trig_Expand, font=FONT, width=width_B, height=height_B).grid(
  1319. column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  1320. tkinter.Button(top, bg=bbg, fg=fg, text='三角函数合成',command=trig_Simp, font=FONT, width=width_B, height=height_B).grid(
  1321. column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W)
  1322. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='完全展开',
  1323. variable=simp_deep).grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
  1324. global Fo_exp,Deep_exp
  1325. a_y += 1
  1326. tkinter.Label(top, text='【乘法、指数、对数恒等变形】', bg=bg, fg=fg, font=FONT, width=width_B*3, height=height_B).grid(
  1327. column=a_x,row=a_y,columnspan=3) # 设置说明
  1328. a_y += 1
  1329. Fo_exp = tkinter.IntVar()
  1330. Deep_exp = tkinter.IntVar()
  1331. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='忽略假设',
  1332. variable=Fo_exp).grid(column=a_x + 1, row=a_y, sticky=tkinter.W)
  1333. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='完全展开',
  1334. variable=Deep_exp).grid(column=a_x, row=a_y, sticky=tkinter.W)
  1335. a_y += 1
  1336. tkinter.Button(top, bg=bbg, fg=fg, text='展开乘法',command=mul_Ex, font=FONT, width=width_B, height=height_B).grid(
  1337. column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  1338. tkinter.Button(top, bg=bbg, fg=fg, text='展开加法式幂',command=multinomial_Ex, font=FONT, width=width_B, height=height_B).grid(
  1339. column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W)
  1340. tkinter.Button(top, bg=bbg, fg=fg, text='指数合成', command=multinomial_Simp, font=FONT, width=width_B,
  1341. height=height_B).grid(
  1342. column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1343. a_y += 1
  1344. tkinter.Button(top, bg=bbg, fg=fg, text='化简指数底数',command=exp_Simp_base, font=FONT, width=width_B, height=height_B).grid(
  1345. column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  1346. tkinter.Button(top, bg=bbg, fg=fg, text='化简指数幂',command=exp_Simp_exp, font=FONT, width=width_B, height=height_B).grid(
  1347. column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W)
  1348. tkinter.Button(top, bg=bbg, fg=fg, text='化简指数',command=exp_Simp, font=FONT, width=width_B, height=height_B).grid(
  1349. column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1350. a_y += 1
  1351. tkinter.Button(top, bg=bbg, fg=fg, text='展开指数底数',command=exp_Ex_base, font=FONT, width=width_B, height=height_B).grid(
  1352. column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  1353. tkinter.Button(top, bg=bbg, fg=fg, text='展开指数幂',command=exp_Ex_exp, font=FONT, width=width_B, height=height_B).grid(
  1354. column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W)
  1355. tkinter.Button(top, bg=bbg, fg=fg, text='展开指数',command=exp_Ex, font=FONT, width=width_B, height=height_B).grid(
  1356. column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1357. global Fo_log,Deep_log
  1358. Fo_log = tkinter.IntVar()
  1359. Deep_log = tkinter.IntVar()
  1360. a_y += 1
  1361. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='完全展开',
  1362. variable=Deep_log).grid(column=a_x, row=a_y, sticky=tkinter.W)
  1363. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='忽略假设',
  1364. variable=Fo_log).grid(column=a_x+1, row=a_y, sticky=tkinter.W)
  1365. a_y += 1
  1366. tkinter.Button(top, bg=bbg, fg=fg, text='展开对数',command=log_Ex, font=FONT, width=width_B, height=height_B).grid(
  1367. column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  1368. tkinter.Button(top, bg=bbg, fg=fg, text='化简对数',command=log_Simp, font=FONT, width=width_B, height=height_B).grid(
  1369. column=a_x+1, row=a_y,columnspan=2, sticky=tkinter.E + tkinter.W)
  1370. a_y += 1
  1371. tkinter.Label(top, text='【虚数与特殊函数】', bg=bg, fg=fg, font=FONT, width=width_B*3, height=height_B).grid(
  1372. column=a_x,row=a_y,columnspan=3) # 设置说明
  1373. a_y += 1
  1374. tkinter.Button(top, bg=bbg, fg=fg, text='展开特殊函数',command=Ex_Func, font=FONT, width=width_B, height=height_B).grid(
  1375. column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  1376. tkinter.Button(top, bg=bbg, fg=fg, text='展开虚数',command=Ex_I, font=FONT, width=width_B, height=height_B).grid(
  1377. column=a_x+1, row=a_y,columnspan=2, sticky=tkinter.E + tkinter.W)
  1378. global Simpratio_Input,SimpFunc_Input
  1379. a_y += 1
  1380. tkinter.Label(top, text='【普遍操作类】', bg=bg, fg=fg, font=FONT, width=width_B*3, height=height_B).grid(
  1381. column=a_x,row=a_y,columnspan=3) # 设置说明
  1382. a_y += 1
  1383. tkinter.Label(top, text='简化方案:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  1384. SimpFunc_Input = tkinter.Entry(top, width=width_B)#简化方案
  1385. SimpFunc_Input.grid(column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W)
  1386. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='有理化',
  1387. variable=simp_rat).grid(column=a_x+2, row=a_y, sticky=tkinter.W)
  1388. a_y += 1
  1389. tkinter.Label(top, text='简化比率:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  1390. Simpratio_Input = tkinter.Entry(top, width=width_B)#简化比率
  1391. Simpratio_Input.grid(column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W)
  1392. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='忽略假设',
  1393. variable=simp_in).grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
  1394. global GAOSI,FactorM_Input,Factor_Deep,Factor_Rat
  1395. GAOSI = tkinter.IntVar()
  1396. Factor_Deep = tkinter.IntVar()
  1397. Factor_Rat = tkinter.IntVar()
  1398. a_y += 1
  1399. tkinter.Label(top, text='模数:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  1400. FactorM_Input = tkinter.Entry(top, width=width_B) # 简化比率
  1401. FactorM_Input.grid(column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W)
  1402. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='高斯因式分解',
  1403. variable=GAOSI).grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
  1404. a_y += 1
  1405. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='完全因式分解',
  1406. variable=Factor_Deep).grid(column=a_x, row=a_y, sticky=tkinter.W)
  1407. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='因式分解有理代数式',
  1408. variable=Factor_Rat).grid(column=a_x+1, row=a_y,columnspan=2, sticky=tkinter.W)
  1409. global EX_IM,CollX_Input
  1410. a_y += 1
  1411. EX_IM = tkinter.IntVar()
  1412. tkinter.Label(top, text='同类项对象:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  1413. CollX_Input = tkinter.Entry(top, width=width_B)
  1414. CollX_Input.grid(column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W)
  1415. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='展开复数',
  1416. variable=EX_IM).grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
  1417. a_y += 1
  1418. tkinter.Button(top, bg=bbg, fg=fg, text='化简标准化',command=Simp, font=FONT, width=width_B, height=height_B).grid(
  1419. column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  1420. tkinter.Button(top, bg=bbg, fg=fg, text='普遍运算展开',command=Expansion, font=FONT, width=width_B, height=height_B).grid(
  1421. column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W)
  1422. tkinter.Button(top, bg=bbg, fg=fg, text='因式分解',command=Factor, font=FONT, width=width_B, height=height_B).grid(
  1423. column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1424. a_y += 1
  1425. tkinter.Button(top, bg=bbg, fg=fg, text='合并同类项',command=Coll, font=FONT, width=width_B, height=height_B).grid(
  1426. column=a_x, row=a_y,columnspan=3, sticky=tkinter.E + tkinter.W)
  1427. a_x += 3
  1428. tkinter.Label(top, text='', bg=bg, fg=fg, font=FONT, width=1).grid(column=a_x, row=0)
  1429. a_x += 1
  1430. a_y = 0
  1431. tkinter.Label(top, text='【联立操作】', bg=bg, fg=fg, font=FONT, width=width_B*3, height=height_B).grid(
  1432. column=a_x,row=a_y,columnspan=3) # 设置说明
  1433. a_y += 1
  1434. tkinter.Button(top, bg=bbg, fg=fg, text='选定符号',command = Add_Sub_Value, font=FONT, width=width_B, height=height_B).grid(
  1435. column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  1436. tkinter.Button(top, bg=bbg, fg=fg, text='选定代数式',command = Add_Sub_Alg, font=FONT, width=width_B, height=height_B).grid(
  1437. column=a_x+1, row=a_y, sticky=tkinter.E + tkinter.W)
  1438. tkinter.Button(top, bg=bbg, fg=fg, text='新键联立',command = Add_Sub, font=FONT, width=width_B, height=height_B).grid(
  1439. column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1440. a_y += 1
  1441. tkinter.Button(top, bg=bbg, fg=fg, text='生成联立代数式', command=Alg_Sub,font=FONT, width=width_B, height=height_B).grid(
  1442. column=a_x, columnspan=2,row=a_y, sticky=tkinter.E + tkinter.W)
  1443. tkinter.Button(top, bg=bbg, fg=fg, text='删除联立',command = Del_Sub, font=FONT, width=width_B, height=height_B).grid(
  1444. column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1445. global Sub_BOX
  1446. a_y += 1
  1447. Sub_BOX = tkinter.Listbox(top, width=width_B * 3,height = height_B*4) # 显示代数式
  1448. Sub_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=4, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  1449. a_y += 4
  1450. tkinter.Label(top, text='【反向联立操作】', bg=bg, fg=fg, font=FONT, width=width_B * 3, height=height_B).grid(
  1451. column=a_x, row=a_y, columnspan=3) # 设置说明
  1452. #反向联立系统
  1453. a_y += 1
  1454. tkinter.Button(top, bg=bbg, fg=fg, text='选定代数式', command=Add_RSub_Alg, font=FONT, width=width_B,
  1455. height=height_B).grid(
  1456. column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  1457. tkinter.Button(top, bg=bbg, fg=fg, text='选定符号', command=Add_RSub_Value, font=FONT, width=width_B,
  1458. height=height_B).grid(
  1459. column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W)
  1460. tkinter.Button(top, bg=bbg, fg=fg, text='新键联立', command=Add_RSub, font=FONT, width=width_B, height=height_B).grid(
  1461. column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1462. a_y += 1
  1463. tkinter.Button(top, bg=bbg, fg=fg, text='生成联立代数式', command=Alg_RSub, font=FONT, width=width_B, height=height_B).grid(
  1464. column=a_x, columnspan=2, row=a_y, sticky=tkinter.E + tkinter.W)
  1465. tkinter.Button(top, bg=bbg, fg=fg, text='删除联立', command=Del_RSub, font=FONT, width=width_B, height=height_B).grid(
  1466. column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1467. global RSub_BOX
  1468. a_y += 1
  1469. RSub_BOX = tkinter.Listbox(top, width=width_B * 3, height=height_B * 4) # 显示代数式
  1470. RSub_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=4, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  1471. global ValueNUM_Input,Num_Type
  1472. #代数运算
  1473. a_y += 4
  1474. tkinter.Label(top, text='【赋值运算操作】', bg=bg, fg=fg, font=FONT, width=width_B * 3, height=height_B).grid(
  1475. column=a_x, row=a_y, columnspan=3) # 设置说明
  1476. a_y += 1
  1477. tkinter.Label(top, text='数值:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  1478. ValueNUM_Input = tkinter.Entry(top, width=width_B+2)
  1479. ValueNUM_Input.grid(column=a_x + 1, row=a_y, sticky=tkinter.W)
  1480. tkinter.Button(top, bg=bbg, fg=fg, text='指定符号', command=Add_Sub_Num, font=FONT, width=width_B,
  1481. height=height_B).grid(
  1482. column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1483. a_y += 1
  1484. Num_Type = tkinter.IntVar()#正,负,0
  1485. lable = ['浮点数','整数','分数有理数','无约束数字']#复选框
  1486. for i in range(3):
  1487. tkinter.Radiobutton(top,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg,
  1488. text=lable[i], variable=Num_Type, value=i).grid(column=a_x+i, row=a_y, sticky=tkinter.W)
  1489. a_y += 1
  1490. tkinter.Radiobutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg,
  1491. text=lable[3], variable=Num_Type, value=3).grid(column=a_x + 1, row=a_y, sticky=tkinter.W)
  1492. a_y += 1
  1493. tkinter.Button(top, bg=bbg, fg=fg, text='生成赋值代数式', command=Alg_Sub_Num, font=FONT, width=width_B, height=height_B).grid(
  1494. column=a_x, columnspan=2, row=a_y, sticky=tkinter.E + tkinter.W)
  1495. tkinter.Button(top, bg=bbg, fg=fg, text='删除赋值', command=Del_Sub_Num, font=FONT, width=width_B, height=height_B).grid(
  1496. column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1497. global ValueNUM_BOX
  1498. a_y += 1
  1499. ValueNUM_BOX = tkinter.Listbox(top, width=width_B * 3, height=height_B * 4) # 显示代数式
  1500. ValueNUM_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=5, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  1501. a_x += 3
  1502. tkinter.Label(top, text='', bg=bg, fg=fg, font=FONT, width=1).grid(column=a_x, row=0)
  1503. a_x += 1
  1504. a_y = 0
  1505. tkinter.Label(top, text='【方程联立】', bg=bg, fg=fg, font=FONT, width=width_B * 3, height=height_B).grid(
  1506. column=a_x, row=a_y, columnspan=3) # 设置说明
  1507. a_y += 1
  1508. tkinter.Button(top, bg=bbg, fg=fg, text='左代数式', command=add_Z, font=FONT, width=width_B,
  1509. height=height_B).grid(
  1510. column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  1511. tkinter.Button(top, bg=bbg, fg=fg, text='右代数式', command=add_Y, font=FONT, width=width_B,
  1512. height=height_B).grid(
  1513. column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W)
  1514. tkinter.Button(top, bg=bbg, fg=fg, text='新建方程', command=add_ZY, font=FONT, width=width_B, height=height_B).grid(
  1515. column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1516. a_y += 1
  1517. tkinter.Button(top, bg=bbg, fg=fg, text='解联立方程', command=alg_Solve, font=FONT, width=width_B, height=height_B).grid(
  1518. column=a_x, columnspan=2, row=a_y, sticky=tkinter.E + tkinter.W)
  1519. tkinter.Button(top, bg=bbg, fg=fg, text='删除方程', command=Del_Solve, font=FONT, width=width_B, height=height_B).grid(
  1520. column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1521. global Solve_BOX
  1522. a_y += 1
  1523. Solve_BOX = tkinter.Listbox(top, width=width_B * 3, height=height_B * 2) # 显示代数式
  1524. Solve_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=2, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  1525. a_y +=2
  1526. tkinter.Button(top, bg=bbg, fg=fg, text='应用为代数式', command=To_Alg, font=FONT, width=width_B,
  1527. height=height_B).grid(
  1528. column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  1529. tkinter.Button(top, bg=bbg, fg=fg, text='添加联立', command=To_Sub, font=FONT, width=width_B,
  1530. height=height_B).grid(
  1531. column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W)
  1532. tkinter.Button(top, bg=bbg, fg=fg, text='添加反联立', command=To_RSub, font=FONT, width=width_B, height=height_B).grid(
  1533. column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1534. global Answer_BOX
  1535. a_y += 1
  1536. Answer_BOX = tkinter.Listbox(top, width=width_B * 3, height=height_B * 2) # 显示代数式
  1537. Answer_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=2, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  1538. a_y += 2
  1539. tkinter.Label(top, text='【解不等式】', bg=bg, fg=fg, font=FONT, width=width_B * 3, height=height_B).grid(
  1540. column=a_x, row=a_y, columnspan=3) # 设置说明
  1541. a_y += 1
  1542. tkinter.Button(top, bg=bbg, fg=fg, text='左代数式', command=In_add_Z, font=FONT, width=width_B,
  1543. height=height_B).grid(
  1544. column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  1545. tkinter.Button(top, bg=bbg, fg=fg, text='右代数式', command=In_add_Y, font=FONT, width=width_B,
  1546. height=height_B).grid(
  1547. column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W)
  1548. tkinter.Button(top, bg=bbg, fg=fg, text='不等式运算', command=Inequality_Solve, font=FONT, width=width_B, height=height_B).grid(
  1549. column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1550. global Inequality_BOX,Inequality_Type,AnswerInequality_BOX,Range_Input
  1551. a_y += 1
  1552. Inequality_BOX = tkinter.Listbox(top, width=width_B * 3, height=height_B) # 显示代数式
  1553. Inequality_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=1, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  1554. a_y += 1
  1555. Inequality_Type = tkinter.IntVar()#实数
  1556. lable = ['大于>','小于<','大于等于>=','小于等于<=']
  1557. for i in range(2):
  1558. tkinter.Radiobutton(top,command=Update_Inequality_BOX,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg, text=lable[i], variable=Inequality_Type, value=i).grid(column=a_x+i, row=a_y, sticky=tkinter.W)
  1559. a_y += 1
  1560. for i in range(2):
  1561. i += 2
  1562. tkinter.Radiobutton(top,command=Update_Inequality_BOX,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg, text=lable[i], variable=Inequality_Type, value=i).grid(column=a_x+i-2, row=a_y, sticky=tkinter.W)
  1563. a_y += 1
  1564. AnswerInequality_BOX = tkinter.Listbox(top, width=width_B * 3, height=height_B) # 显示代数式
  1565. AnswerInequality_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=2, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  1566. a_y += 2
  1567. tkinter.Label(top, text='【代数式画图】', bg=bg, fg=fg, font=FONT, width=width_B * 3, height=height_B).grid(
  1568. column=a_x, row=a_y, columnspan=3) # 设置说明
  1569. a_y += 1
  1570. tkinter.Label(top, text='符号取值范围:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y) # 设置说明
  1571. Range_Input = tkinter.Entry(top, width=width_B+2)
  1572. Range_Input.grid(column=a_x + 1, row=a_y, sticky=tkinter.W)
  1573. tkinter.Button(top, bg=bbg, fg=fg, text='指定符号', command=add_PlotValue, font=FONT, width=width_B,
  1574. height=height_B).grid(
  1575. column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1576. global PlotValue_BOX,Plot_Type
  1577. a_y += 1
  1578. PlotValue_BOX = tkinter.Listbox(top, width=width_B * 3, height=height_B) # 显示代数式
  1579. PlotValue_BOX.grid(column=a_x, row=a_y, columnspan=3, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  1580. a_y += 1
  1581. Plot_Type = tkinter.IntVar()#实数
  1582. lable = ['二维图像','三维图像']
  1583. for i in range(2):
  1584. tkinter.Radiobutton(top,command=Update_PlotValue,bg = bg,fg = fg,activebackground=bg,activeforeground=fg,selectcolor=bg, text=lable[i], variable=Plot_Type, value=i).grid(column=a_x+i, row=a_y, sticky=tkinter.W)
  1585. tkinter.Button(top, bg=bbg, fg=fg, text='绘制图像', command=Plotting, font=FONT, width=width_B,
  1586. height=height_B).grid(column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
  1587. a_y += 1
  1588. tkinter.Button(top, bg=bbg, fg=fg, text='绘制代数式', command=Draw_An_Alg, font=FONT, width=width_B,
  1589. height=height_B).grid(
  1590. column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
  1591. tkinter.Button(top, bg=bbg, fg=fg, text='绘制树状图', command=Print_Sym, font=FONT, width=width_B,
  1592. height=height_B).grid(
  1593. column=a_x + 1, row=a_y,columnspan=2, sticky=tkinter.E + tkinter.W)
  1594. global News_BOX,Can_Input,kd_bool,logkd_bool
  1595. a_y += 1
  1596. kd_bool = tkinter.IntVar()
  1597. logkd_bool = tkinter.IntVar()
  1598. Can_Input = tkinter.Entry(top, width=width_B)
  1599. Can_Input.grid(column=a_x, row=a_y, sticky=tkinter.W+tkinter.E)
  1600. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='每项绘制括号',
  1601. variable=kd_bool).grid(column=a_x+1, row=a_y,columnspan=2, sticky=tkinter.W)
  1602. tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='对数绘制括号',
  1603. variable=logkd_bool).grid(column=a_x+2, row=a_y,columnspan=2, sticky=tkinter.W)
  1604. a_y += 1
  1605. News_BOX = tkinter.Listbox(top, width=width_B * 3, height=height_B) # 显示代数式
  1606. News_BOX.grid(column=a_x, row=a_y, columnspan=3,rowspan=3, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  1607. addNews('加载完成')
  1608. top.mainloop()