gui.py 104 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685
  1. import tkinter
  2. import tkinter.messagebox
  3. import tkinter.font as tkfont
  4. import os
  5. from algebraicfactory.controller import AlgebraPolynomial
  6. from system import exception_catch, QueueController
  7. queue_controller = QueueController()
  8. algebra_list = []
  9. variable_list = []
  10. SCREEN = tkinter.Tk()
  11. bg_color = "#FFFAFA" # 主颜色
  12. buttom_color = "#FFFAFA" # 按钮颜色
  13. word_color = "#000000" # 文字颜色
  14. SCREEN["bg"] = bg_color
  15. FONT = ("黑体", 11) # 设置字体
  16. FONT2 = ("Fixdsys", 16)
  17. FONT3 = tkfont.Font(family="Fixdsys", size=11)
  18. SCREEN.title("CoTan代数工厂")
  19. SCREEN.resizable(width=False, height=False)
  20. SCREEN.geometry("+10+10") # 设置所在位置
  21. SCREEN.iconbitmap(bitmap=f'Pic{os.sep}favicon.ico', default=f'Pic{os.sep}favicon.ico')
  22. option_list = []
  23. value_algebra_dict = {} # Sub替换字典
  24. left_value = None # 选定的Sub符号
  25. right_algebra = None # 选定的Sub代数式
  26. algebra_value_dict = {} # Sub替换字典
  27. right_value = None # 选定的Sub符号
  28. left_algebra = None # 选定的Sub代数式
  29. value_sub_dict = {} # 代数运算空列表
  30. left_equation = None
  31. right_equation = None
  32. equation_set = []
  33. equation_solution_set = []
  34. left_inequality = None
  35. right_inequality = None
  36. p2d_value = None # 画图
  37. p3d_value = None
  38. prompt_num = 0
  39. gui_width = 13 # 标准宽度
  40. gui_height = 2
  41. row = 0
  42. column = 0
  43. new_text = None
  44. class UIAPI:
  45. @staticmethod
  46. @exception_catch()
  47. def update_simultaneous_equations_box_gui():
  48. box = []
  49. if left_equation is not None or right_equation is not None:
  50. box.append(f"(选定){left_equation} = {right_equation}")
  51. for i in equation_set:
  52. box.append(f"{i[0]} = {i[1]}")
  53. equation_box.delete(0, tkinter.END)
  54. equation_box.insert(tkinter.END, *box)
  55. @staticmethod
  56. @exception_catch()
  57. def get_merge_func_gui():
  58. return merge_func.get()
  59. @staticmethod
  60. @exception_catch()
  61. def add_variable_assignment_gui():
  62. return number.get(), number_type.get()
  63. @staticmethod
  64. @exception_catch()
  65. def algebraic_partition_gui():
  66. deep = deep_split.get()
  67. f = split_func.get().split(",")
  68. m = return_type.get()
  69. if m == 1:
  70. must = False
  71. else:
  72. must = True
  73. return deep, f, m, must
  74. @staticmethod
  75. @exception_catch()
  76. def algebraic_similarity_split_gui():
  77. name = API.get_algebraic_name_gui()
  78. value = similar_items.get().split("#")
  79. f = return_type.get()
  80. return f, name, value
  81. @staticmethod
  82. @exception_catch()
  83. def algebraic_factorization_gui():
  84. all_ = return_type.get()
  85. if all_ == 0:
  86. return True, False
  87. elif all_ == 1:
  88. return False, False
  89. else:
  90. return True, True
  91. @staticmethod
  92. @exception_catch()
  93. def askok_gui(message):
  94. return tkinter.messagebox.askokcancel('提示', message)
  95. @staticmethod
  96. @exception_catch()
  97. def get_algebraic_name_gui():
  98. global algebra_list, algebra_box
  99. try:
  100. name = algebra_list[algebra_box.curselection()[0]]
  101. except IndexError:
  102. API.output_prompt_gui("请选定代数式")
  103. raise
  104. return name
  105. @staticmethod
  106. @exception_catch()
  107. def add_algebraic_gui():
  108. alg_str = algebra_expression.get()
  109. name = algebra_name.get().replace(" ", "")
  110. ratdio_list = ratdio.get().split("#")
  111. try:
  112. the_ratdio = float(ratdio_list[0])
  113. except (ValueError, IndexError):
  114. the_ratdio = 1.7
  115. rat = bool(init_rationalization.get())
  116. inverse = bool(init_ignore_assumptions.get())
  117. the_standardization = bool(standardization.get())
  118. return alg_str, inverse, name, rat, the_ratdio, the_standardization
  119. @staticmethod
  120. @exception_catch()
  121. def update_predictions_box_gui(index):
  122. predictions_box.delete(0, tkinter.END)
  123. predictions_box.insert(tkinter.END, *algebra_controller.variable_prediction(index))
  124. @staticmethod
  125. @exception_catch()
  126. def update_symbol_algebraic_box_gui():
  127. global algebra_controller, variable_box, variable_list, algebra_box, algebra_list, option_list, on_hold_algebra
  128. # 保存符号
  129. re = algebra_controller() # 0-value,1-alg
  130. variable_list = re[0][1]
  131. # 显示符号
  132. variable_box.delete(0, tkinter.END)
  133. variable_box.insert(tkinter.END, *re[0][0])
  134. # 保存代数式
  135. algebra_list = re[1][1]
  136. # 显示代数式
  137. algebra_box.delete(0, tkinter.END)
  138. algebra_box.insert(tkinter.END, *re[1][0])
  139. option_list = []
  140. on_hold_algebra.delete(0, tkinter.END)
  141. @staticmethod
  142. @exception_catch()
  143. def update_operation_box_gui():
  144. global on_hold_algebra, option_list
  145. re = []
  146. for i in range(len(option_list)):
  147. re.append(f"({i + 1}) --> {option_list[i]}")
  148. on_hold_algebra.delete(0, tkinter.END)
  149. on_hold_algebra.insert(tkinter.END, *re)
  150. @staticmethod
  151. @exception_catch()
  152. def get_on_hold_algebra_gui():
  153. return on_hold_algebra.curselection()[0]
  154. @staticmethod
  155. @exception_catch()
  156. def denominator_rationalization_gui():
  157. try:
  158. maximum = int(maximum_irrational_term.get())
  159. except ValueError:
  160. maximum = 4
  161. rationalized = bool(rationalized_unknown.get())
  162. return maximum, rationalized
  163. @staticmethod
  164. @exception_catch()
  165. def get_fully_divided_gui():
  166. deep = bool(fully_divided.get())
  167. return deep
  168. @staticmethod
  169. @exception_catch()
  170. def get_apart_gui():
  171. x = apart.get().replace(" ", "")
  172. if x == "":
  173. x = None
  174. return x
  175. @staticmethod
  176. @exception_catch()
  177. def get_trig_fully_expand_gui():
  178. return bool(trig_fully_expand.get())
  179. @staticmethod
  180. @exception_catch()
  181. def get_ignore_assumptions_gui():
  182. return not bool(ignore_assumptions.get())
  183. @staticmethod
  184. @exception_catch()
  185. def get_fully_expand_gui():
  186. deep = bool(fully_expand.get())
  187. return deep
  188. @staticmethod
  189. @exception_catch()
  190. def get_reduce_log_gui():
  191. return not bool(ignore_assumptions_log.get())
  192. @staticmethod
  193. @exception_catch()
  194. def get_expand_log_gui():
  195. return bool(log_fully_expand.get()), not bool(ignore_assumptions_log.get())
  196. @staticmethod
  197. @exception_catch()
  198. def get_standardization_gui():
  199. try:
  200. radio = float(simplify_ratio_input.get())
  201. except ValueError:
  202. radio = 1.7
  203. rat = bool(init_rationalization.get())
  204. inverse = bool(init_ignore_assumptions.get())
  205. name = API.get_algebraic_name_gui()
  206. return inverse, name, radio, rat
  207. @staticmethod
  208. @exception_catch()
  209. def get_factorization_gui():
  210. gaussian = bool(is_gaussian.get())
  211. deep = bool(fully_factor.get())
  212. rat = bool(factor_rat.get())
  213. try:
  214. modulus_num = int(modulus.get())
  215. except ValueError:
  216. modulus_num = None
  217. return deep, gaussian, modulus_num, rat
  218. @staticmethod
  219. @exception_catch()
  220. def get_is_expand_complex_gui():
  221. return bool(is_expand_complex.get())
  222. @staticmethod
  223. @exception_catch()
  224. def get_similar_items_gui():
  225. global similar_items_object
  226. return similar_items_object.get().split("#")
  227. @staticmethod
  228. @exception_catch()
  229. def get_valid_number_gui():
  230. global valid_number
  231. try:
  232. num = int(valid_number.get())
  233. except ValueError:
  234. num = 5
  235. return num
  236. @staticmethod
  237. @exception_catch()
  238. def get_value_algebra_box_index_gui():
  239. return value_algebra_box.curselection()[0]
  240. @staticmethod
  241. @exception_catch()
  242. def update_value_algebraic_box_gui():
  243. global algebra_controller, variable_list, variable_box, value_algebra_dict, right_algebra, left_value
  244. global value_algebra_box
  245. box = []
  246. if left_value is not None or right_algebra is not None:
  247. box.append(f"选定:{left_value} = {right_algebra}")
  248. for v in value_algebra_dict:
  249. box.append(f"{v} = {value_algebra_dict[v]}")
  250. value_algebra_box.delete(0, tkinter.END)
  251. value_algebra_box.insert(tkinter.END, *box)
  252. @staticmethod
  253. @exception_catch()
  254. def get_algebra_value_box_index_gui():
  255. global algebra_value_box
  256. return algebra_value_box.curselection()[0]
  257. @staticmethod
  258. @exception_catch()
  259. def update_algebraic_value_box_gui():
  260. global algebra_controller, algebra_value_dict, left_algebra, right_value, algebra_value_box
  261. box = []
  262. if right_value is not None or left_algebra is not None:
  263. box.append(f"选定:{left_algebra} = {right_value}")
  264. for v in algebra_value_dict:
  265. box.append(f"{v} = {algebra_value_dict[v]}")
  266. algebra_value_box.delete(0, tkinter.END)
  267. algebra_value_box.insert(tkinter.END, *box)
  268. @staticmethod
  269. @exception_catch()
  270. def get_variable_assignment_box_index_gui():
  271. global variable_assignment_box
  272. return variable_assignment_box.curselection()[0]
  273. @staticmethod
  274. @exception_catch()
  275. def update_variable_assignment_box_gui():
  276. global algebra_controller, value_sub_dict, variable_assignment_box
  277. box = []
  278. for v in value_sub_dict:
  279. box.append(f"{v} = {value_sub_dict[v]}")
  280. variable_assignment_box.delete(0, tkinter.END)
  281. variable_assignment_box.insert(tkinter.END, *box)
  282. @staticmethod
  283. @exception_catch()
  284. def get_equation_box_index_gui():
  285. global equation_box
  286. return equation_box.curselection()[0]
  287. @staticmethod
  288. @exception_catch()
  289. def update_equation_solution_box_gui(re):
  290. global equation_solution_box
  291. equation_solution_box.delete(0, tkinter.END)
  292. equation_solution_box.insert(tkinter.END, *re)
  293. @staticmethod
  294. @exception_catch()
  295. def equation_solution_set_gui():
  296. return equation_solution_set[equation_solution_box.curselection()[0]][1]
  297. @staticmethod
  298. @exception_catch()
  299. def update_inequality_solution_box_gui(get):
  300. inequality_solution_box.delete(0, tkinter.END)
  301. inequality_solution_box.insert(tkinter.END, *get)
  302. @staticmethod
  303. @exception_catch()
  304. def get_inequality_symbol_gui():
  305. return inequality_symbol.get()
  306. @staticmethod
  307. @exception_catch()
  308. def rewrite_algebra_gui():
  309. func = rewrite_func.get()
  310. rewrite = rewrite_object.get().split(",")
  311. deep = bool(rewrite_deep.get())
  312. name = API.get_algebraic_name_gui()
  313. if rewrite == [""]:
  314. rewrite = []
  315. return deep, func, name, rewrite
  316. @staticmethod
  317. @exception_catch()
  318. def update_inequality_box_gui():
  319. global left_inequality, right_inequality, inequality_symbol, inequality_box
  320. re = []
  321. if left_inequality is not None and right_inequality is not None:
  322. inequality_type = [">", "<", ">=", "<="][inequality_symbol.get()]
  323. re.append(f"{left_inequality} {inequality_type} {right_inequality}")
  324. else:
  325. if left_inequality is not None:
  326. re.append(f"左代数式:{left_inequality}")
  327. if right_inequality is not None:
  328. re.append(f"右代数式:{right_inequality}")
  329. inequality_box.delete(0, tkinter.END)
  330. inequality_box.insert(tkinter.END, *re)
  331. @staticmethod
  332. @exception_catch()
  333. def update_plot_value_gui():
  334. global plot_object_box, plot_type, p2d_value, p3d_value
  335. ty = plot_type.get()
  336. re = []
  337. try:
  338. if ty == 0: # 2D
  339. re = [f"二维:{p2d_value[0]} -> ({p2d_value[1]},{p2d_value[2]})"]
  340. else:
  341. re = [
  342. f"三维:{p2d_value[0]} -> ({p2d_value[1]},{p2d_value[2]})",
  343. f"三维:{p3d_value[0]} -> ({p3d_value[1]},{p3d_value[2]})",
  344. ]
  345. except IndexError:
  346. pass
  347. plot_object_box.delete(0, tkinter.END)
  348. plot_object_box.insert(tkinter.END, *re)
  349. @staticmethod
  350. @exception_catch()
  351. def get_range_of_values_gui():
  352. global range_of_values
  353. return range_of_values.get().split(",")
  354. @staticmethod
  355. @exception_catch()
  356. def get_var_name_gui():
  357. global variable_list, variable_box
  358. return variable_list[variable_box.curselection()[0]]
  359. @staticmethod
  360. @exception_catch()
  361. def creat_tree_gui(bg_color_, h, str_, w):
  362. global new_text
  363. new_top = tkinter.Toplevel(bg=bg_color_)
  364. new_top.resizable(width=False, height=False)
  365. new_top.geometry("+10+10") # 设置所在位置
  366. new_text = tkinter.Text(new_top, width=w, height=h)
  367. new_text.pack()
  368. new_text.delete(1.0, tkinter.END)
  369. new_text.insert(tkinter.END, str_)
  370. new_text.config(state=tkinter.DISABLED)
  371. @staticmethod
  372. @exception_catch()
  373. def creat_text_gui(font, paint_container, te, x, y):
  374. paint_container.create_text(x, y, font=font, text=te)
  375. @staticmethod
  376. @exception_catch()
  377. def make_artboard_gui(h, w):
  378. new_top = tkinter.Toplevel(bg=bg_color)
  379. new_top.resizable(width=False, height=False)
  380. new_top.geometry("+10+10") # 设置所在位置
  381. paint_container = tkinter.Canvas(new_top, bg=bg_color, width=w, height=h)
  382. paint_container.pack()
  383. return paint_container, new_top
  384. @staticmethod
  385. @exception_catch()
  386. def draw_algebra_gui():
  387. return bool(bracket.get()), bool(log_bracket.get()), can_input.get().split(",")
  388. @staticmethod
  389. @exception_catch()
  390. def add_custom_symbol_gui():
  391. # 复选框系统
  392. parameter = []
  393. n = 0
  394. for i in is_complex:
  395. parameter.append(i.get())
  396. n += parameter[-1]
  397. if n == 1: # 选一个设为True
  398. is_the_complex = [
  399. ["complex", "real", "imaginary"][parameter.index(1)],
  400. True,
  401. ] # 对象,布尔
  402. elif n == 2: # 选两个设为False
  403. is_the_complex = [
  404. ["complex", "real", "imaginary"][parameter.index(0)],
  405. False,
  406. ] # 对象,布尔
  407. else:
  408. is_the_complex = None # 其余
  409. parameter = []
  410. n = 0
  411. for i in is_positives:
  412. parameter.append(i.get())
  413. n += parameter[-1]
  414. if n == 1: # 选一个设为True
  415. is_natural = [
  416. ["positive", "negative", "zero"][parameter.index(1)],
  417. True,
  418. ] # 对象,布尔
  419. elif n == 2: # 选两个设为False
  420. is_natural = [
  421. ["positive", "negative", "zero"][parameter.index(0)],
  422. False,
  423. ] # 对象,布尔
  424. else:
  425. is_natural = None # 其余
  426. return [
  427. is_generation.get(),
  428. is_rational.get(),
  429. is_prime.get(),
  430. is_even.get(),
  431. is_limited.get(),
  432. is_the_complex,
  433. is_natural,
  434. integer.get(),
  435. ]
  436. @staticmethod
  437. @exception_catch()
  438. def get_var_name_list_gui(): # 获取variable_name的name而不是box
  439. name_list = variable_name.get().split(",")
  440. return name_list
  441. @staticmethod
  442. @exception_catch()
  443. def output_prompt_gui(news):
  444. global prompt_box, prompt_num, SCREEN
  445. prompt_num += 1
  446. news = str(news)
  447. prompt_box.insert(0, news + f"({prompt_num})")
  448. SCREEN.update()
  449. class API(UIAPI):
  450. @staticmethod
  451. @exception_catch()
  452. def algebraic_factorization():
  453. name = API.get_algebraic_name_gui()
  454. try:
  455. re = algebra_controller.split_mul(name, *API.algebraic_factorization_gui())
  456. except BaseException:
  457. API.output_prompt_gui("拆分失败")
  458. raise
  459. else:
  460. API.output_prompt_gui("拆分成功")
  461. if tkinter.messagebox.askokcancel("提示", f"{name}分解结果为:{re[1]},拆分之后:{re[0]},是否应用?"):
  462. for in_alg in re[0]:
  463. algebra_controller.add_expression("", in_alg)
  464. API.update_symbol_algebraic_box_gui()
  465. @staticmethod
  466. @exception_catch()
  467. def draw_algebra_core():
  468. bracket_, log_bracket_, wh = API.draw_algebra_gui()
  469. name = API.get_algebraic_name_gui()
  470. get = algebra_controller.get_expression_from_name(name)
  471. try:
  472. w = int(wh[0])
  473. h = int(wh[1])
  474. except (ValueError, IndexError):
  475. w = 1000
  476. h = 300
  477. size = 20
  478. font = ("Fixdsys", size)
  479. x = 30
  480. y = 150
  481. plot_len = (size / 16) * 5.5
  482. paint_container, new_top = API.make_artboard_gui(h, w)
  483. for i in get:
  484. if i[0] == "A":
  485. te = f"{i[1]}"
  486. x += len(te) * plot_len
  487. API.creat_text_gui(font, paint_container, te, x, y)
  488. x += len(te) * plot_len
  489. elif i[0] == "B":
  490. if bracket_:
  491. x, y, q = API.draw_algebra_son(
  492. [["A", "["]],
  493. paint_container,
  494. x,
  495. y,
  496. size - 5,
  497. [],
  498. bracket_,
  499. log_bracket_,
  500. ) # 递归呼叫儿子
  501. x, y, h = API.draw_algebra_son(
  502. i[1], paint_container, x, y, size, [], bracket_, log_bracket_
  503. ) # 底数
  504. dy = y
  505. y = h - 10
  506. x, y, q = API.draw_algebra_son(
  507. i[2], paint_container, x, y, size - 5, [], bracket_, log_bracket_
  508. ) # 指数
  509. y = dy
  510. if bracket_:
  511. x, y, q = API.draw_algebra_son(
  512. [["A", "]"]],
  513. paint_container,
  514. x,
  515. y,
  516. size - 5,
  517. [],
  518. bracket_,
  519. log_bracket_,
  520. ) # 递归呼叫儿子
  521. elif i[0] == "C":
  522. if bracket_:
  523. x, y, q = API.draw_algebra_son(
  524. [["A", "["]],
  525. paint_container,
  526. x,
  527. y,
  528. size - 5,
  529. [],
  530. bracket_,
  531. log_bracket_,
  532. ) # 递归呼叫儿子
  533. x, y, h = API.draw_algebra_son(
  534. i[1], paint_container, x, y, size, [], bracket_, log_bracket_
  535. ) # log符号
  536. if log_bracket_:
  537. x, y, q = API.draw_algebra_son(
  538. [["A", "("]],
  539. paint_container,
  540. x,
  541. y,
  542. size - 5,
  543. [],
  544. bracket_,
  545. log_bracket_,
  546. ) # 递归呼叫儿子
  547. x, y, q = API.draw_algebra_son(
  548. i[2], paint_container, x, y, size, [], bracket_, log_bracket_
  549. ) # 递归呼叫儿子
  550. if log_bracket_:
  551. x, y, q = API.draw_algebra_son(
  552. [["A", ")"]],
  553. paint_container,
  554. x,
  555. y,
  556. size - 5,
  557. [],
  558. bracket_,
  559. log_bracket_,
  560. ) # 递归呼叫儿子
  561. if bracket_:
  562. x, y, q = API.draw_algebra_son(
  563. [["A", "]"]],
  564. paint_container,
  565. x,
  566. y,
  567. size - 5,
  568. [],
  569. bracket_,
  570. log_bracket_,
  571. ) # 递归呼叫儿子
  572. elif i[0] == "D":
  573. if bracket_:
  574. x, y, q = API.draw_algebra_son(
  575. [["A", "["]],
  576. paint_container,
  577. x,
  578. y,
  579. size - 5,
  580. [],
  581. bracket_,
  582. log_bracket_,
  583. ) # 递归呼叫儿子
  584. y -= 20
  585. a_x, y, h = API.draw_algebra_son(
  586. i[1], paint_container, x, y, size, [], bracket_, log_bracket_
  587. ) # log符号
  588. y += 40
  589. b_x, y, h = API.draw_algebra_son(
  590. i[2], paint_container, x, y, size, [], bracket_, log_bracket_
  591. ) # log符号
  592. n_x = max([a_x, b_x]) - x
  593. y -= 20
  594. x, y, h = API.draw_algebra_son(
  595. [("A", "-" * int((n_x / (2 * plot_len))))],
  596. paint_container,
  597. x,
  598. y,
  599. size,
  600. [],
  601. bracket_,
  602. log_bracket_,
  603. ) # log符号
  604. if bracket_:
  605. x, y, q = API.draw_algebra_son(
  606. [["A", "]"]],
  607. paint_container,
  608. x,
  609. y,
  610. size - 5,
  611. [],
  612. bracket_,
  613. log_bracket_,
  614. ) # 递归呼叫儿子
  615. API.output_prompt_gui("运算完毕")
  616. @staticmethod
  617. @exception_catch()
  618. def draw_algebra_son(n, paint_container, x, y, size, max_y, bracket_=True, log_bracket_=True):
  619. font = ("Fixdsys", size)
  620. plot_len = (size / 16) * 5.5
  621. for i in n:
  622. if i[0] == "A": # 只有A才是真的画图,其他是移动坐标
  623. max_y.append(y)
  624. te = f"{i[1]}"
  625. x += len(te) * plot_len
  626. API.creat_text_gui(font, paint_container, te, x, y)
  627. x += len(te) * plot_len
  628. elif i[0] == "B":
  629. if bracket_:
  630. x, y, q = API.draw_algebra_son(
  631. [["A", "["]],
  632. paint_container,
  633. x,
  634. y,
  635. size - 5,
  636. [],
  637. bracket_,
  638. log_bracket_,
  639. ) # 递归呼叫儿子
  640. x, y, h = API.draw_algebra_son(
  641. i[1], paint_container, x, y, size, max_y, bracket_, log_bracket_
  642. ) # 底数
  643. dy = y
  644. y = h - 10
  645. x, y, q = API.draw_algebra_son(
  646. i[2], paint_container, x, y, size - 5, max_y, bracket_, log_bracket_
  647. ) # 递归呼叫儿子
  648. y = dy
  649. if bracket_:
  650. x, y, q = API.draw_algebra_son(
  651. [["A", "]"]],
  652. paint_container,
  653. x,
  654. y,
  655. size - 5,
  656. [],
  657. bracket_,
  658. log_bracket_,
  659. ) # 递归呼叫儿子
  660. elif i[0] == "C":
  661. if bracket_:
  662. x, y, q = API.draw_algebra_son(
  663. [["A", "["]],
  664. paint_container,
  665. x,
  666. y,
  667. size - 5,
  668. [],
  669. bracket_,
  670. log_bracket_,
  671. ) # 递归呼叫儿子
  672. x, y, h = API.draw_algebra_son(
  673. i[1], paint_container, x, y, size, [], bracket_, log_bracket_
  674. ) # log符号
  675. if log_bracket_:
  676. x, y, q = API.draw_algebra_son(
  677. [["A", "("]],
  678. paint_container,
  679. x,
  680. y,
  681. size - 5,
  682. [],
  683. bracket_,
  684. log_bracket_,
  685. ) # 递归呼叫儿子
  686. x, y, q = API.draw_algebra_son(
  687. i[2], paint_container, x, y, size, [], bracket_, log_bracket_
  688. ) # 递归呼叫儿子
  689. if log_bracket_:
  690. x, y, q = API.draw_algebra_son(
  691. [["A", ")"]],
  692. paint_container,
  693. x,
  694. y,
  695. size - 5,
  696. [],
  697. bracket_,
  698. log_bracket_,
  699. ) # 递归呼叫儿子
  700. if bracket_:
  701. x, y, q = API.draw_algebra_son(
  702. [["A", "]"]],
  703. paint_container,
  704. x,
  705. y,
  706. size - 5,
  707. [],
  708. bracket_,
  709. log_bracket_,
  710. ) # 递归呼叫儿子
  711. elif i[0] == "D":
  712. if bracket_:
  713. x, y, q = API.draw_algebra_son(
  714. [["A", "["]],
  715. paint_container,
  716. x,
  717. y,
  718. size - 5,
  719. [],
  720. bracket_,
  721. log_bracket_,
  722. ) # 递归呼叫儿子
  723. y -= 20
  724. a_x, y, h = API.draw_algebra_son(
  725. i[1], paint_container, x, y, size, [], bracket_, log_bracket_
  726. ) # log符号
  727. y += 40
  728. b_x, y, h = API.draw_algebra_son(
  729. i[2], paint_container, x, y, size, [], bracket_, log_bracket_
  730. ) # log符号
  731. n_x = max([a_x, b_x]) - x
  732. y -= 20
  733. x, y, h = API.draw_algebra_son(
  734. [("A", "-" * int((n_x / (2 * plot_len))))],
  735. paint_container,
  736. x,
  737. y,
  738. size,
  739. [],
  740. bracket_,
  741. log_bracket_,
  742. ) # log符号
  743. if bracket_:
  744. x, y, q = API.draw_algebra_son(
  745. [["A", "]"]],
  746. paint_container,
  747. x,
  748. y,
  749. size - 5,
  750. [],
  751. bracket_,
  752. log_bracket_,
  753. ) # 递归呼叫儿子
  754. try:
  755. re = min(max_y)
  756. except ValueError:
  757. re = 150
  758. return x, y, re
  759. @staticmethod
  760. @exception_catch()
  761. def show_algebraic():
  762. str_ = algebra_controller.print_expression(API.get_algebraic_name_gui())
  763. try:
  764. wh = can_input.get().split(",")
  765. w = int(wh[0]) / 10
  766. h = int(wh[1]) / 10
  767. except (ValueError, IndexError):
  768. w = 40
  769. h = 20
  770. API.output_prompt_gui("系统运算中")
  771. API.creat_tree_gui(bg_color, h, str_, w)
  772. API.output_prompt_gui("运算完毕")
  773. @staticmethod
  774. @exception_catch()
  775. def clear_algebra():
  776. try:
  777. algebra_controller.clean_expression()
  778. API.update_symbol_algebraic_box_gui()
  779. API.output_prompt_gui("删除完成")
  780. except BaseException:
  781. API.output_prompt_gui("删除失败")
  782. raise
  783. @staticmethod
  784. @exception_catch()
  785. def del_algebra():
  786. name = API.get_algebraic_name_gui()
  787. try:
  788. algebra_controller.del_expression(name)
  789. except BaseException:
  790. API.output_prompt_gui("删除失败")
  791. raise
  792. else:
  793. API.update_symbol_algebraic_box_gui()
  794. API.output_prompt_gui("删除完成")
  795. @staticmethod
  796. @exception_catch()
  797. def del_symbol():
  798. name = API.get_var_name_gui()
  799. try:
  800. algebra_controller.del_symbol(name)
  801. except BaseException:
  802. API.output_prompt_gui("删除失败")
  803. raise
  804. else:
  805. API.update_symbol_algebraic_box_gui()
  806. API.output_prompt_gui("删除完成")
  807. @staticmethod
  808. @exception_catch()
  809. def get_plot_type():
  810. global plot_type
  811. return plot_type.get()
  812. @staticmethod
  813. @exception_catch()
  814. def drawing_image():
  815. try:
  816. the_plot_type = API.get_plot_type()
  817. if p2d_value is None:
  818. raise Exception
  819. if the_plot_type == 1 and p3d_value is None:
  820. raise Exception
  821. name = API.get_algebraic_name_gui()
  822. algebra_controller.plot(name, p2d_value, p3d_value)
  823. except BaseException:
  824. API.output_prompt_gui("画图失败")
  825. raise
  826. @staticmethod
  827. @exception_catch()
  828. def add_plot_value():
  829. global p2d_value, p3d_value
  830. try:
  831. try:
  832. value = API.get_var_name_gui()
  833. except BaseException:
  834. API.output_prompt_gui("请选定符号")
  835. raise
  836. value_range = API.get_range_of_values_gui()
  837. if value_range == [""]:
  838. value_range = [-10, 10]
  839. tup = [value] + [
  840. min((float(value_range[0]), float(value_range[1]))),
  841. max((float(value_range[0]), float(value_range[1]))),
  842. ]
  843. ty = API.get_plot_type()
  844. except BaseException:
  845. API.output_prompt_gui("修改失败")
  846. raise
  847. if p2d_value is None:
  848. p2d_value = tup
  849. elif p3d_value is None and ty == 1:
  850. if p2d_value[0] != tup[0]:
  851. p3d_value = tup
  852. else:
  853. p2d_value = tup
  854. else:
  855. if ty == 0: # 2D
  856. p2d_value = tup
  857. p3d_value = None
  858. else: # 3D
  859. if p2d_value[0] == tup[0]:
  860. p2d_value = tup
  861. elif p3d_value[0] == tup[0]:
  862. p3d_value = tup
  863. else:
  864. p2d_value = p3d_value
  865. p3d_value = tup
  866. API.output_prompt_gui("修改完成")
  867. API.update_plot_value_gui()
  868. @staticmethod
  869. @exception_catch()
  870. def rewrite_algebra():
  871. deep, func, name, rewrite = API.rewrite_algebra_gui()
  872. try:
  873. get = algebra_controller.rewrite_exp(name, func, rewrite, deep)
  874. API.output_prompt_gui("运行完成")
  875. API.apply_algebraic_tips(get, f"代数式重写的结果为:{get},是否应用?")
  876. except BaseException:
  877. API.output_prompt_gui("运行失败")
  878. raise
  879. @staticmethod
  880. @exception_catch()
  881. def inequality_solve():
  882. if left_inequality is not None and right_inequality is not None:
  883. type_ = API.get_inequality_symbol_gui()
  884. try:
  885. get = algebra_controller.solving_inequality(
  886. [left_inequality, right_inequality], type_
  887. )
  888. API.update_inequality_solution_box_gui(get)
  889. API.output_prompt_gui("运行完成")
  890. except BaseException:
  891. API.output_prompt_gui("解不等式失败")
  892. raise
  893. @staticmethod
  894. @exception_catch()
  895. def add_left_algebra():
  896. global left_inequality
  897. left_inequality = API.get_algebraic_name_gui()
  898. API.update_inequality_box_gui()
  899. @staticmethod
  900. @exception_catch()
  901. def add_right_algebra():
  902. global right_inequality
  903. right_inequality = API.get_algebraic_name_gui()
  904. API.update_inequality_box_gui()
  905. @staticmethod
  906. @exception_catch()
  907. def add_to_algebraic_box():
  908. get = API.equation_solution_set_gui()[
  909. 1
  910. ] # [1]取结果
  911. API.apply_algebraic_tips(get, f"联立结果为:{get},是否应用?")
  912. @staticmethod
  913. @exception_catch()
  914. def add_to_value_algebraic_box():
  915. get = API.equation_solution_set_gui()
  916. value_algebra_dict[get[0]] = get[1]
  917. API.update_value_algebraic_box_gui()
  918. @staticmethod
  919. @exception_catch()
  920. def add_to_algebraic_value_box():
  921. get = API.equation_solution_set_gui()
  922. algebra_value_dict[get[1]] = get[0]
  923. API.update_algebraic_value_box_gui()
  924. @staticmethod
  925. @exception_catch()
  926. def solve_simultaneous_equations():
  927. global equation_solution_set
  928. try:
  929. get = algebra_controller.solving_equations(equation_set)
  930. API.output_prompt_gui("运行成功")
  931. except BaseException:
  932. API.output_prompt_gui("解方程失败")
  933. raise
  934. equation_solution_set = []
  935. re = []
  936. for i in get:
  937. re.append(f"{i[0]} = {i[1]}") # i[0]是一个字母=i[1]是一个代数式
  938. equation_solution_set.append((i[0], i[1]))
  939. API.update_equation_solution_box_gui(re)
  940. @staticmethod
  941. @exception_catch()
  942. def del_equation():
  943. global left_equation, right_equation
  944. num = API.get_equation_box_index_gui()
  945. if left_equation is not None or right_equation is not None:
  946. if num == 0:
  947. left_equation = None
  948. right_equation = None
  949. else:
  950. num -= 1
  951. del equation_set[num]
  952. else:
  953. del equation_set[num]
  954. API.update_simultaneous_equations_box_gui()
  955. @staticmethod
  956. @exception_catch()
  957. def generating_equation():
  958. global left_equation, right_equation
  959. if left_equation is not None and right_equation is not None:
  960. equation_set.append((left_equation, right_equation))
  961. left_equation = None
  962. right_equation = None
  963. API.update_simultaneous_equations_box_gui()
  964. @staticmethod
  965. @exception_catch()
  966. def add_equation_left():
  967. global left_equation
  968. left_equation = API.get_algebraic_name_gui()
  969. API.update_simultaneous_equations_box_gui()
  970. @staticmethod
  971. @exception_catch()
  972. def add_equation_right():
  973. global right_equation
  974. right_equation = API.get_algebraic_name_gui()
  975. API.update_simultaneous_equations_box_gui()
  976. @staticmethod
  977. @exception_catch()
  978. def algebraic_assignment():
  979. name = API.get_algebraic_name_gui()
  980. try:
  981. get = algebra_controller.algebraic_assignment(name, value_sub_dict)
  982. API.output_prompt_gui("运算成功")
  983. except BaseException:
  984. API.output_prompt_gui("代数运算失败")
  985. raise
  986. API.apply_algebraic_tips(get, f"联立结果为:{get},是否应用?")
  987. @staticmethod
  988. @exception_catch()
  989. def del_variable_assignment():
  990. num = API.get_variable_assignment_box_index_gui()
  991. del value_sub_dict[list(value_sub_dict.keys())[num]]
  992. API.update_variable_assignment_box_gui()
  993. @staticmethod
  994. @exception_catch()
  995. def add_variable_assignment():
  996. try:
  997. value_name = API.get_variable_assignment_box_index_gui()
  998. except BaseException:
  999. API.output_prompt_gui("请选定符号")
  1000. raise
  1001. value_num = algebra_controller.creat_num(*API.add_variable_assignment_gui()) # 不同类型
  1002. value_sub_dict[value_name] = value_num
  1003. API.update_variable_assignment_box_gui()
  1004. @staticmethod
  1005. @exception_catch()
  1006. def algebragic_value_simultaneous():
  1007. name = API.get_algebraic_name_gui()
  1008. try:
  1009. get = algebra_controller.algebragic_value_simultaneous(name, algebra_value_dict)
  1010. API.output_prompt_gui("反向联立完成")
  1011. except BaseException:
  1012. API.output_prompt_gui("无法联立")
  1013. raise
  1014. API.apply_algebraic_tips(get, f"联立结果为:{get},是否应用?")
  1015. @staticmethod
  1016. @exception_catch()
  1017. def del_algebraic_value_simultaneousness():
  1018. global left_algebra, right_value
  1019. num = API.get_algebra_value_box_index_gui()
  1020. if right_value is not None or left_algebra is not None:
  1021. if num == 0:
  1022. right_value = None
  1023. left_algebra = None
  1024. else:
  1025. num -= 1
  1026. del algebra_value_dict[list(algebra_value_dict.keys())[num]]
  1027. else:
  1028. del algebra_value_dict[list(algebra_value_dict.keys())[num]]
  1029. API.update_algebraic_value_box_gui()
  1030. @staticmethod
  1031. @exception_catch()
  1032. def add_algebraic_values_simultaneously():
  1033. global left_algebra, right_value
  1034. if right_value is not None and left_algebra is not None:
  1035. algebra_value_dict[left_algebra] = right_value
  1036. right_value, left_algebra = None, None
  1037. API.update_algebraic_value_box_gui()
  1038. @staticmethod
  1039. @exception_catch()
  1040. def add_left_simultaneous_algebra(): # 代数式=值的左代数式
  1041. global left_algebra
  1042. alg_name = API.get_algebraic_name_gui()
  1043. left_algebra = alg_name
  1044. API.update_algebraic_value_box_gui()
  1045. @staticmethod
  1046. @exception_catch()
  1047. def add_right_simultaneous_values(): # 解释同上
  1048. global right_value
  1049. try:
  1050. value_name = API.get_var_name_gui()
  1051. except BaseException:
  1052. API.output_prompt_gui("请选定符号")
  1053. raise
  1054. right_value = value_name
  1055. API.update_algebraic_value_box_gui()
  1056. @staticmethod
  1057. @exception_catch()
  1058. def value_algebraic_simultaneous():
  1059. name = API.get_algebraic_name_gui()
  1060. try:
  1061. get = algebra_controller.value_algebraic_simultaneous(name, value_algebra_dict)
  1062. API.output_prompt_gui("联立完成")
  1063. except BaseException:
  1064. API.output_prompt_gui("无法联立")
  1065. raise
  1066. API.apply_algebraic_tips(get, f"联立结果为:{get},是否应用?")
  1067. @staticmethod
  1068. @exception_catch()
  1069. def del_value_algebraic_simultaneous():
  1070. global right_algebra, left_value
  1071. num = API.get_value_algebra_box_index_gui()
  1072. if left_value is not None or right_algebra is not None:
  1073. if num == 0:
  1074. left_value = None
  1075. right_algebra = None
  1076. else:
  1077. num -= 1
  1078. del value_algebra_dict[list(value_algebra_dict.keys())[num]]
  1079. else:
  1080. del value_algebra_dict[list(value_algebra_dict.keys())[num]]
  1081. API.update_value_algebraic_box_gui()
  1082. @staticmethod
  1083. @exception_catch()
  1084. def add_value_algebraic_simultaneous():
  1085. global right_algebra, left_value
  1086. if left_value is not None and right_algebra is not None:
  1087. value_algebra_dict[left_value] = right_algebra
  1088. left_value, right_algebra = None, None
  1089. API.update_value_algebraic_box_gui()
  1090. @staticmethod
  1091. @exception_catch()
  1092. def add_right_simultaneous_algebra():
  1093. global right_algebra
  1094. alg_name = API.get_algebraic_name_gui()
  1095. right_algebra = alg_name
  1096. API.update_value_algebraic_box_gui()
  1097. @staticmethod
  1098. @exception_catch()
  1099. def add_left_simultaneous_values():
  1100. global left_value
  1101. try:
  1102. value_name = API.get_var_name_gui()
  1103. except BaseException:
  1104. API.output_prompt_gui("请选定符号")
  1105. raise
  1106. left_value = value_name
  1107. API.update_value_algebraic_box_gui()
  1108. @staticmethod
  1109. @exception_catch()
  1110. def algebraic_digitization():
  1111. try:
  1112. get = (algebra_controller
  1113. .algebraic_digitization(API.get_algebraic_name_gui(), API.get_valid_number_gui()))
  1114. API.output_prompt_gui("数字化完成")
  1115. except BaseException:
  1116. API.output_prompt_gui("数字化失败")
  1117. raise
  1118. API.apply_algebraic_tips(get, f"数字化的结果为:{get},是否应用?")
  1119. @staticmethod
  1120. @exception_catch()
  1121. def expand_special():
  1122. name = API.get_algebraic_name_gui()
  1123. try:
  1124. get = algebra_controller.expand_special(name)
  1125. API.output_prompt_gui("运算成功")
  1126. except BaseException:
  1127. API.output_prompt_gui("运算失败")
  1128. raise
  1129. API.apply_algebraic_tips(get, f"展开特殊函数的结果为:{get},是否应用?")
  1130. @staticmethod
  1131. @exception_catch()
  1132. def expand_complex():
  1133. name = API.get_algebraic_name_gui()
  1134. try:
  1135. get = algebra_controller.expand_complex(name)
  1136. API.output_prompt_gui("运算成功")
  1137. except BaseException:
  1138. API.output_prompt_gui("运算失败")
  1139. raise
  1140. API.apply_algebraic_tips(get, f"展开虚数的结果为:{get},是否应用?")
  1141. @staticmethod
  1142. @exception_catch()
  1143. def merger_of_similar_items():
  1144. name = API.get_algebraic_name_gui()
  1145. try:
  1146. get = algebra_controller.merger_of_similar_items(name, API.get_similar_items_gui())
  1147. API.output_prompt_gui("运算成功")
  1148. except BaseException:
  1149. API.output_prompt_gui("运算失败")
  1150. raise
  1151. API.apply_algebraic_tips(get, f"合并同类项的结果为:{get},是否应用?")
  1152. @staticmethod
  1153. @exception_catch()
  1154. def general_expansion():
  1155. complex_ = API.get_is_expand_complex_gui()
  1156. name = API.get_algebraic_name_gui()
  1157. try:
  1158. get = algebra_controller.expansion(name, complex_)
  1159. API.output_prompt_gui("运算成功")
  1160. except BaseException:
  1161. API.output_prompt_gui("运算失败")
  1162. raise
  1163. API.apply_algebraic_tips(get, f"普遍展开的结果为:{get},是否应用?")
  1164. @staticmethod
  1165. @exception_catch()
  1166. def factorization():
  1167. name = API.get_algebraic_name_gui()
  1168. deep, gaussian, modulus_num, rat = API.get_factorization_gui()
  1169. try:
  1170. get = algebra_controller.factor(name, modulus_num, gaussian, deep, rat)
  1171. API.output_prompt_gui("运算成功")
  1172. except BaseException:
  1173. API.output_prompt_gui("运算失败")
  1174. raise
  1175. API.apply_algebraic_tips(get, f"因式分解的结果为:{get},是否应用?")
  1176. @staticmethod
  1177. @exception_catch()
  1178. def simplify_standardization():
  1179. inverse, name, radio, rat = API.get_standardization_gui()
  1180. try:
  1181. get = algebra_controller.simplify(name, radio, rat=rat, inv=inverse)
  1182. API.output_prompt_gui("运算成功")
  1183. except BaseException:
  1184. API.output_prompt_gui("运算失败")
  1185. raise
  1186. API.apply_algebraic_tips(get, f"化简(标准化)为:{get},是否应用?")
  1187. @staticmethod
  1188. @exception_catch()
  1189. def apply_algebraic_tips(re, message):
  1190. if API.askok_gui(message):
  1191. algebra_controller.add_expression("", re)
  1192. API.update_symbol_algebraic_box_gui()
  1193. @staticmethod
  1194. @exception_catch()
  1195. def expand_log():
  1196. deep, ignore_assumptions_ = API.get_expand_log_gui()
  1197. name = API.get_algebraic_name_gui()
  1198. try:
  1199. get = algebra_controller.log_expansion(name, ignore_assumptions_, deep)
  1200. API.output_prompt_gui("运算成功")
  1201. except BaseException:
  1202. API.output_prompt_gui("运算失败")
  1203. raise
  1204. API.apply_algebraic_tips(get, f"展开对数结果为:{get},是否应用?")
  1205. @staticmethod
  1206. @exception_catch()
  1207. def reduce_log():
  1208. ignore = API.get_reduce_log_gui()
  1209. name = API.get_algebraic_name_gui()
  1210. try:
  1211. get = algebra_controller.log_simp(name, ignore)
  1212. API.output_prompt_gui("运算成功")
  1213. except BaseException:
  1214. API.output_prompt_gui("运算失败")
  1215. raise
  1216. API.apply_algebraic_tips(get, f"化简对数结果为:{get},是否应用?")
  1217. @staticmethod
  1218. @exception_catch()
  1219. def expand_mul():
  1220. name = API.get_algebraic_name_gui()
  1221. try:
  1222. get = algebra_controller.mul_expansion(name)
  1223. API.output_prompt_gui("运算成功")
  1224. except BaseException:
  1225. API.output_prompt_gui("运算失败")
  1226. raise
  1227. API.apply_algebraic_tips(get, f"展开乘法结果为:{get},是否应用?")
  1228. @staticmethod
  1229. @exception_catch()
  1230. def expand_additive_index():
  1231. global algebra_controller, ignore_assumptions
  1232. name = API.get_algebraic_name_gui()
  1233. try:
  1234. get = algebra_controller.multinomial_expansion(name)
  1235. API.output_prompt_gui("运算成功")
  1236. except BaseException:
  1237. API.output_prompt_gui("运算失败")
  1238. raise
  1239. API.apply_algebraic_tips(get, f"展开加法式幂结果为:{get},是否应用?")
  1240. @staticmethod
  1241. @exception_catch()
  1242. def composite_index():
  1243. name = API.get_algebraic_name_gui()
  1244. try:
  1245. get = algebra_controller.pow_simp_multinomial(name)
  1246. API.output_prompt_gui("运算成功")
  1247. except BaseException:
  1248. API.output_prompt_gui("运算失败")
  1249. raise
  1250. API.apply_algebraic_tips(get, f"合成幂指数的结果为:{get},是否应用?(彻底化简加法式幂可以使用因式分解)")
  1251. @staticmethod
  1252. @exception_catch()
  1253. def expand_exp_base():
  1254. deep = API.get_fully_expand_gui()
  1255. name = API.get_algebraic_name_gui()
  1256. try:
  1257. get = algebra_controller.pow_expansion_base(name, deep)
  1258. API.output_prompt_gui("运算成功")
  1259. except BaseException:
  1260. API.output_prompt_gui("运算失败")
  1261. raise
  1262. API.apply_algebraic_tips(get, f"展开指数底数结果为:{get},是否应用?")
  1263. @staticmethod
  1264. @exception_catch()
  1265. def expand_exp_index():
  1266. deep = API.get_fully_expand_gui()
  1267. name = API.get_algebraic_name_gui()
  1268. try:
  1269. get = algebra_controller.pow_expansion_exp(name, deep)
  1270. except BaseException:
  1271. API.output_prompt_gui("运算失败")
  1272. raise
  1273. API.apply_algebraic_tips(get, f"展开指数幂结果为:{get},是否应用?")
  1274. @staticmethod
  1275. @exception_catch()
  1276. def expand_power():
  1277. deep = API.get_fully_expand_gui()
  1278. name = API.get_algebraic_name_gui()
  1279. try:
  1280. get = algebra_controller.pow_expansion_core(name, deep)
  1281. API.output_prompt_gui("运算成功")
  1282. except BaseException:
  1283. API.output_prompt_gui("运算失败")
  1284. raise
  1285. API.apply_algebraic_tips(get, f"展开指数结果为:{get},是否应用?")
  1286. @staticmethod
  1287. @exception_catch()
  1288. def reduce_exp_base():
  1289. ignore = API.get_ignore_assumptions_gui()
  1290. name = API.get_algebraic_name_gui()
  1291. try:
  1292. get = algebra_controller.pow_simp_base(name, ignore)
  1293. API.output_prompt_gui("运算成功")
  1294. except BaseException:
  1295. API.output_prompt_gui("运算失败")
  1296. raise
  1297. API.apply_algebraic_tips(get, f"化简指数底数结果为:{get},是否应用?")
  1298. @staticmethod
  1299. @exception_catch()
  1300. def reduce_exp_index():
  1301. ignore = API.get_ignore_assumptions_gui()
  1302. name = API.get_algebraic_name_gui()
  1303. try:
  1304. get = algebra_controller.pow_simp_exp(name, ignore)
  1305. API.output_prompt_gui("运算成功")
  1306. except BaseException:
  1307. API.output_prompt_gui("运算失败")
  1308. raise
  1309. API.apply_algebraic_tips(get, f"化简指数幂结果为:{get},是否应用?")
  1310. @staticmethod
  1311. @exception_catch()
  1312. def reduced_power():
  1313. ignore = API.get_ignore_assumptions_gui()
  1314. name = API.get_algebraic_name_gui()
  1315. try:
  1316. get = algebra_controller.pow_simp_core(name, ignore)
  1317. API.output_prompt_gui("运算成功")
  1318. except BaseException:
  1319. API.output_prompt_gui("运算失败")
  1320. raise
  1321. API.apply_algebraic_tips(get, f"化简指数结果为:{get},是否应用?")
  1322. @staticmethod
  1323. @exception_catch()
  1324. def reduced_trigonometric(): # 三角函数化简
  1325. name = API.get_algebraic_name_gui()
  1326. try:
  1327. get = algebra_controller.trig_simp(name)
  1328. API.output_prompt_gui("运算成功")
  1329. except BaseException:
  1330. API.output_prompt_gui("运算失败")
  1331. raise
  1332. API.apply_algebraic_tips(get, f"三角化简结果为:{get},是否应用?")
  1333. @staticmethod
  1334. @exception_catch()
  1335. def expand_trigonometric(): # 三角展开
  1336. deep = API.get_trig_fully_expand_gui()
  1337. name = API.get_algebraic_name_gui()
  1338. try:
  1339. get = algebra_controller.trig_expansion(name, deep)
  1340. API.output_prompt_gui("运算成功")
  1341. except BaseException:
  1342. API.output_prompt_gui("运算失败")
  1343. raise
  1344. API.apply_algebraic_tips(get, f"三角展开结果为:{get},是否应用?")
  1345. @staticmethod
  1346. @exception_catch()
  1347. def fractional_division(): # 通分
  1348. name = API.get_algebraic_name_gui()
  1349. try:
  1350. get = algebra_controller.fractional_merge(name)
  1351. API.output_prompt_gui("运算成功")
  1352. except BaseException:
  1353. API.output_prompt_gui("运算失败")
  1354. raise
  1355. API.apply_algebraic_tips(get, f"分式通分结果为:{get},是否应用?")
  1356. @staticmethod
  1357. @exception_catch()
  1358. def fraction_reduction(): # 约分
  1359. name = API.get_algebraic_name_gui()
  1360. try:
  1361. get = algebra_controller.fraction_reduction(name)
  1362. API.output_prompt_gui("运算成功")
  1363. except BaseException:
  1364. API.output_prompt_gui("运算失败")
  1365. raise
  1366. API.apply_algebraic_tips(get, f"分式约分结果为:{get},是否应用?")
  1367. @staticmethod
  1368. @exception_catch()
  1369. def fractional_fission(): # 裂项
  1370. name = API.get_algebraic_name_gui()
  1371. try:
  1372. get = algebra_controller.fractional_fission(name, API.get_apart_gui())
  1373. API.output_prompt_gui("运算成功")
  1374. except BaseException:
  1375. API.output_prompt_gui("运算失败")
  1376. raise
  1377. API.apply_algebraic_tips(get, f"分式裂项结果为:{get},是否应用?")
  1378. @staticmethod
  1379. @exception_catch()
  1380. def fractional_synthesis(): # together
  1381. deep = API.get_fully_divided_gui()
  1382. name = API.get_algebraic_name_gui()
  1383. try:
  1384. get = algebra_controller.as_fraction(name, deep)
  1385. API.output_prompt_gui("运算成功")
  1386. except BaseException:
  1387. API.output_prompt_gui("运算失败")
  1388. raise
  1389. API.apply_algebraic_tips(get, f"合成分式结果为:{get},是否应用?")
  1390. @staticmethod
  1391. @exception_catch()
  1392. def denominator_rationalization(): # 分母有理化
  1393. maximum, rationalized = API.denominator_rationalization_gui()
  1394. name = API.get_algebraic_name_gui()
  1395. try:
  1396. get = algebra_controller.fractional_rat(name, rationalized, maximum)
  1397. API.output_prompt_gui("运算成功")
  1398. except BaseException:
  1399. API.output_prompt_gui("运算失败")
  1400. raise
  1401. API.apply_algebraic_tips(get, f"分母有理化结果为:{get},是否应用?")
  1402. @staticmethod
  1403. @exception_catch()
  1404. def add_operation_algebra():
  1405. name = API.get_algebraic_name_gui()
  1406. if name is None:
  1407. raise
  1408. option_list.append(name)
  1409. API.update_operation_box_gui()
  1410. @staticmethod
  1411. @exception_catch()
  1412. def del_operation_algebra():
  1413. del option_list[API.get_on_hold_algebra_gui()]
  1414. API.update_operation_box_gui()
  1415. @staticmethod
  1416. @exception_catch()
  1417. def clear_operational_algebra():
  1418. API.update_symbol_algebraic_box_gui()
  1419. @staticmethod
  1420. @exception_catch()
  1421. def algebraic_composition():
  1422. global algebra_controller, option_list
  1423. name = option_list.copy()
  1424. if len(name) < 2:
  1425. raise Exception
  1426. try:
  1427. re = algebra_controller.merge_func(name, API.get_merge_func_gui())
  1428. API.output_prompt_gui("合成成功")
  1429. except BaseException:
  1430. API.output_prompt_gui("合成失败")
  1431. raise
  1432. API.apply_algebraic_tips(re, f"合成结果为:{re},是否应用?")
  1433. @staticmethod
  1434. @exception_catch()
  1435. def algebraic_multiplication():
  1436. name = option_list.copy()
  1437. if len(name) < 2:
  1438. raise Exception
  1439. try:
  1440. re = algebra_controller.merge_mul(name)
  1441. API.output_prompt_gui("合成成功")
  1442. except BaseException:
  1443. API.output_prompt_gui("合成失败")
  1444. raise
  1445. API.apply_algebraic_tips(re, f"合成结果为:{re},是否应用?")
  1446. @staticmethod
  1447. @exception_catch()
  1448. def algebraic_addition():
  1449. name = option_list.copy()
  1450. if len(name) < 2:
  1451. raise Exception
  1452. try:
  1453. re = algebra_controller.merge_add(name)
  1454. API.output_prompt_gui("合成成功")
  1455. except BaseException:
  1456. API.output_prompt_gui("合成失败")
  1457. raise
  1458. API.apply_algebraic_tips(re, f"合成结果为:{re},是否应用?")
  1459. @staticmethod
  1460. @exception_catch()
  1461. def algebraic_partition():
  1462. name = API.get_algebraic_name_gui()
  1463. deep, f, m, must = API.algebraic_partition_gui()
  1464. try:
  1465. re = algebra_controller.split_func(name, deep, f, must)
  1466. API.output_prompt_gui("拆分成功")
  1467. except BaseException:
  1468. API.output_prompt_gui("拆分失败")
  1469. raise
  1470. API.split_apply_algebraic_tips(re, f"{name}分解结果为:{re[1]},拆分之后:{re[0]},是否应用?")
  1471. @staticmethod
  1472. @exception_catch()
  1473. def split_apply_algebraic_tips(re, message):
  1474. if API.askok_gui(message):
  1475. for in_alg in re[0]:
  1476. algebra_controller.add_expression("", in_alg)
  1477. API.update_symbol_algebraic_box_gui()
  1478. @staticmethod
  1479. @exception_catch()
  1480. def algebraic_similarity_split():
  1481. f, name, value = API.algebraic_similarity_split_gui()
  1482. try:
  1483. re = algebra_controller.split_add(name, value, f)
  1484. API.output_prompt_gui("拆分成功")
  1485. except BaseException:
  1486. API.output_prompt_gui("拆分失败")
  1487. raise
  1488. API.split_apply_algebraic_tips(re, f"{name}分解结果为:{re[1]},拆分之后:{re[0]},是否应用?")
  1489. @staticmethod
  1490. @exception_catch()
  1491. def add_algebraic():
  1492. try:
  1493. (
  1494. alg_str,
  1495. inverse,
  1496. name,
  1497. rat,
  1498. the_ratdio,
  1499. the_standardization,
  1500. ) = API.add_algebraic_gui()
  1501. if the_standardization: # 标准化
  1502. new_alg = algebra_controller.simplify(
  1503. alg_str, ratdio=the_ratdio, rat=rat, inv=inverse
  1504. )
  1505. alg_str = API.application(alg_str, new_alg)
  1506. if not algebra_controller.add_expression(name, alg_str):
  1507. raise Exception
  1508. API.update_symbol_algebraic_box_gui()
  1509. API.output_prompt_gui("代数式新增成功")
  1510. except BaseException:
  1511. API.output_prompt_gui("新增代数式无法应用")
  1512. raise
  1513. @staticmethod
  1514. @exception_catch()
  1515. def application(alg_str, new_alg):
  1516. if new_alg is not None and API.askok_gui(f"约简函数为:{new_alg},是否应用?"):
  1517. alg_str = new_alg
  1518. return alg_str
  1519. @staticmethod
  1520. @exception_catch()
  1521. def get_predictions():
  1522. global variable_box, variable_list, algebra_controller, predictions_box
  1523. try:
  1524. try:
  1525. index = API.get_var_name_gui()
  1526. except BaseException:
  1527. API.output_prompt_gui("请选定符号")
  1528. raise
  1529. API.update_predictions_box_gui(index)
  1530. API.output_prompt_gui("性质预测成功")
  1531. except BaseException:
  1532. API.output_prompt_gui("性质预测失败")
  1533. raise
  1534. @staticmethod
  1535. @exception_catch()
  1536. def add_custom_symbol(): # 添加自定义Symbol
  1537. try:
  1538. API.__add_symbot_core(*API.add_custom_symbol_gui())
  1539. except BaseException:
  1540. API.output_prompt_gui("自定义符号新增失败")
  1541. raise
  1542. @staticmethod
  1543. @exception_catch()
  1544. def add_real(): # 添加实数符号
  1545. API.__add_symbot_core(is_complex_=["real", True], describe_="实数(且复数)符号")
  1546. @staticmethod
  1547. @exception_catch()
  1548. def add_integer(): # 添加整数符号
  1549. API.__add_symbot_core(is_integer_=1, describe_="整数(且实数)符号")
  1550. @staticmethod
  1551. @exception_catch()
  1552. def add_non_negative_real(): # 非负实数
  1553. API.__add_symbot_core(
  1554. is_natural_=["negative", False], is_complex_=["real", True], describe_="非负实数符号"
  1555. )
  1556. @staticmethod
  1557. @exception_catch()
  1558. def add_even(): # 偶数
  1559. API.__add_symbot_core(is_even_=1, describe_="偶数(且整数)符号")
  1560. @staticmethod
  1561. @exception_catch()
  1562. def add_odd(): # 奇数
  1563. API.__add_symbot_core(is_even_=2, describe_="奇数(且整数)符号")
  1564. @staticmethod
  1565. @exception_catch()
  1566. def add_positive_real(): # 正实数
  1567. API.__add_symbot_core(
  1568. is_natural_=["positive", True], is_complex_=["real", True], describe_="正实数符号"
  1569. )
  1570. @staticmethod
  1571. @exception_catch()
  1572. def add_positive_integer(): # 正整数
  1573. API.__add_symbot_core(is_natural_=["positive", True], is_integer_=1, describe_="正整数符号")
  1574. @staticmethod
  1575. @exception_catch()
  1576. def add_natural(): # 自然数
  1577. API.__add_symbot_core(
  1578. is_natural_=["negative", False], is_integer_=1, describe_="自然数(非负整数)符号"
  1579. )
  1580. @staticmethod
  1581. @exception_catch()
  1582. def add_no_constraints(): # 无约束
  1583. API.__add_symbot_core(no_constraint_=1, describe_="仅满足交换律的无约束符号")
  1584. @staticmethod
  1585. @exception_catch()
  1586. def __add_symbot_core(
  1587. is_generation_=0,
  1588. is_rational_=0,
  1589. is_prime_=0,
  1590. is_even_=0,
  1591. is_finite_=0,
  1592. is_complex_=None,
  1593. is_natural_=None,
  1594. is_integer_=0,
  1595. no_constraint_=0,
  1596. describe_="自定义符号",
  1597. ):
  1598. # 代数,有理,质数,偶数,有限实数,复数,正负,整数,取消
  1599. name_list = API.get_var_name_list_gui()
  1600. for name in name_list:
  1601. try:
  1602. if not algebra_controller.add_symbol(
  1603. name,
  1604. is_generation_,
  1605. is_rational_,
  1606. is_prime_,
  1607. is_even_,
  1608. is_finite_,
  1609. is_complex_,
  1610. is_natural_,
  1611. is_integer_,
  1612. no_constraint_,
  1613. describe_,
  1614. ):
  1615. raise Exception
  1616. except BaseException:
  1617. API.output_prompt_gui(f"新增“{name}”失败")
  1618. raise
  1619. API.output_prompt_gui(f"新增“{describe_}”完成")
  1620. API.update_symbol_algebraic_box_gui()
  1621. def algebraic_factory_main(in_queue, out_queue):
  1622. global SCREEN
  1623. API.output_prompt_gui("加载完成")
  1624. queue_controller.set_queue(in_queue, out_queue)
  1625. queue_controller()
  1626. SCREEN.mainloop()
  1627. queue_controller.stop_process()
  1628. algebra_controller = AlgebraPolynomial(API.output_prompt_gui)
  1629. tkinter.Label(
  1630. SCREEN,
  1631. text="符号名字:",
  1632. bg=bg_color,
  1633. fg=word_color,
  1634. font=FONT,
  1635. width=gui_width,
  1636. height=gui_height,
  1637. ).grid(
  1638. column=column, row=row
  1639. ) # 设置说明
  1640. variable_name = tkinter.Entry(SCREEN, width=gui_width * 2)
  1641. variable_name.grid(
  1642. column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W
  1643. )
  1644. row += 1
  1645. tkinter.Button(
  1646. SCREEN,
  1647. bg=buttom_color,
  1648. fg=word_color,
  1649. text="实数符号(R)",
  1650. command=API.add_real,
  1651. font=FONT,
  1652. width=gui_width,
  1653. height=gui_height,
  1654. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  1655. tkinter.Button(
  1656. SCREEN,
  1657. bg=buttom_color,
  1658. fg=word_color,
  1659. text="整数符号(Z)",
  1660. command=API.add_integer,
  1661. font=FONT,
  1662. width=gui_width,
  1663. height=gui_height,
  1664. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  1665. tkinter.Button(
  1666. SCREEN,
  1667. bg=buttom_color,
  1668. fg=word_color,
  1669. text="非负实数符号",
  1670. command=API.add_non_negative_real,
  1671. font=FONT,
  1672. width=gui_width,
  1673. height=gui_height,
  1674. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  1675. row += 1
  1676. tkinter.Button(
  1677. SCREEN,
  1678. bg=buttom_color,
  1679. fg=word_color,
  1680. text="偶数符号",
  1681. command=API.add_even,
  1682. font=FONT,
  1683. width=gui_width,
  1684. height=gui_height,
  1685. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  1686. tkinter.Button(
  1687. SCREEN,
  1688. bg=buttom_color,
  1689. fg=word_color,
  1690. text="奇数符号",
  1691. command=API.add_odd,
  1692. font=FONT,
  1693. width=gui_width,
  1694. height=gui_height,
  1695. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  1696. tkinter.Button(
  1697. SCREEN,
  1698. bg=buttom_color,
  1699. fg=word_color,
  1700. text="正数符号",
  1701. command=API.add_positive_real,
  1702. font=FONT,
  1703. width=gui_width,
  1704. height=gui_height,
  1705. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  1706. row += 1
  1707. tkinter.Button(
  1708. SCREEN,
  1709. bg=buttom_color,
  1710. fg=word_color,
  1711. text="自然数符号",
  1712. command=API.add_natural,
  1713. font=FONT,
  1714. width=gui_width,
  1715. height=gui_height,
  1716. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  1717. tkinter.Button(
  1718. SCREEN,
  1719. bg=buttom_color,
  1720. fg=word_color,
  1721. text="正整数符号",
  1722. command=API.add_positive_integer,
  1723. font=FONT,
  1724. width=gui_width,
  1725. height=gui_height,
  1726. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  1727. tkinter.Button(
  1728. SCREEN,
  1729. bg=buttom_color,
  1730. fg=word_color,
  1731. text="无约束符号",
  1732. command=API.add_no_constraints,
  1733. font=FONT,
  1734. width=gui_width,
  1735. height=gui_height,
  1736. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  1737. row += 1
  1738. is_generation = tkinter.IntVar() # 代数或者超越数
  1739. lable = ["均可", "代数", "超越数"]
  1740. for i in range(3):
  1741. tkinter.Radiobutton(
  1742. SCREEN,
  1743. bg=bg_color,
  1744. fg=word_color,
  1745. activebackground=bg_color,
  1746. activeforeground=word_color,
  1747. selectcolor=bg_color,
  1748. text=lable[i],
  1749. variable=is_generation,
  1750. value=i,
  1751. ).grid(column=column + i, row=row, sticky=tkinter.W)
  1752. row += 1
  1753. is_rational = tkinter.IntVar() # 有理数或者无理数
  1754. lable = ["均可", "有理数", "无理数"]
  1755. for i in range(3):
  1756. tkinter.Radiobutton(
  1757. SCREEN,
  1758. bg=bg_color,
  1759. fg=word_color,
  1760. activebackground=bg_color,
  1761. activeforeground=word_color,
  1762. selectcolor=bg_color,
  1763. text=lable[i],
  1764. variable=is_rational,
  1765. value=i,
  1766. ).grid(column=column + i, row=row, sticky=tkinter.W)
  1767. row += 1
  1768. is_prime = tkinter.IntVar() # 质数合数
  1769. lable = ["均可", "质数", "合数"]
  1770. for i in range(3):
  1771. tkinter.Radiobutton(
  1772. SCREEN,
  1773. bg=bg_color,
  1774. fg=word_color,
  1775. activebackground=bg_color,
  1776. activeforeground=word_color,
  1777. selectcolor=bg_color,
  1778. text=lable[i],
  1779. variable=is_prime,
  1780. value=i,
  1781. ).grid(column=column + i, row=row, sticky=tkinter.W)
  1782. row += 1
  1783. is_even = tkinter.IntVar() # 奇数偶数
  1784. lable = ["均可", "偶数", "奇数"]
  1785. for i in range(3):
  1786. tkinter.Radiobutton(
  1787. SCREEN,
  1788. bg=bg_color,
  1789. fg=word_color,
  1790. activebackground=bg_color,
  1791. activeforeground=word_color,
  1792. selectcolor=bg_color,
  1793. text=lable[i],
  1794. variable=is_even,
  1795. value=i,
  1796. ).grid(column=column + i, row=row, sticky=tkinter.W)
  1797. row += 1
  1798. is_complex = [] # 实数虚数
  1799. lable = ["复数", "实数", "虚数"]
  1800. for i in range(3):
  1801. is_complex.append(tkinter.IntVar())
  1802. tkinter.Checkbutton(
  1803. SCREEN,
  1804. bg=bg_color,
  1805. fg=word_color,
  1806. activebackground=bg_color,
  1807. activeforeground=word_color,
  1808. selectcolor=bg_color,
  1809. text=lable[i],
  1810. variable=is_complex[-1],
  1811. ).grid(column=column + i, row=row, sticky=tkinter.W)
  1812. row += 1
  1813. is_positives = [] # 正,负,0
  1814. lable = ["正数", "负数", "零"] # 复选框
  1815. for i in range(3):
  1816. is_positives.append(tkinter.IntVar())
  1817. tkinter.Checkbutton(
  1818. SCREEN,
  1819. bg=bg_color,
  1820. fg=word_color,
  1821. activebackground=bg_color,
  1822. activeforeground=word_color,
  1823. selectcolor=bg_color,
  1824. text=lable[i],
  1825. variable=is_positives[-1],
  1826. ).grid(column=column + i, row=row, sticky=tkinter.W)
  1827. row += 1
  1828. is_limited = tkinter.IntVar() # 实数
  1829. lable = ["均可", "有限实数", "无穷数", "广义实数"]
  1830. for i in range(3):
  1831. tkinter.Radiobutton(
  1832. SCREEN,
  1833. bg=bg_color,
  1834. fg=word_color,
  1835. activebackground=bg_color,
  1836. activeforeground=word_color,
  1837. selectcolor=bg_color,
  1838. text=lable[i],
  1839. variable=is_limited,
  1840. value=i,
  1841. ).grid(column=column + i, row=row, sticky=tkinter.W)
  1842. row += 1
  1843. tkinter.Radiobutton(
  1844. SCREEN,
  1845. bg=bg_color,
  1846. fg=word_color,
  1847. activebackground=bg_color,
  1848. activeforeground=word_color,
  1849. selectcolor=bg_color,
  1850. text=lable[3],
  1851. variable=is_limited,
  1852. value=3,
  1853. ).grid(
  1854. column=column, row=row, sticky=tkinter.W
  1855. ) # 同上的
  1856. integer = tkinter.IntVar()
  1857. tkinter.Checkbutton(
  1858. SCREEN,
  1859. bg=bg_color,
  1860. fg=word_color,
  1861. activebackground=bg_color,
  1862. activeforeground=word_color,
  1863. selectcolor=bg_color,
  1864. text="整数",
  1865. variable=integer,
  1866. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  1867. row += 1
  1868. variable_box = tkinter.Listbox(
  1869. SCREEN, width=gui_width * 3, height=gui_height * 4
  1870. ) # 显示符号
  1871. variable_box.grid(
  1872. column=column,
  1873. row=row,
  1874. columnspan=3,
  1875. rowspan=6,
  1876. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  1877. )
  1878. row += 6
  1879. tkinter.Button(
  1880. SCREEN,
  1881. bg=buttom_color,
  1882. fg=word_color,
  1883. text="自定义符号",
  1884. command=API.add_custom_symbol,
  1885. font=FONT,
  1886. width=gui_width,
  1887. height=gui_height,
  1888. ).grid(
  1889. column=column, row=row, sticky=tkinter.E + tkinter.W
  1890. ) # 添加函数
  1891. tkinter.Button(
  1892. SCREEN,
  1893. bg=buttom_color,
  1894. fg=word_color,
  1895. text="查看假设",
  1896. command=API.get_predictions,
  1897. font=FONT,
  1898. width=gui_width,
  1899. height=gui_height,
  1900. ).grid(
  1901. column=column + 1, row=row, sticky=tkinter.E + tkinter.W
  1902. ) # 添加函数
  1903. tkinter.Button(
  1904. SCREEN,
  1905. bg=buttom_color,
  1906. fg=word_color,
  1907. text="删除符号",
  1908. command=API.del_symbol,
  1909. font=FONT,
  1910. width=gui_width,
  1911. height=gui_height,
  1912. ).grid(
  1913. column=column + 2, row=row, sticky=tkinter.E + tkinter.W
  1914. ) # 添加函数
  1915. row += 1
  1916. predictions_box = tkinter.Listbox(
  1917. SCREEN, width=gui_width * 3, height=gui_height * 5
  1918. ) # 显示函数假设
  1919. predictions_box.grid(
  1920. column=column,
  1921. row=row,
  1922. columnspan=3,
  1923. rowspan=5,
  1924. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  1925. )
  1926. column += 3
  1927. tkinter.Label(SCREEN, text="", bg=bg_color, fg=word_color, font=FONT, width=1).grid(
  1928. column=column, row=0
  1929. )
  1930. column += 1
  1931. row = 0
  1932. tkinter.Label(
  1933. SCREEN,
  1934. text="代数式:",
  1935. bg=bg_color,
  1936. fg=word_color,
  1937. font=FONT,
  1938. width=gui_width,
  1939. height=gui_height,
  1940. ).grid(
  1941. column=column, row=row
  1942. ) # 设置说明
  1943. algebra_expression = tkinter.Entry(SCREEN, width=gui_width * 2)
  1944. algebra_expression.grid(
  1945. column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W
  1946. )
  1947. row += 1
  1948. tkinter.Label(
  1949. SCREEN,
  1950. text="标识:",
  1951. bg=bg_color,
  1952. fg=word_color,
  1953. font=FONT,
  1954. width=gui_width,
  1955. height=gui_height,
  1956. ).grid(
  1957. column=column, row=row
  1958. ) # 设置说明
  1959. algebra_name = tkinter.Entry(SCREEN, width=gui_width * 2)
  1960. algebra_name.grid(
  1961. column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W
  1962. )
  1963. row += 1
  1964. tkinter.Label(
  1965. SCREEN,
  1966. text="标准:",
  1967. bg=bg_color,
  1968. fg=word_color,
  1969. font=FONT,
  1970. width=gui_width,
  1971. height=gui_height,
  1972. ).grid(
  1973. column=column, row=row
  1974. ) # 设置说明
  1975. ratdio = tkinter.Entry(SCREEN, width=gui_width * 2)
  1976. ratdio.grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  1977. row += 1
  1978. init_rationalization = tkinter.IntVar()
  1979. tkinter.Checkbutton(
  1980. SCREEN,
  1981. bg=bg_color,
  1982. fg=word_color,
  1983. activebackground=bg_color,
  1984. activeforeground=word_color,
  1985. selectcolor=bg_color,
  1986. text="有理化",
  1987. variable=init_rationalization,
  1988. ).grid(column=column, row=row, sticky=tkinter.W)
  1989. init_ignore_assumptions = tkinter.IntVar()
  1990. tkinter.Checkbutton(
  1991. SCREEN,
  1992. bg=bg_color,
  1993. fg=word_color,
  1994. activebackground=bg_color,
  1995. activeforeground=word_color,
  1996. selectcolor=bg_color,
  1997. text="忽略假设",
  1998. variable=init_ignore_assumptions,
  1999. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  2000. standardization = tkinter.IntVar()
  2001. tkinter.Checkbutton(
  2002. SCREEN,
  2003. bg=bg_color,
  2004. fg=word_color,
  2005. activebackground=bg_color,
  2006. activeforeground=word_color,
  2007. selectcolor=bg_color,
  2008. text="标准化",
  2009. variable=standardization,
  2010. ).grid(column=column + 1, row=row, sticky=tkinter.W)
  2011. row += 1
  2012. tkinter.Button(
  2013. SCREEN,
  2014. bg=buttom_color,
  2015. fg=word_color,
  2016. text="清空代数式",
  2017. command=API.clear_algebra,
  2018. font=FONT,
  2019. width=gui_width,
  2020. height=gui_height,
  2021. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2022. tkinter.Button(
  2023. SCREEN,
  2024. bg=buttom_color,
  2025. fg=word_color,
  2026. text="生成代数式",
  2027. command=API.add_algebraic,
  2028. font=FONT,
  2029. width=gui_width,
  2030. height=gui_height,
  2031. ).grid(
  2032. column=column + 1, row=row, sticky=tkinter.E + tkinter.W
  2033. ) # 添加函数
  2034. tkinter.Button(
  2035. SCREEN,
  2036. bg=buttom_color,
  2037. fg=word_color,
  2038. text="删除代数式",
  2039. command=API.del_algebra,
  2040. font=FONT,
  2041. width=gui_width,
  2042. height=gui_height,
  2043. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2044. row += 1
  2045. algebra_box = tkinter.Listbox(SCREEN, width=gui_width * 3) # 显示代数式
  2046. algebra_box.grid(
  2047. column=column,
  2048. row=row,
  2049. columnspan=3,
  2050. rowspan=4,
  2051. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  2052. )
  2053. row += 4
  2054. tkinter.Label(
  2055. SCREEN,
  2056. text="重写对象:",
  2057. bg=bg_color,
  2058. fg=word_color,
  2059. font=FONT,
  2060. width=gui_width,
  2061. height=gui_height,
  2062. ).grid(
  2063. column=column, row=row
  2064. ) # 设置说明
  2065. rewrite_object = tkinter.Entry(SCREEN, width=gui_width * 2)
  2066. rewrite_object.grid(
  2067. column=column + 1, columnspan=2, row=row, sticky=tkinter.W + tkinter.E
  2068. )
  2069. row += 1
  2070. tkinter.Label(
  2071. SCREEN,
  2072. text="重写方法:",
  2073. bg=bg_color,
  2074. fg=word_color,
  2075. font=FONT,
  2076. width=gui_width,
  2077. height=gui_height,
  2078. ).grid(
  2079. column=column, row=row
  2080. ) # 设置说明
  2081. rewrite_func = tkinter.Entry(SCREEN, width=gui_width * 2)
  2082. rewrite_func.grid(
  2083. column=column + 1, columnspan=2, row=row, sticky=tkinter.W + tkinter.E
  2084. )
  2085. row += 1
  2086. rewrite_deep = tkinter.IntVar()
  2087. tkinter.Checkbutton(
  2088. SCREEN,
  2089. bg=bg_color,
  2090. fg=word_color,
  2091. activebackground=bg_color,
  2092. activeforeground=word_color,
  2093. selectcolor=bg_color,
  2094. text="重写子代数式",
  2095. variable=rewrite_deep,
  2096. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  2097. tkinter.Button(
  2098. SCREEN,
  2099. bg=buttom_color,
  2100. fg=word_color,
  2101. text="重写代数式",
  2102. command=API.rewrite_algebra,
  2103. font=FONT,
  2104. width=gui_width,
  2105. height=gui_height,
  2106. ).grid(column=column, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  2107. row += 1
  2108. tkinter.Label(
  2109. SCREEN,
  2110. text="同类项:",
  2111. bg=bg_color,
  2112. fg=word_color,
  2113. font=FONT,
  2114. width=gui_width,
  2115. height=gui_height,
  2116. ).grid(
  2117. column=column, row=row
  2118. ) # 设置说明
  2119. similar_items = tkinter.Entry(SCREEN, width=gui_width * 2)
  2120. similar_items.grid(
  2121. column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W
  2122. )
  2123. row += 1
  2124. return_type = tkinter.IntVar() # 正,负,0
  2125. lable = ["仅系数(同类项)", "仅代数式", "均保留"] # 复选框
  2126. for i in range(3):
  2127. tkinter.Radiobutton(
  2128. SCREEN,
  2129. bg=bg_color,
  2130. fg=word_color,
  2131. activebackground=bg_color,
  2132. activeforeground=word_color,
  2133. selectcolor=bg_color,
  2134. text=lable[i],
  2135. variable=return_type,
  2136. value=i,
  2137. ).grid(column=column + i, row=row, sticky=tkinter.W)
  2138. row += 1
  2139. tkinter.Label(
  2140. SCREEN,
  2141. text="拆分函数:",
  2142. bg=bg_color,
  2143. fg=word_color,
  2144. font=FONT,
  2145. width=gui_width,
  2146. height=gui_height,
  2147. ).grid(
  2148. column=column, row=row
  2149. ) # 设置说明
  2150. split_func = tkinter.Entry(SCREEN, width=gui_width)
  2151. split_func.grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2152. deep_split = tkinter.IntVar()
  2153. tkinter.Checkbutton(
  2154. SCREEN,
  2155. bg=bg_color,
  2156. fg=word_color,
  2157. activebackground=bg_color,
  2158. activeforeground=word_color,
  2159. selectcolor=bg_color,
  2160. text="完全拆分",
  2161. variable=deep_split,
  2162. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  2163. row += 1
  2164. tkinter.Button(
  2165. SCREEN,
  2166. bg=buttom_color,
  2167. fg=word_color,
  2168. text="同类项拆分",
  2169. command=API.algebraic_similarity_split,
  2170. font=FONT,
  2171. width=gui_width,
  2172. height=gui_height,
  2173. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2174. tkinter.Button(
  2175. SCREEN,
  2176. bg=buttom_color,
  2177. fg=word_color,
  2178. text="乘法拆分",
  2179. command=API.algebraic_factorization,
  2180. font=FONT,
  2181. width=gui_width,
  2182. height=gui_height,
  2183. ).grid(
  2184. column=column + 1, row=row, sticky=tkinter.E + tkinter.W
  2185. ) # 添加函数
  2186. tkinter.Button(
  2187. SCREEN,
  2188. bg=buttom_color,
  2189. fg=word_color,
  2190. text="函数拆分",
  2191. command=API.algebraic_partition,
  2192. font=FONT,
  2193. width=gui_width,
  2194. height=gui_height,
  2195. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2196. row += 1
  2197. on_hold_algebra = tkinter.Listbox(
  2198. SCREEN, width=gui_width * 3, height=gui_height * 4
  2199. ) # 显示代数式
  2200. on_hold_algebra.grid(
  2201. column=column,
  2202. row=row,
  2203. columnspan=3,
  2204. rowspan=4,
  2205. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  2206. )
  2207. row += 4
  2208. tkinter.Button(
  2209. SCREEN,
  2210. bg=buttom_color,
  2211. fg=word_color,
  2212. text="添加",
  2213. command=API.add_operation_algebra,
  2214. font=FONT,
  2215. width=gui_width,
  2216. height=gui_height,
  2217. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2218. tkinter.Button(
  2219. SCREEN,
  2220. bg=buttom_color,
  2221. fg=word_color,
  2222. text="清空",
  2223. command=API.clear_operational_algebra,
  2224. font=FONT,
  2225. width=gui_width,
  2226. height=gui_height,
  2227. ).grid(
  2228. column=column + 1, row=row, sticky=tkinter.E + tkinter.W
  2229. ) # 添加函数
  2230. tkinter.Button(
  2231. SCREEN,
  2232. bg=buttom_color,
  2233. fg=word_color,
  2234. text="删除",
  2235. command=API.del_operation_algebra,
  2236. font=FONT,
  2237. width=gui_width,
  2238. height=gui_height,
  2239. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2240. row += 1
  2241. tkinter.Label(
  2242. SCREEN,
  2243. text="合成函数:",
  2244. bg=bg_color,
  2245. fg=word_color,
  2246. font=FONT,
  2247. width=gui_width,
  2248. height=gui_height,
  2249. ).grid(
  2250. column=column, row=row
  2251. ) # 设置说明
  2252. merge_func = tkinter.Entry(SCREEN, width=gui_width * 2)
  2253. merge_func.grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  2254. row += 1
  2255. tkinter.Button(
  2256. SCREEN,
  2257. bg=buttom_color,
  2258. fg=word_color,
  2259. text="多项式合成",
  2260. command=API.algebraic_addition,
  2261. font=FONT,
  2262. width=gui_width,
  2263. height=gui_height,
  2264. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2265. tkinter.Button(
  2266. SCREEN,
  2267. bg=buttom_color,
  2268. fg=word_color,
  2269. text="因式合成",
  2270. command=API.algebraic_multiplication,
  2271. font=FONT,
  2272. width=gui_width,
  2273. height=gui_height,
  2274. ).grid(
  2275. column=column + 1, row=row, sticky=tkinter.E + tkinter.W
  2276. ) # 添加函数
  2277. tkinter.Button(
  2278. SCREEN,
  2279. bg=buttom_color,
  2280. fg=word_color,
  2281. text="函数合成",
  2282. command=API.algebraic_composition,
  2283. font=FONT,
  2284. width=gui_width,
  2285. height=gui_height,
  2286. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2287. row += 1
  2288. tkinter.Label(
  2289. SCREEN,
  2290. text="有效数字:",
  2291. bg=bg_color,
  2292. fg=word_color,
  2293. font=FONT,
  2294. width=gui_width,
  2295. height=gui_height,
  2296. ).grid(
  2297. column=column + 1, row=row
  2298. ) # 设置说明
  2299. valid_number = tkinter.Entry(SCREEN, width=gui_width)
  2300. valid_number.grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2301. tkinter.Button(
  2302. SCREEN,
  2303. bg=buttom_color,
  2304. fg=word_color,
  2305. text="代数式数字化",
  2306. command=API.algebraic_digitization,
  2307. font=FONT,
  2308. width=gui_width,
  2309. height=gui_height,
  2310. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2311. column += 3
  2312. tkinter.Label(SCREEN, text="", bg=bg_color, fg=word_color, font=FONT, width=1).grid(
  2313. column=column, row=0
  2314. )
  2315. column += 1
  2316. row = 0
  2317. tkinter.Label(
  2318. SCREEN,
  2319. text="【分式恒等变形】",
  2320. bg=bg_color,
  2321. fg=word_color,
  2322. font=FONT,
  2323. width=gui_width * 3,
  2324. height=gui_height,
  2325. ).grid(
  2326. column=column, row=row, columnspan=3
  2327. ) # 设置说明
  2328. row += 1
  2329. fully_divided = tkinter.IntVar()
  2330. tkinter.Label(
  2331. SCREEN,
  2332. text="裂项关注对象:",
  2333. bg=bg_color,
  2334. fg=word_color,
  2335. font=FONT,
  2336. width=gui_width,
  2337. height=gui_height,
  2338. ).grid(
  2339. column=column, row=row
  2340. ) # 设置说明
  2341. apart = tkinter.Entry(SCREEN, width=gui_width)
  2342. apart.grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2343. tkinter.Checkbutton(
  2344. SCREEN,
  2345. bg=bg_color,
  2346. fg=word_color,
  2347. activebackground=bg_color,
  2348. activeforeground=word_color,
  2349. selectcolor=bg_color,
  2350. text="完全转化分式",
  2351. variable=fully_divided,
  2352. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  2353. row += 1
  2354. rationalized_unknown = tkinter.IntVar()
  2355. tkinter.Label(
  2356. SCREEN,
  2357. text="最大无理项:",
  2358. bg=bg_color,
  2359. fg=word_color,
  2360. font=FONT,
  2361. width=gui_width,
  2362. height=gui_height,
  2363. ).grid(
  2364. column=column, row=row
  2365. ) # 设置说明
  2366. maximum_irrational_term = tkinter.Entry(SCREEN, width=gui_width)
  2367. maximum_irrational_term.grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2368. tkinter.Checkbutton(
  2369. SCREEN,
  2370. bg=bg_color,
  2371. fg=word_color,
  2372. activebackground=bg_color,
  2373. activeforeground=word_color,
  2374. selectcolor=bg_color,
  2375. text="有理化符号分母",
  2376. variable=rationalized_unknown,
  2377. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  2378. row += 1
  2379. tkinter.Button(
  2380. SCREEN,
  2381. bg=buttom_color,
  2382. fg=word_color,
  2383. text="最小公分母",
  2384. command=API.fractional_division,
  2385. font=FONT,
  2386. width=gui_width,
  2387. height=gui_height,
  2388. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2389. tkinter.Button(
  2390. SCREEN,
  2391. bg=buttom_color,
  2392. fg=word_color,
  2393. text="分式约分",
  2394. command=API.fraction_reduction,
  2395. font=FONT,
  2396. width=gui_width,
  2397. height=gui_height,
  2398. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2399. tkinter.Button(
  2400. SCREEN,
  2401. bg=buttom_color,
  2402. fg=word_color,
  2403. text="分式裂项",
  2404. command=API.fractional_fission,
  2405. font=FONT,
  2406. width=gui_width,
  2407. height=gui_height,
  2408. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2409. row += 1
  2410. tkinter.Button(
  2411. SCREEN,
  2412. bg=buttom_color,
  2413. fg=word_color,
  2414. text="分母有理化",
  2415. command=API.denominator_rationalization,
  2416. font=FONT,
  2417. width=gui_width,
  2418. height=gui_height,
  2419. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2420. tkinter.Button(
  2421. SCREEN,
  2422. bg=buttom_color,
  2423. fg=word_color,
  2424. text="转化为分式(小改动)",
  2425. command=API.fractional_synthesis,
  2426. font=FONT,
  2427. width=gui_width,
  2428. height=gui_height,
  2429. ).grid(column=column + 1, columnspan=2, row=row, sticky=tkinter.E + tkinter.W)
  2430. row += 1
  2431. tkinter.Label(
  2432. SCREEN,
  2433. text="【三角恒等变换】",
  2434. bg=bg_color,
  2435. fg=word_color,
  2436. font=FONT,
  2437. width=gui_width * 3,
  2438. height=gui_height,
  2439. ).grid(
  2440. column=column, row=row, columnspan=3
  2441. ) # 设置说明
  2442. row += 1
  2443. trig_fully_expand = tkinter.IntVar()
  2444. tkinter.Button(
  2445. SCREEN,
  2446. bg=buttom_color,
  2447. fg=word_color,
  2448. text="展开三角函数",
  2449. command=API.expand_trigonometric,
  2450. font=FONT,
  2451. width=gui_width,
  2452. height=gui_height,
  2453. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2454. tkinter.Button(
  2455. SCREEN,
  2456. bg=buttom_color,
  2457. fg=word_color,
  2458. text="三角函数合成",
  2459. command=API.reduced_trigonometric,
  2460. font=FONT,
  2461. width=gui_width,
  2462. height=gui_height,
  2463. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2464. tkinter.Checkbutton(
  2465. SCREEN,
  2466. bg=bg_color,
  2467. fg=word_color,
  2468. activebackground=bg_color,
  2469. activeforeground=word_color,
  2470. selectcolor=bg_color,
  2471. text="完全展开",
  2472. variable=trig_fully_expand,
  2473. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  2474. row += 1
  2475. tkinter.Label(
  2476. SCREEN,
  2477. text="【乘法、指数、对数恒等变形】",
  2478. bg=bg_color,
  2479. fg=word_color,
  2480. font=FONT,
  2481. width=gui_width * 3,
  2482. height=gui_height,
  2483. ).grid(
  2484. column=column, row=row, columnspan=3
  2485. ) # 设置说明
  2486. row += 1
  2487. ignore_assumptions = tkinter.IntVar()
  2488. fully_expand = tkinter.IntVar()
  2489. tkinter.Checkbutton(
  2490. SCREEN,
  2491. bg=bg_color,
  2492. fg=word_color,
  2493. activebackground=bg_color,
  2494. activeforeground=word_color,
  2495. selectcolor=bg_color,
  2496. text="忽略假设",
  2497. variable=ignore_assumptions,
  2498. ).grid(column=column + 1, row=row, sticky=tkinter.W)
  2499. tkinter.Checkbutton(
  2500. SCREEN,
  2501. bg=bg_color,
  2502. fg=word_color,
  2503. activebackground=bg_color,
  2504. activeforeground=word_color,
  2505. selectcolor=bg_color,
  2506. text="完全展开",
  2507. variable=fully_expand,
  2508. ).grid(column=column, row=row, sticky=tkinter.W)
  2509. row += 1
  2510. tkinter.Button(
  2511. SCREEN,
  2512. bg=buttom_color,
  2513. fg=word_color,
  2514. text="展开乘法",
  2515. command=API.expand_mul,
  2516. font=FONT,
  2517. width=gui_width,
  2518. height=gui_height,
  2519. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2520. tkinter.Button(
  2521. SCREEN,
  2522. bg=buttom_color,
  2523. fg=word_color,
  2524. text="展开加法式幂",
  2525. command=API.expand_additive_index,
  2526. font=FONT,
  2527. width=gui_width,
  2528. height=gui_height,
  2529. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2530. tkinter.Button(
  2531. SCREEN,
  2532. bg=buttom_color,
  2533. fg=word_color,
  2534. text="指数合成",
  2535. command=API.composite_index,
  2536. font=FONT,
  2537. width=gui_width,
  2538. height=gui_height,
  2539. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2540. row += 1
  2541. tkinter.Button(
  2542. SCREEN,
  2543. bg=buttom_color,
  2544. fg=word_color,
  2545. text="化简指数底数",
  2546. command=API.reduce_exp_base,
  2547. font=FONT,
  2548. width=gui_width,
  2549. height=gui_height,
  2550. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2551. tkinter.Button(
  2552. SCREEN,
  2553. bg=buttom_color,
  2554. fg=word_color,
  2555. text="化简指数幂",
  2556. command=API.reduce_exp_index,
  2557. font=FONT,
  2558. width=gui_width,
  2559. height=gui_height,
  2560. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2561. tkinter.Button(
  2562. SCREEN,
  2563. bg=buttom_color,
  2564. fg=word_color,
  2565. text="化简指数",
  2566. command=API.reduced_power,
  2567. font=FONT,
  2568. width=gui_width,
  2569. height=gui_height,
  2570. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2571. row += 1
  2572. tkinter.Button(
  2573. SCREEN,
  2574. bg=buttom_color,
  2575. fg=word_color,
  2576. text="展开指数底数",
  2577. command=API.expand_exp_base,
  2578. font=FONT,
  2579. width=gui_width,
  2580. height=gui_height,
  2581. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2582. tkinter.Button(
  2583. SCREEN,
  2584. bg=buttom_color,
  2585. fg=word_color,
  2586. text="展开指数幂",
  2587. command=API.expand_exp_index,
  2588. font=FONT,
  2589. width=gui_width,
  2590. height=gui_height,
  2591. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2592. tkinter.Button(
  2593. SCREEN,
  2594. bg=buttom_color,
  2595. fg=word_color,
  2596. text="展开指数",
  2597. command=API.expand_power,
  2598. font=FONT,
  2599. width=gui_width,
  2600. height=gui_height,
  2601. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2602. ignore_assumptions_log = tkinter.IntVar()
  2603. log_fully_expand = tkinter.IntVar()
  2604. row += 1
  2605. tkinter.Checkbutton(
  2606. SCREEN,
  2607. bg=bg_color,
  2608. fg=word_color,
  2609. activebackground=bg_color,
  2610. activeforeground=word_color,
  2611. selectcolor=bg_color,
  2612. text="完全展开",
  2613. variable=log_fully_expand,
  2614. ).grid(column=column, row=row, sticky=tkinter.W)
  2615. tkinter.Checkbutton(
  2616. SCREEN,
  2617. bg=bg_color,
  2618. fg=word_color,
  2619. activebackground=bg_color,
  2620. activeforeground=word_color,
  2621. selectcolor=bg_color,
  2622. text="忽略假设",
  2623. variable=ignore_assumptions_log,
  2624. ).grid(column=column + 1, row=row, sticky=tkinter.W)
  2625. row += 1
  2626. tkinter.Button(
  2627. SCREEN,
  2628. bg=buttom_color,
  2629. fg=word_color,
  2630. text="展开对数",
  2631. command=API.expand_log,
  2632. font=FONT,
  2633. width=gui_width,
  2634. height=gui_height,
  2635. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2636. tkinter.Button(
  2637. SCREEN,
  2638. bg=buttom_color,
  2639. fg=word_color,
  2640. text="化简对数",
  2641. command=API.reduce_log,
  2642. font=FONT,
  2643. width=gui_width,
  2644. height=gui_height,
  2645. ).grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  2646. row += 1
  2647. tkinter.Label(
  2648. SCREEN,
  2649. text="【虚数与特殊函数】",
  2650. bg=bg_color,
  2651. fg=word_color,
  2652. font=FONT,
  2653. width=gui_width * 3,
  2654. height=gui_height,
  2655. ).grid(
  2656. column=column, row=row, columnspan=3
  2657. ) # 设置说明
  2658. row += 1
  2659. tkinter.Button(
  2660. SCREEN,
  2661. bg=buttom_color,
  2662. fg=word_color,
  2663. text="展开特殊函数",
  2664. command=API.expand_special,
  2665. font=FONT,
  2666. width=gui_width,
  2667. height=gui_height,
  2668. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2669. tkinter.Button(
  2670. SCREEN,
  2671. bg=buttom_color,
  2672. fg=word_color,
  2673. text="展开虚数",
  2674. command=API.expand_complex,
  2675. font=FONT,
  2676. width=gui_width,
  2677. height=gui_height,
  2678. ).grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  2679. row += 1
  2680. tkinter.Label(
  2681. SCREEN,
  2682. text="【普遍操作类】",
  2683. bg=bg_color,
  2684. fg=word_color,
  2685. font=FONT,
  2686. width=gui_width * 3,
  2687. height=gui_height,
  2688. ).grid(
  2689. column=column, row=row, columnspan=3
  2690. ) # 设置说明
  2691. row += 1
  2692. tkinter.Label(
  2693. SCREEN,
  2694. text="简化方案:",
  2695. bg=bg_color,
  2696. fg=word_color,
  2697. font=FONT,
  2698. width=gui_width,
  2699. height=gui_height,
  2700. ).grid(
  2701. column=column, row=row
  2702. ) # 设置说明
  2703. simplify_func_Input = tkinter.Entry(SCREEN, width=gui_width) # 简化方案
  2704. simplify_func_Input.grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2705. tkinter.Checkbutton(
  2706. SCREEN,
  2707. bg=bg_color,
  2708. fg=word_color,
  2709. activebackground=bg_color,
  2710. activeforeground=word_color,
  2711. selectcolor=bg_color,
  2712. text="有理化",
  2713. variable=init_rationalization,
  2714. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  2715. row += 1
  2716. tkinter.Label(
  2717. SCREEN,
  2718. text="简化比率:",
  2719. bg=bg_color,
  2720. fg=word_color,
  2721. font=FONT,
  2722. width=gui_width,
  2723. height=gui_height,
  2724. ).grid(
  2725. column=column, row=row
  2726. ) # 设置说明
  2727. simplify_ratio_input = tkinter.Entry(SCREEN, width=gui_width) # 简化比率
  2728. simplify_ratio_input.grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2729. tkinter.Checkbutton(
  2730. SCREEN,
  2731. bg=bg_color,
  2732. fg=word_color,
  2733. activebackground=bg_color,
  2734. activeforeground=word_color,
  2735. selectcolor=bg_color,
  2736. text="忽略假设",
  2737. variable=init_ignore_assumptions,
  2738. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  2739. is_gaussian = tkinter.IntVar()
  2740. fully_factor = tkinter.IntVar()
  2741. factor_rat = tkinter.IntVar()
  2742. row += 1
  2743. tkinter.Label(
  2744. SCREEN,
  2745. text="模数:",
  2746. bg=bg_color,
  2747. fg=word_color,
  2748. font=FONT,
  2749. width=gui_width,
  2750. height=gui_height,
  2751. ).grid(
  2752. column=column, row=row
  2753. ) # 设置说明
  2754. modulus = tkinter.Entry(SCREEN, width=gui_width) # 简化比率
  2755. modulus.grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2756. tkinter.Checkbutton(
  2757. SCREEN,
  2758. bg=bg_color,
  2759. fg=word_color,
  2760. activebackground=bg_color,
  2761. activeforeground=word_color,
  2762. selectcolor=bg_color,
  2763. text="高斯因式分解",
  2764. variable=is_gaussian,
  2765. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  2766. row += 1
  2767. tkinter.Checkbutton(
  2768. SCREEN,
  2769. bg=bg_color,
  2770. fg=word_color,
  2771. activebackground=bg_color,
  2772. activeforeground=word_color,
  2773. selectcolor=bg_color,
  2774. text="完全因式分解",
  2775. variable=fully_factor,
  2776. ).grid(column=column, row=row, sticky=tkinter.W)
  2777. tkinter.Checkbutton(
  2778. SCREEN,
  2779. bg=bg_color,
  2780. fg=word_color,
  2781. activebackground=bg_color,
  2782. activeforeground=word_color,
  2783. selectcolor=bg_color,
  2784. text="因式分解有理代数式",
  2785. variable=factor_rat,
  2786. ).grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.W)
  2787. row += 1
  2788. is_expand_complex = tkinter.IntVar()
  2789. tkinter.Label(
  2790. SCREEN,
  2791. text="同类项对象:",
  2792. bg=bg_color,
  2793. fg=word_color,
  2794. font=FONT,
  2795. width=gui_width,
  2796. height=gui_height,
  2797. ).grid(
  2798. column=column, row=row
  2799. ) # 设置说明
  2800. similar_items_object = tkinter.Entry(SCREEN, width=gui_width)
  2801. similar_items_object.grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2802. tkinter.Checkbutton(
  2803. SCREEN,
  2804. bg=bg_color,
  2805. fg=word_color,
  2806. activebackground=bg_color,
  2807. activeforeground=word_color,
  2808. selectcolor=bg_color,
  2809. text="展开复数",
  2810. variable=is_expand_complex,
  2811. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  2812. row += 1
  2813. tkinter.Button(
  2814. SCREEN,
  2815. bg=buttom_color,
  2816. fg=word_color,
  2817. text="化简标准化",
  2818. command=API.simplify_standardization,
  2819. font=FONT,
  2820. width=gui_width,
  2821. height=gui_height,
  2822. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2823. tkinter.Button(
  2824. SCREEN,
  2825. bg=buttom_color,
  2826. fg=word_color,
  2827. text="普遍运算展开",
  2828. command=API.general_expansion,
  2829. font=FONT,
  2830. width=gui_width,
  2831. height=gui_height,
  2832. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2833. tkinter.Button(
  2834. SCREEN,
  2835. bg=buttom_color,
  2836. fg=word_color,
  2837. text="因式分解",
  2838. command=API.factorization,
  2839. font=FONT,
  2840. width=gui_width,
  2841. height=gui_height,
  2842. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2843. row += 1
  2844. tkinter.Button(
  2845. SCREEN,
  2846. bg=buttom_color,
  2847. fg=word_color,
  2848. text="合并同类项",
  2849. command=API.merger_of_similar_items,
  2850. font=FONT,
  2851. width=gui_width,
  2852. height=gui_height,
  2853. ).grid(column=column, row=row, columnspan=3, sticky=tkinter.E + tkinter.W)
  2854. column += 3
  2855. tkinter.Label(SCREEN, text="", bg=bg_color, fg=word_color, font=FONT, width=1).grid(
  2856. column=column, row=0
  2857. )
  2858. column += 1
  2859. row = 0
  2860. tkinter.Label(
  2861. SCREEN,
  2862. text="【联立操作】",
  2863. bg=bg_color,
  2864. fg=word_color,
  2865. font=FONT,
  2866. width=gui_width * 3,
  2867. height=gui_height,
  2868. ).grid(
  2869. column=column, row=row, columnspan=3
  2870. ) # 设置说明
  2871. row += 1
  2872. tkinter.Button(
  2873. SCREEN,
  2874. bg=buttom_color,
  2875. fg=word_color,
  2876. text="选定符号",
  2877. command=API.add_left_simultaneous_values,
  2878. font=FONT,
  2879. width=gui_width,
  2880. height=gui_height,
  2881. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2882. tkinter.Button(
  2883. SCREEN,
  2884. bg=buttom_color,
  2885. fg=word_color,
  2886. text="选定代数式",
  2887. command=API.add_right_simultaneous_algebra,
  2888. font=FONT,
  2889. width=gui_width,
  2890. height=gui_height,
  2891. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2892. tkinter.Button(
  2893. SCREEN,
  2894. bg=buttom_color,
  2895. fg=word_color,
  2896. text="新键联立",
  2897. command=API.add_value_algebraic_simultaneous,
  2898. font=FONT,
  2899. width=gui_width,
  2900. height=gui_height,
  2901. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2902. row += 1
  2903. tkinter.Button(
  2904. SCREEN,
  2905. bg=buttom_color,
  2906. fg=word_color,
  2907. text="生成联立代数式",
  2908. command=API.value_algebraic_simultaneous,
  2909. font=FONT,
  2910. width=gui_width,
  2911. height=gui_height,
  2912. ).grid(column=column, columnspan=2, row=row, sticky=tkinter.E + tkinter.W)
  2913. tkinter.Button(
  2914. SCREEN,
  2915. bg=buttom_color,
  2916. fg=word_color,
  2917. text="删除联立",
  2918. command=API.del_value_algebraic_simultaneous,
  2919. font=FONT,
  2920. width=gui_width,
  2921. height=gui_height,
  2922. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2923. row += 1
  2924. value_algebra_box = tkinter.Listbox(
  2925. SCREEN, width=gui_width * 3, height=gui_height * 4
  2926. ) # 显示代数式
  2927. value_algebra_box.grid(
  2928. column=column,
  2929. row=row,
  2930. columnspan=3,
  2931. rowspan=4,
  2932. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  2933. )
  2934. row += 4
  2935. tkinter.Label(
  2936. SCREEN,
  2937. text="【反向联立操作】",
  2938. bg=bg_color,
  2939. fg=word_color,
  2940. font=FONT,
  2941. width=gui_width * 3,
  2942. height=gui_height,
  2943. ).grid(
  2944. column=column, row=row, columnspan=3
  2945. ) # 设置说明
  2946. # 反向联立系统
  2947. row += 1
  2948. tkinter.Button(
  2949. SCREEN,
  2950. bg=buttom_color,
  2951. fg=word_color,
  2952. text="选定代数式",
  2953. command=API.add_left_simultaneous_algebra,
  2954. font=FONT,
  2955. width=gui_width,
  2956. height=gui_height,
  2957. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2958. tkinter.Button(
  2959. SCREEN,
  2960. bg=buttom_color,
  2961. fg=word_color,
  2962. text="选定符号",
  2963. command=API.add_right_simultaneous_values,
  2964. font=FONT,
  2965. width=gui_width,
  2966. height=gui_height,
  2967. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2968. tkinter.Button(
  2969. SCREEN,
  2970. bg=buttom_color,
  2971. fg=word_color,
  2972. text="新键联立",
  2973. command=API.add_algebraic_values_simultaneously,
  2974. font=FONT,
  2975. width=gui_width,
  2976. height=gui_height,
  2977. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2978. row += 1
  2979. tkinter.Button(
  2980. SCREEN,
  2981. bg=buttom_color,
  2982. fg=word_color,
  2983. text="生成联立代数式",
  2984. command=API.algebragic_value_simultaneous,
  2985. font=FONT,
  2986. width=gui_width,
  2987. height=gui_height,
  2988. ).grid(column=column, columnspan=2, row=row, sticky=tkinter.E + tkinter.W)
  2989. tkinter.Button(
  2990. SCREEN,
  2991. bg=buttom_color,
  2992. fg=word_color,
  2993. text="删除联立",
  2994. command=API.del_algebraic_value_simultaneousness,
  2995. font=FONT,
  2996. width=gui_width,
  2997. height=gui_height,
  2998. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2999. row += 1
  3000. algebra_value_box = tkinter.Listbox(
  3001. SCREEN, width=gui_width * 3, height=gui_height * 4
  3002. ) # 显示代数式
  3003. algebra_value_box.grid(
  3004. column=column,
  3005. row=row,
  3006. columnspan=3,
  3007. rowspan=4,
  3008. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  3009. )
  3010. # 代数运算
  3011. row += 4
  3012. tkinter.Label(
  3013. SCREEN,
  3014. text="【赋值运算操作】",
  3015. bg=bg_color,
  3016. fg=word_color,
  3017. font=FONT,
  3018. width=gui_width * 3,
  3019. height=gui_height,
  3020. ).grid(
  3021. column=column, row=row, columnspan=3
  3022. ) # 设置说明
  3023. row += 1
  3024. tkinter.Label(
  3025. SCREEN,
  3026. text="数值:",
  3027. bg=bg_color,
  3028. fg=word_color,
  3029. font=FONT,
  3030. width=gui_width,
  3031. height=gui_height,
  3032. ).grid(
  3033. column=column, row=row
  3034. ) # 设置说明
  3035. number = tkinter.Entry(SCREEN, width=gui_width + 2)
  3036. number.grid(column=column + 1, row=row, sticky=tkinter.W)
  3037. tkinter.Button(
  3038. SCREEN,
  3039. bg=buttom_color,
  3040. fg=word_color,
  3041. text="指定符号",
  3042. command=API.add_variable_assignment,
  3043. font=FONT,
  3044. width=gui_width,
  3045. height=gui_height,
  3046. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  3047. row += 1
  3048. number_type = tkinter.IntVar() # 正,负,0
  3049. lable = ["浮点数", "整数", "分数有理数", "无约束数字"] # 复选框
  3050. for i in range(3):
  3051. tkinter.Radiobutton(
  3052. SCREEN,
  3053. bg=bg_color,
  3054. fg=word_color,
  3055. activebackground=bg_color,
  3056. activeforeground=word_color,
  3057. selectcolor=bg_color,
  3058. text=lable[i],
  3059. variable=number_type,
  3060. value=i,
  3061. ).grid(column=column + i, row=row, sticky=tkinter.W)
  3062. row += 1
  3063. tkinter.Radiobutton(
  3064. SCREEN,
  3065. bg=bg_color,
  3066. fg=word_color,
  3067. activebackground=bg_color,
  3068. activeforeground=word_color,
  3069. selectcolor=bg_color,
  3070. text=lable[3],
  3071. variable=number_type,
  3072. value=3,
  3073. ).grid(column=column + 1, row=row, sticky=tkinter.W)
  3074. row += 1
  3075. tkinter.Button(
  3076. SCREEN,
  3077. bg=buttom_color,
  3078. fg=word_color,
  3079. text="生成赋值代数式",
  3080. command=API.algebraic_assignment,
  3081. font=FONT,
  3082. width=gui_width,
  3083. height=gui_height,
  3084. ).grid(column=column, columnspan=2, row=row, sticky=tkinter.E + tkinter.W)
  3085. tkinter.Button(
  3086. SCREEN,
  3087. bg=buttom_color,
  3088. fg=word_color,
  3089. text="删除赋值",
  3090. command=API.del_variable_assignment,
  3091. font=FONT,
  3092. width=gui_width,
  3093. height=gui_height,
  3094. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  3095. row += 1
  3096. variable_assignment_box = tkinter.Listbox(
  3097. SCREEN, width=gui_width * 3, height=gui_height * 4
  3098. ) # 显示代数式
  3099. variable_assignment_box.grid(
  3100. column=column,
  3101. row=row,
  3102. columnspan=3,
  3103. rowspan=5,
  3104. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  3105. )
  3106. column += 3
  3107. tkinter.Label(SCREEN, text="", bg=bg_color, fg=word_color, font=FONT, width=1).grid(
  3108. column=column, row=0
  3109. )
  3110. column += 1
  3111. row = 0
  3112. tkinter.Label(
  3113. SCREEN,
  3114. text="【方程联立】",
  3115. bg=bg_color,
  3116. fg=word_color,
  3117. font=FONT,
  3118. width=gui_width * 3,
  3119. height=gui_height,
  3120. ).grid(
  3121. column=column, row=row, columnspan=3
  3122. ) # 设置说明
  3123. row += 1
  3124. tkinter.Button(
  3125. SCREEN,
  3126. bg=buttom_color,
  3127. fg=word_color,
  3128. text="左代数式",
  3129. command=API.add_equation_left,
  3130. font=FONT,
  3131. width=gui_width,
  3132. height=gui_height,
  3133. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  3134. tkinter.Button(
  3135. SCREEN,
  3136. bg=buttom_color,
  3137. fg=word_color,
  3138. text="右代数式",
  3139. command=API.add_equation_right,
  3140. font=FONT,
  3141. width=gui_width,
  3142. height=gui_height,
  3143. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  3144. tkinter.Button(
  3145. SCREEN,
  3146. bg=buttom_color,
  3147. fg=word_color,
  3148. text="新建方程",
  3149. command=API.generating_equation,
  3150. font=FONT,
  3151. width=gui_width,
  3152. height=gui_height,
  3153. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  3154. row += 1
  3155. tkinter.Button(
  3156. SCREEN,
  3157. bg=buttom_color,
  3158. fg=word_color,
  3159. text="解联立方程",
  3160. command=API.solve_simultaneous_equations,
  3161. font=FONT,
  3162. width=gui_width,
  3163. height=gui_height,
  3164. ).grid(column=column, columnspan=2, row=row, sticky=tkinter.E + tkinter.W)
  3165. tkinter.Button(
  3166. SCREEN,
  3167. bg=buttom_color,
  3168. fg=word_color,
  3169. text="删除方程",
  3170. command=API.del_equation,
  3171. font=FONT,
  3172. width=gui_width,
  3173. height=gui_height,
  3174. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  3175. row += 1
  3176. equation_box = tkinter.Listbox(
  3177. SCREEN, width=gui_width * 3, height=gui_height * 2
  3178. ) # 显示代数式
  3179. equation_box.grid(
  3180. column=column,
  3181. row=row,
  3182. columnspan=3,
  3183. rowspan=2,
  3184. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  3185. )
  3186. row += 2
  3187. tkinter.Button(
  3188. SCREEN,
  3189. bg=buttom_color,
  3190. fg=word_color,
  3191. text="应用为代数式",
  3192. command=API.add_to_algebraic_box,
  3193. font=FONT,
  3194. width=gui_width,
  3195. height=gui_height,
  3196. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  3197. tkinter.Button(
  3198. SCREEN,
  3199. bg=buttom_color,
  3200. fg=word_color,
  3201. text="添加联立",
  3202. command=API.add_to_value_algebraic_box,
  3203. font=FONT,
  3204. width=gui_width,
  3205. height=gui_height,
  3206. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  3207. tkinter.Button(
  3208. SCREEN,
  3209. bg=buttom_color,
  3210. fg=word_color,
  3211. text="添加反联立",
  3212. command=API.add_to_algebraic_value_box,
  3213. font=FONT,
  3214. width=gui_width,
  3215. height=gui_height,
  3216. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  3217. row += 1
  3218. equation_solution_box = tkinter.Listbox(
  3219. SCREEN, width=gui_width * 3, height=gui_height * 2
  3220. ) # 显示代数式
  3221. equation_solution_box.grid(
  3222. column=column,
  3223. row=row,
  3224. columnspan=3,
  3225. rowspan=2,
  3226. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  3227. )
  3228. row += 2
  3229. tkinter.Label(
  3230. SCREEN,
  3231. text="【解不等式】",
  3232. bg=bg_color,
  3233. fg=word_color,
  3234. font=FONT,
  3235. width=gui_width * 3,
  3236. height=gui_height,
  3237. ).grid(
  3238. column=column, row=row, columnspan=3
  3239. ) # 设置说明
  3240. row += 1
  3241. tkinter.Button(
  3242. SCREEN,
  3243. bg=buttom_color,
  3244. fg=word_color,
  3245. text="左代数式",
  3246. command=API.add_left_algebra,
  3247. font=FONT,
  3248. width=gui_width,
  3249. height=gui_height,
  3250. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  3251. tkinter.Button(
  3252. SCREEN,
  3253. bg=buttom_color,
  3254. fg=word_color,
  3255. text="右代数式",
  3256. command=API.add_right_algebra,
  3257. font=FONT,
  3258. width=gui_width,
  3259. height=gui_height,
  3260. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  3261. tkinter.Button(
  3262. SCREEN,
  3263. bg=buttom_color,
  3264. fg=word_color,
  3265. text="不等式运算",
  3266. command=API.inequality_solve,
  3267. font=FONT,
  3268. width=gui_width,
  3269. height=gui_height,
  3270. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  3271. row += 1
  3272. inequality_box = tkinter.Listbox(
  3273. SCREEN, width=gui_width * 3, height=gui_height
  3274. ) # 显示代数式
  3275. inequality_box.grid(
  3276. column=column,
  3277. row=row,
  3278. columnspan=3,
  3279. rowspan=1,
  3280. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  3281. )
  3282. row += 1
  3283. inequality_symbol = tkinter.IntVar() # 实数
  3284. lable = ["大于>", "小于<", "大于等于>=", "小于等于<="]
  3285. for i in range(2):
  3286. tkinter.Radiobutton(
  3287. SCREEN,
  3288. command=API.update_inequality_box_gui,
  3289. bg=bg_color,
  3290. fg=word_color,
  3291. activebackground=bg_color,
  3292. activeforeground=word_color,
  3293. selectcolor=bg_color,
  3294. text=lable[i],
  3295. variable=inequality_symbol,
  3296. value=i,
  3297. ).grid(column=column + i, row=row, sticky=tkinter.W)
  3298. row += 1
  3299. for i in range(2):
  3300. i += 2
  3301. tkinter.Radiobutton(
  3302. SCREEN,
  3303. command=API.update_inequality_box_gui,
  3304. bg=bg_color,
  3305. fg=word_color,
  3306. activebackground=bg_color,
  3307. activeforeground=word_color,
  3308. selectcolor=bg_color,
  3309. text=lable[i],
  3310. variable=inequality_symbol,
  3311. value=i,
  3312. ).grid(column=column + i - 2, row=row, sticky=tkinter.W)
  3313. row += 1
  3314. inequality_solution_box = tkinter.Listbox(
  3315. SCREEN, width=gui_width * 3, height=gui_height
  3316. ) # 显示代数式
  3317. inequality_solution_box.grid(
  3318. column=column,
  3319. row=row,
  3320. columnspan=3,
  3321. rowspan=2,
  3322. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  3323. )
  3324. row += 2
  3325. tkinter.Label(
  3326. SCREEN,
  3327. text="【代数式画图】",
  3328. bg=bg_color,
  3329. fg=word_color,
  3330. font=FONT,
  3331. width=gui_width * 3,
  3332. height=gui_height,
  3333. ).grid(
  3334. column=column, row=row, columnspan=3
  3335. ) # 设置说明
  3336. row += 1
  3337. tkinter.Label(
  3338. SCREEN,
  3339. text="符号取值范围:",
  3340. bg=bg_color,
  3341. fg=word_color,
  3342. font=FONT,
  3343. width=gui_width,
  3344. height=gui_height,
  3345. ).grid(
  3346. column=column, row=row
  3347. ) # 设置说明
  3348. range_of_values = tkinter.Entry(SCREEN, width=gui_width + 2)
  3349. range_of_values.grid(column=column + 1, row=row, sticky=tkinter.W)
  3350. tkinter.Button(
  3351. SCREEN,
  3352. bg=buttom_color,
  3353. fg=word_color,
  3354. text="指定符号",
  3355. command=API.add_plot_value,
  3356. font=FONT,
  3357. width=gui_width,
  3358. height=gui_height,
  3359. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  3360. row += 1
  3361. plot_object_box = tkinter.Listbox(
  3362. SCREEN, width=gui_width * 3, height=gui_height
  3363. ) # 显示代数式
  3364. plot_object_box.grid(
  3365. column=column,
  3366. row=row,
  3367. columnspan=3,
  3368. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  3369. )
  3370. row += 1
  3371. plot_type = tkinter.IntVar() # 实数
  3372. lable = ["二维图像", "三维图像"]
  3373. for i in range(2):
  3374. tkinter.Radiobutton(
  3375. SCREEN,
  3376. command=API.update_plot_value_gui,
  3377. bg=bg_color,
  3378. fg=word_color,
  3379. activebackground=bg_color,
  3380. activeforeground=word_color,
  3381. selectcolor=bg_color,
  3382. text=lable[i],
  3383. variable=plot_type,
  3384. value=i,
  3385. ).grid(column=column + i, row=row, sticky=tkinter.W)
  3386. tkinter.Button(
  3387. SCREEN,
  3388. bg=buttom_color,
  3389. fg=word_color,
  3390. text="绘制图像",
  3391. command=API.drawing_image,
  3392. font=FONT,
  3393. width=gui_width,
  3394. height=gui_height,
  3395. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  3396. row += 1
  3397. tkinter.Button(
  3398. SCREEN,
  3399. bg=buttom_color,
  3400. fg=word_color,
  3401. text="绘制代数式",
  3402. command=API.draw_algebra_core,
  3403. font=FONT,
  3404. width=gui_width,
  3405. height=gui_height,
  3406. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  3407. tkinter.Button(
  3408. SCREEN,
  3409. bg=buttom_color,
  3410. fg=word_color,
  3411. text="绘制树状图",
  3412. command=API.show_algebraic,
  3413. font=FONT,
  3414. width=gui_width,
  3415. height=gui_height,
  3416. ).grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  3417. row += 1
  3418. bracket = tkinter.IntVar()
  3419. log_bracket = tkinter.IntVar()
  3420. can_input = tkinter.Entry(SCREEN, width=gui_width)
  3421. can_input.grid(column=column, row=row, sticky=tkinter.W + tkinter.E)
  3422. tkinter.Checkbutton(
  3423. SCREEN,
  3424. bg=bg_color,
  3425. fg=word_color,
  3426. activebackground=bg_color,
  3427. activeforeground=word_color,
  3428. selectcolor=bg_color,
  3429. text="每项绘制括号",
  3430. variable=bracket,
  3431. ).grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.W)
  3432. tkinter.Checkbutton(
  3433. SCREEN,
  3434. bg=bg_color,
  3435. fg=word_color,
  3436. activebackground=bg_color,
  3437. activeforeground=word_color,
  3438. selectcolor=bg_color,
  3439. text="对数绘制括号",
  3440. variable=log_bracket,
  3441. ).grid(column=column + 2, row=row, columnspan=2, sticky=tkinter.W)
  3442. row += 1
  3443. prompt_box = tkinter.Listbox(SCREEN, width=gui_width * 3, height=gui_height) # 显示代数式
  3444. prompt_box.grid(
  3445. column=column,
  3446. row=row,
  3447. columnspan=3,
  3448. rowspan=3,
  3449. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  3450. )