gui.py 104 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682
  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]]
  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()[1]
  909. API.apply_algebraic_tips(get, f"联立结果为:{get},是否应用?")
  910. @staticmethod
  911. @exception_catch()
  912. def add_to_value_algebraic_box():
  913. get = API.equation_solution_set_gui()
  914. value_algebra_dict[get[0]] = get[1]
  915. API.update_value_algebraic_box_gui()
  916. @staticmethod
  917. @exception_catch()
  918. def add_to_algebraic_value_box():
  919. get = API.equation_solution_set_gui()
  920. algebra_value_dict[get[1]] = get[0]
  921. API.update_algebraic_value_box_gui()
  922. @staticmethod
  923. @exception_catch()
  924. def solve_simultaneous_equations():
  925. global equation_solution_set
  926. try:
  927. get = algebra_controller.solving_equations(equation_set)
  928. API.output_prompt_gui("运行成功")
  929. except BaseException:
  930. API.output_prompt_gui("解方程失败")
  931. raise
  932. equation_solution_set = []
  933. re = []
  934. for i in get:
  935. re.append(f"{i[0]} = {i[1]}") # i[0]是一个字母=i[1]是一个代数式
  936. equation_solution_set.append((i[0], i[1]))
  937. API.update_equation_solution_box_gui(re)
  938. @staticmethod
  939. @exception_catch()
  940. def del_equation():
  941. global left_equation, right_equation
  942. num = API.get_equation_box_index_gui()
  943. if left_equation is not None or right_equation is not None:
  944. if num == 0:
  945. left_equation = None
  946. right_equation = None
  947. else:
  948. num -= 1
  949. del equation_set[num]
  950. else:
  951. del equation_set[num]
  952. API.update_simultaneous_equations_box_gui()
  953. @staticmethod
  954. @exception_catch()
  955. def generating_equation():
  956. global left_equation, right_equation
  957. if left_equation is not None and right_equation is not None:
  958. equation_set.append((left_equation, right_equation))
  959. left_equation = None
  960. right_equation = None
  961. API.update_simultaneous_equations_box_gui()
  962. @staticmethod
  963. @exception_catch()
  964. def add_equation_left():
  965. global left_equation
  966. left_equation = API.get_algebraic_name_gui()
  967. API.update_simultaneous_equations_box_gui()
  968. @staticmethod
  969. @exception_catch()
  970. def add_equation_right():
  971. global right_equation
  972. right_equation = API.get_algebraic_name_gui()
  973. API.update_simultaneous_equations_box_gui()
  974. @staticmethod
  975. @exception_catch()
  976. def algebraic_assignment():
  977. name = API.get_algebraic_name_gui()
  978. try:
  979. get = algebra_controller.algebraic_assignment(name, value_sub_dict)
  980. API.output_prompt_gui("运算成功")
  981. except BaseException:
  982. API.output_prompt_gui("代数运算失败")
  983. raise
  984. API.apply_algebraic_tips(get, f"联立结果为:{get},是否应用?")
  985. @staticmethod
  986. @exception_catch()
  987. def del_variable_assignment():
  988. num = API.get_variable_assignment_box_index_gui()
  989. del value_sub_dict[list(value_sub_dict.keys())[num]]
  990. API.update_variable_assignment_box_gui()
  991. @staticmethod
  992. @exception_catch()
  993. def add_variable_assignment():
  994. try:
  995. value_name = API.get_variable_assignment_box_index_gui()
  996. except BaseException:
  997. API.output_prompt_gui("请选定符号")
  998. raise
  999. value_num = algebra_controller.creat_num(*API.add_variable_assignment_gui()) # 不同类型
  1000. value_sub_dict[value_name] = value_num
  1001. API.update_variable_assignment_box_gui()
  1002. @staticmethod
  1003. @exception_catch()
  1004. def algebragic_value_simultaneous():
  1005. name = API.get_algebraic_name_gui()
  1006. try:
  1007. get = algebra_controller.algebragic_value_simultaneous(name, algebra_value_dict)
  1008. API.output_prompt_gui("反向联立完成")
  1009. except BaseException:
  1010. API.output_prompt_gui("无法联立")
  1011. raise
  1012. API.apply_algebraic_tips(get, f"联立结果为:{get},是否应用?")
  1013. @staticmethod
  1014. @exception_catch()
  1015. def del_algebraic_value_simultaneousness():
  1016. global left_algebra, right_value
  1017. num = API.get_algebra_value_box_index_gui()
  1018. if right_value is not None or left_algebra is not None:
  1019. if num == 0:
  1020. right_value = None
  1021. left_algebra = None
  1022. else:
  1023. num -= 1
  1024. del algebra_value_dict[list(algebra_value_dict.keys())[num]]
  1025. else:
  1026. del algebra_value_dict[list(algebra_value_dict.keys())[num]]
  1027. API.update_algebraic_value_box_gui()
  1028. @staticmethod
  1029. @exception_catch()
  1030. def add_algebraic_values_simultaneously():
  1031. global left_algebra, right_value
  1032. if right_value is not None and left_algebra is not None:
  1033. algebra_value_dict[left_algebra] = right_value
  1034. right_value, left_algebra = None, None
  1035. API.update_algebraic_value_box_gui()
  1036. @staticmethod
  1037. @exception_catch()
  1038. def add_left_simultaneous_algebra(): # 代数式=值的左代数式
  1039. global left_algebra
  1040. alg_name = API.get_algebraic_name_gui()
  1041. left_algebra = alg_name
  1042. API.update_algebraic_value_box_gui()
  1043. @staticmethod
  1044. @exception_catch()
  1045. def add_right_simultaneous_values(): # 解释同上
  1046. global right_value
  1047. try:
  1048. value_name = API.get_var_name_gui()
  1049. except BaseException:
  1050. API.output_prompt_gui("请选定符号")
  1051. raise
  1052. right_value = value_name
  1053. API.update_algebraic_value_box_gui()
  1054. @staticmethod
  1055. @exception_catch()
  1056. def value_algebraic_simultaneous():
  1057. name = API.get_algebraic_name_gui()
  1058. try:
  1059. get = algebra_controller.value_algebraic_simultaneous(name, value_algebra_dict)
  1060. API.output_prompt_gui("联立完成")
  1061. except BaseException:
  1062. API.output_prompt_gui("无法联立")
  1063. raise
  1064. API.apply_algebraic_tips(get, f"联立结果为:{get},是否应用?")
  1065. @staticmethod
  1066. @exception_catch()
  1067. def del_value_algebraic_simultaneous():
  1068. global right_algebra, left_value
  1069. num = API.get_value_algebra_box_index_gui()
  1070. if left_value is not None or right_algebra is not None:
  1071. if num == 0:
  1072. left_value = None
  1073. right_algebra = None
  1074. else:
  1075. num -= 1
  1076. del value_algebra_dict[list(value_algebra_dict.keys())[num]]
  1077. else:
  1078. del value_algebra_dict[list(value_algebra_dict.keys())[num]]
  1079. API.update_value_algebraic_box_gui()
  1080. @staticmethod
  1081. @exception_catch()
  1082. def add_value_algebraic_simultaneous():
  1083. global right_algebra, left_value
  1084. if left_value is not None and right_algebra is not None:
  1085. value_algebra_dict[left_value] = right_algebra
  1086. left_value, right_algebra = None, None
  1087. API.update_value_algebraic_box_gui()
  1088. @staticmethod
  1089. @exception_catch()
  1090. def add_right_simultaneous_algebra():
  1091. global right_algebra
  1092. alg_name = API.get_algebraic_name_gui()
  1093. right_algebra = alg_name
  1094. API.update_value_algebraic_box_gui()
  1095. @staticmethod
  1096. @exception_catch()
  1097. def add_left_simultaneous_values():
  1098. global left_value
  1099. try:
  1100. value_name = API.get_var_name_gui()
  1101. except BaseException:
  1102. API.output_prompt_gui("请选定符号")
  1103. raise
  1104. left_value = value_name
  1105. API.update_value_algebraic_box_gui()
  1106. @staticmethod
  1107. @exception_catch()
  1108. def algebraic_digitization():
  1109. try:
  1110. get = (algebra_controller
  1111. .algebraic_digitization(API.get_algebraic_name_gui(), API.get_valid_number_gui()))
  1112. API.output_prompt_gui("数字化完成")
  1113. except BaseException:
  1114. API.output_prompt_gui("数字化失败")
  1115. raise
  1116. API.apply_algebraic_tips(get, f"数字化的结果为:{get},是否应用?")
  1117. @staticmethod
  1118. @exception_catch()
  1119. def expand_special():
  1120. name = API.get_algebraic_name_gui()
  1121. try:
  1122. get = algebra_controller.expand_special(name)
  1123. API.output_prompt_gui("运算成功")
  1124. except BaseException:
  1125. API.output_prompt_gui("运算失败")
  1126. raise
  1127. API.apply_algebraic_tips(get, f"展开特殊函数的结果为:{get},是否应用?")
  1128. @staticmethod
  1129. @exception_catch()
  1130. def expand_complex():
  1131. name = API.get_algebraic_name_gui()
  1132. try:
  1133. get = algebra_controller.expand_complex(name)
  1134. API.output_prompt_gui("运算成功")
  1135. except BaseException:
  1136. API.output_prompt_gui("运算失败")
  1137. raise
  1138. API.apply_algebraic_tips(get, f"展开虚数的结果为:{get},是否应用?")
  1139. @staticmethod
  1140. @exception_catch()
  1141. def merger_of_similar_items():
  1142. name = API.get_algebraic_name_gui()
  1143. try:
  1144. get = algebra_controller.merger_of_similar_items(name, API.get_similar_items_gui())
  1145. API.output_prompt_gui("运算成功")
  1146. except BaseException:
  1147. API.output_prompt_gui("运算失败")
  1148. raise
  1149. API.apply_algebraic_tips(get, f"合并同类项的结果为:{get},是否应用?")
  1150. @staticmethod
  1151. @exception_catch()
  1152. def general_expansion():
  1153. complex_ = API.get_is_expand_complex_gui()
  1154. name = API.get_algebraic_name_gui()
  1155. try:
  1156. get = algebra_controller.expansion(name, complex_)
  1157. API.output_prompt_gui("运算成功")
  1158. except BaseException:
  1159. API.output_prompt_gui("运算失败")
  1160. raise
  1161. API.apply_algebraic_tips(get, f"普遍展开的结果为:{get},是否应用?")
  1162. @staticmethod
  1163. @exception_catch()
  1164. def factorization():
  1165. name = API.get_algebraic_name_gui()
  1166. deep, gaussian, modulus_num, rat = API.get_factorization_gui()
  1167. try:
  1168. get = algebra_controller.factor(name, modulus_num, gaussian, deep, rat)
  1169. API.output_prompt_gui("运算成功")
  1170. except BaseException:
  1171. API.output_prompt_gui("运算失败")
  1172. raise
  1173. API.apply_algebraic_tips(get, f"因式分解的结果为:{get},是否应用?")
  1174. @staticmethod
  1175. @exception_catch()
  1176. def simplify_standardization():
  1177. inverse, name, radio, rat = API.get_standardization_gui()
  1178. try:
  1179. get = algebra_controller.simplify(name, radio, rat=rat, inv=inverse)
  1180. API.output_prompt_gui("运算成功")
  1181. except BaseException:
  1182. API.output_prompt_gui("运算失败")
  1183. raise
  1184. API.apply_algebraic_tips(get, f"化简(标准化)为:{get},是否应用?")
  1185. @staticmethod
  1186. @exception_catch()
  1187. def apply_algebraic_tips(re, message):
  1188. if API.askok_gui(message):
  1189. algebra_controller.add_expression("", re)
  1190. API.update_symbol_algebraic_box_gui()
  1191. @staticmethod
  1192. @exception_catch()
  1193. def expand_log():
  1194. deep, ignore_assumptions_ = API.get_expand_log_gui()
  1195. name = API.get_algebraic_name_gui()
  1196. try:
  1197. get = algebra_controller.log_expansion(name, ignore_assumptions_, deep)
  1198. API.output_prompt_gui("运算成功")
  1199. except BaseException:
  1200. API.output_prompt_gui("运算失败")
  1201. raise
  1202. API.apply_algebraic_tips(get, f"展开对数结果为:{get},是否应用?")
  1203. @staticmethod
  1204. @exception_catch()
  1205. def reduce_log():
  1206. ignore = API.get_reduce_log_gui()
  1207. name = API.get_algebraic_name_gui()
  1208. try:
  1209. get = algebra_controller.log_simp(name, ignore)
  1210. API.output_prompt_gui("运算成功")
  1211. except BaseException:
  1212. API.output_prompt_gui("运算失败")
  1213. raise
  1214. API.apply_algebraic_tips(get, f"化简对数结果为:{get},是否应用?")
  1215. @staticmethod
  1216. @exception_catch()
  1217. def expand_mul():
  1218. name = API.get_algebraic_name_gui()
  1219. try:
  1220. get = algebra_controller.mul_expansion(name)
  1221. API.output_prompt_gui("运算成功")
  1222. except BaseException:
  1223. API.output_prompt_gui("运算失败")
  1224. raise
  1225. API.apply_algebraic_tips(get, f"展开乘法结果为:{get},是否应用?")
  1226. @staticmethod
  1227. @exception_catch()
  1228. def expand_additive_index():
  1229. global algebra_controller, ignore_assumptions
  1230. name = API.get_algebraic_name_gui()
  1231. try:
  1232. get = algebra_controller.multinomial_expansion(name)
  1233. API.output_prompt_gui("运算成功")
  1234. except BaseException:
  1235. API.output_prompt_gui("运算失败")
  1236. raise
  1237. API.apply_algebraic_tips(get, f"展开加法式幂结果为:{get},是否应用?")
  1238. @staticmethod
  1239. @exception_catch()
  1240. def composite_index():
  1241. name = API.get_algebraic_name_gui()
  1242. try:
  1243. get = algebra_controller.pow_simp_multinomial(name)
  1244. API.output_prompt_gui("运算成功")
  1245. except BaseException:
  1246. API.output_prompt_gui("运算失败")
  1247. raise
  1248. API.apply_algebraic_tips(get, f"合成幂指数的结果为:{get},是否应用?(彻底化简加法式幂可以使用因式分解)")
  1249. @staticmethod
  1250. @exception_catch()
  1251. def expand_exp_base():
  1252. deep = API.get_fully_expand_gui()
  1253. name = API.get_algebraic_name_gui()
  1254. try:
  1255. get = algebra_controller.pow_expansion_base(name, deep)
  1256. API.output_prompt_gui("运算成功")
  1257. except BaseException:
  1258. API.output_prompt_gui("运算失败")
  1259. raise
  1260. API.apply_algebraic_tips(get, f"展开指数底数结果为:{get},是否应用?")
  1261. @staticmethod
  1262. @exception_catch()
  1263. def expand_exp_index():
  1264. deep = API.get_fully_expand_gui()
  1265. name = API.get_algebraic_name_gui()
  1266. try:
  1267. get = algebra_controller.pow_expansion_exp(name, deep)
  1268. except BaseException:
  1269. API.output_prompt_gui("运算失败")
  1270. raise
  1271. API.apply_algebraic_tips(get, f"展开指数幂结果为:{get},是否应用?")
  1272. @staticmethod
  1273. @exception_catch()
  1274. def expand_power():
  1275. deep = API.get_fully_expand_gui()
  1276. name = API.get_algebraic_name_gui()
  1277. try:
  1278. get = algebra_controller.pow_expansion_core(name, deep)
  1279. API.output_prompt_gui("运算成功")
  1280. except BaseException:
  1281. API.output_prompt_gui("运算失败")
  1282. raise
  1283. API.apply_algebraic_tips(get, f"展开指数结果为:{get},是否应用?")
  1284. @staticmethod
  1285. @exception_catch()
  1286. def reduce_exp_base():
  1287. ignore = API.get_ignore_assumptions_gui()
  1288. name = API.get_algebraic_name_gui()
  1289. try:
  1290. get = algebra_controller.pow_simp_base(name, ignore)
  1291. API.output_prompt_gui("运算成功")
  1292. except BaseException:
  1293. API.output_prompt_gui("运算失败")
  1294. raise
  1295. API.apply_algebraic_tips(get, f"化简指数底数结果为:{get},是否应用?")
  1296. @staticmethod
  1297. @exception_catch()
  1298. def reduce_exp_index():
  1299. ignore = API.get_ignore_assumptions_gui()
  1300. name = API.get_algebraic_name_gui()
  1301. try:
  1302. get = algebra_controller.pow_simp_exp(name, ignore)
  1303. API.output_prompt_gui("运算成功")
  1304. except BaseException:
  1305. API.output_prompt_gui("运算失败")
  1306. raise
  1307. API.apply_algebraic_tips(get, f"化简指数幂结果为:{get},是否应用?")
  1308. @staticmethod
  1309. @exception_catch()
  1310. def reduced_power():
  1311. ignore = API.get_ignore_assumptions_gui()
  1312. name = API.get_algebraic_name_gui()
  1313. try:
  1314. get = algebra_controller.pow_simp_core(name, ignore)
  1315. API.output_prompt_gui("运算成功")
  1316. except BaseException:
  1317. API.output_prompt_gui("运算失败")
  1318. raise
  1319. API.apply_algebraic_tips(get, f"化简指数结果为:{get},是否应用?")
  1320. @staticmethod
  1321. @exception_catch()
  1322. def reduced_trigonometric(): # 三角函数化简
  1323. name = API.get_algebraic_name_gui()
  1324. try:
  1325. get = algebra_controller.trig_simp(name)
  1326. API.output_prompt_gui("运算成功")
  1327. except BaseException:
  1328. API.output_prompt_gui("运算失败")
  1329. raise
  1330. API.apply_algebraic_tips(get, f"三角化简结果为:{get},是否应用?")
  1331. @staticmethod
  1332. @exception_catch()
  1333. def expand_trigonometric(): # 三角展开
  1334. deep = API.get_trig_fully_expand_gui()
  1335. name = API.get_algebraic_name_gui()
  1336. try:
  1337. get = algebra_controller.trig_expansion(name, deep)
  1338. API.output_prompt_gui("运算成功")
  1339. except BaseException:
  1340. API.output_prompt_gui("运算失败")
  1341. raise
  1342. API.apply_algebraic_tips(get, f"三角展开结果为:{get},是否应用?")
  1343. @staticmethod
  1344. @exception_catch()
  1345. def fractional_division(): # 通分
  1346. name = API.get_algebraic_name_gui()
  1347. try:
  1348. get = algebra_controller.fractional_merge(name)
  1349. API.output_prompt_gui("运算成功")
  1350. except BaseException:
  1351. API.output_prompt_gui("运算失败")
  1352. raise
  1353. API.apply_algebraic_tips(get, f"分式通分结果为:{get},是否应用?")
  1354. @staticmethod
  1355. @exception_catch()
  1356. def fraction_reduction(): # 约分
  1357. name = API.get_algebraic_name_gui()
  1358. try:
  1359. get = algebra_controller.fraction_reduction(name)
  1360. API.output_prompt_gui("运算成功")
  1361. except BaseException:
  1362. API.output_prompt_gui("运算失败")
  1363. raise
  1364. API.apply_algebraic_tips(get, f"分式约分结果为:{get},是否应用?")
  1365. @staticmethod
  1366. @exception_catch()
  1367. def fractional_fission(): # 裂项
  1368. name = API.get_algebraic_name_gui()
  1369. try:
  1370. get = algebra_controller.fractional_fission(name, API.get_apart_gui())
  1371. API.output_prompt_gui("运算成功")
  1372. except BaseException:
  1373. API.output_prompt_gui("运算失败")
  1374. raise
  1375. API.apply_algebraic_tips(get, f"分式裂项结果为:{get},是否应用?")
  1376. @staticmethod
  1377. @exception_catch()
  1378. def fractional_synthesis(): # together
  1379. deep = API.get_fully_divided_gui()
  1380. name = API.get_algebraic_name_gui()
  1381. try:
  1382. get = algebra_controller.as_fraction(name, deep)
  1383. API.output_prompt_gui("运算成功")
  1384. except BaseException:
  1385. API.output_prompt_gui("运算失败")
  1386. raise
  1387. API.apply_algebraic_tips(get, f"合成分式结果为:{get},是否应用?")
  1388. @staticmethod
  1389. @exception_catch()
  1390. def denominator_rationalization(): # 分母有理化
  1391. maximum, rationalized = API.denominator_rationalization_gui()
  1392. name = API.get_algebraic_name_gui()
  1393. try:
  1394. get = algebra_controller.fractional_rat(name, rationalized, maximum)
  1395. API.output_prompt_gui("运算成功")
  1396. except BaseException:
  1397. API.output_prompt_gui("运算失败")
  1398. raise
  1399. API.apply_algebraic_tips(get, f"分母有理化结果为:{get},是否应用?")
  1400. @staticmethod
  1401. @exception_catch()
  1402. def add_operation_algebra():
  1403. name = API.get_algebraic_name_gui()
  1404. if name is None:
  1405. raise
  1406. option_list.append(name)
  1407. API.update_operation_box_gui()
  1408. @staticmethod
  1409. @exception_catch()
  1410. def del_operation_algebra():
  1411. del option_list[API.get_on_hold_algebra_gui()]
  1412. API.update_operation_box_gui()
  1413. @staticmethod
  1414. @exception_catch()
  1415. def clear_operational_algebra():
  1416. API.update_symbol_algebraic_box_gui()
  1417. @staticmethod
  1418. @exception_catch()
  1419. def algebraic_composition():
  1420. global algebra_controller, option_list
  1421. name = option_list.copy()
  1422. if len(name) < 2:
  1423. raise Exception
  1424. try:
  1425. re = algebra_controller.merge_func(name, API.get_merge_func_gui())
  1426. API.output_prompt_gui("合成成功")
  1427. except BaseException:
  1428. API.output_prompt_gui("合成失败")
  1429. raise
  1430. API.apply_algebraic_tips(re, f"合成结果为:{re},是否应用?")
  1431. @staticmethod
  1432. @exception_catch()
  1433. def algebraic_multiplication():
  1434. name = option_list.copy()
  1435. if len(name) < 2:
  1436. raise Exception
  1437. try:
  1438. re = algebra_controller.merge_mul(name)
  1439. API.output_prompt_gui("合成成功")
  1440. except BaseException:
  1441. API.output_prompt_gui("合成失败")
  1442. raise
  1443. API.apply_algebraic_tips(re, f"合成结果为:{re},是否应用?")
  1444. @staticmethod
  1445. @exception_catch()
  1446. def algebraic_addition():
  1447. name = option_list.copy()
  1448. if len(name) < 2:
  1449. raise Exception
  1450. try:
  1451. re = algebra_controller.merge_add(name)
  1452. API.output_prompt_gui("合成成功")
  1453. except BaseException:
  1454. API.output_prompt_gui("合成失败")
  1455. raise
  1456. API.apply_algebraic_tips(re, f"合成结果为:{re},是否应用?")
  1457. @staticmethod
  1458. @exception_catch()
  1459. def algebraic_partition():
  1460. name = API.get_algebraic_name_gui()
  1461. deep, f, m, must = API.algebraic_partition_gui()
  1462. try:
  1463. re = algebra_controller.split_func(name, deep, f, must)
  1464. API.output_prompt_gui("拆分成功")
  1465. except BaseException:
  1466. API.output_prompt_gui("拆分失败")
  1467. raise
  1468. API.split_apply_algebraic_tips(re, f"{name}分解结果为:{re[1]},拆分之后:{re[0]},是否应用?")
  1469. @staticmethod
  1470. @exception_catch()
  1471. def split_apply_algebraic_tips(re, message):
  1472. if API.askok_gui(message):
  1473. for in_alg in re[0]:
  1474. algebra_controller.add_expression("", in_alg)
  1475. API.update_symbol_algebraic_box_gui()
  1476. @staticmethod
  1477. @exception_catch()
  1478. def algebraic_similarity_split():
  1479. f, name, value = API.algebraic_similarity_split_gui()
  1480. try:
  1481. re = algebra_controller.split_add(name, value, f)
  1482. API.output_prompt_gui("拆分成功")
  1483. except BaseException:
  1484. API.output_prompt_gui("拆分失败")
  1485. raise
  1486. API.split_apply_algebraic_tips(re, f"{name}分解结果为:{re[1]},拆分之后:{re[0]},是否应用?")
  1487. @staticmethod
  1488. @exception_catch()
  1489. def add_algebraic():
  1490. try:
  1491. (
  1492. alg_str,
  1493. inverse,
  1494. name,
  1495. rat,
  1496. the_ratdio,
  1497. the_standardization,
  1498. ) = API.add_algebraic_gui()
  1499. if the_standardization: # 标准化
  1500. new_alg = algebra_controller.simplify(
  1501. alg_str, ratdio=the_ratdio, rat=rat, inv=inverse
  1502. )
  1503. alg_str = API.application(alg_str, new_alg)
  1504. algebra_controller.add_expression(name, alg_str)
  1505. API.update_symbol_algebraic_box_gui()
  1506. API.output_prompt_gui("代数式新增成功")
  1507. except BaseException:
  1508. API.output_prompt_gui("新增代数式无法应用")
  1509. raise
  1510. @staticmethod
  1511. @exception_catch()
  1512. def application(alg_str, new_alg):
  1513. if new_alg is not None and API.askok_gui(f"约简函数为:{new_alg},是否应用?"):
  1514. alg_str = new_alg
  1515. return alg_str
  1516. @staticmethod
  1517. @exception_catch()
  1518. def get_predictions():
  1519. global variable_box, variable_list, algebra_controller, predictions_box
  1520. try:
  1521. try:
  1522. index = API.get_var_name_gui()
  1523. except BaseException:
  1524. API.output_prompt_gui("请选定符号")
  1525. raise
  1526. API.update_predictions_box_gui(index)
  1527. API.output_prompt_gui("性质预测成功")
  1528. except BaseException:
  1529. API.output_prompt_gui("性质预测失败")
  1530. raise
  1531. @staticmethod
  1532. @exception_catch()
  1533. def add_custom_symbol(): # 添加自定义Symbol
  1534. try:
  1535. API.__add_symbot_core(*API.add_custom_symbol_gui())
  1536. except BaseException:
  1537. API.output_prompt_gui("自定义符号新增失败")
  1538. raise
  1539. @staticmethod
  1540. @exception_catch()
  1541. def add_real(): # 添加实数符号
  1542. API.__add_symbot_core(is_complex_=["real", True], describe_="实数(且复数)符号")
  1543. @staticmethod
  1544. @exception_catch()
  1545. def add_integer(): # 添加整数符号
  1546. API.__add_symbot_core(is_integer_=1, describe_="整数(且实数)符号")
  1547. @staticmethod
  1548. @exception_catch()
  1549. def add_non_negative_real(): # 非负实数
  1550. API.__add_symbot_core(
  1551. is_natural_=["negative", False], is_complex_=["real", True], describe_="非负实数符号"
  1552. )
  1553. @staticmethod
  1554. @exception_catch()
  1555. def add_even(): # 偶数
  1556. API.__add_symbot_core(is_even_=1, describe_="偶数(且整数)符号")
  1557. @staticmethod
  1558. @exception_catch()
  1559. def add_odd(): # 奇数
  1560. API.__add_symbot_core(is_even_=2, describe_="奇数(且整数)符号")
  1561. @staticmethod
  1562. @exception_catch()
  1563. def add_positive_real(): # 正实数
  1564. API.__add_symbot_core(
  1565. is_natural_=["positive", True], is_complex_=["real", True], describe_="正实数符号"
  1566. )
  1567. @staticmethod
  1568. @exception_catch()
  1569. def add_positive_integer(): # 正整数
  1570. API.__add_symbot_core(is_natural_=["positive", True], is_integer_=1, describe_="正整数符号")
  1571. @staticmethod
  1572. @exception_catch()
  1573. def add_natural(): # 自然数
  1574. API.__add_symbot_core(
  1575. is_natural_=["negative", False], is_integer_=1, describe_="自然数(非负整数)符号"
  1576. )
  1577. @staticmethod
  1578. @exception_catch()
  1579. def add_no_constraints(): # 无约束
  1580. API.__add_symbot_core(no_constraint_=1, describe_="仅满足交换律的无约束符号")
  1581. @staticmethod
  1582. @exception_catch()
  1583. def __add_symbot_core(
  1584. is_generation_=0,
  1585. is_rational_=0,
  1586. is_prime_=0,
  1587. is_even_=0,
  1588. is_finite_=0,
  1589. is_complex_=None,
  1590. is_natural_=None,
  1591. is_integer_=0,
  1592. no_constraint_=0,
  1593. describe_="自定义符号",
  1594. ):
  1595. # 代数,有理,质数,偶数,有限实数,复数,正负,整数,取消
  1596. name_list = API.get_var_name_list_gui()
  1597. for name in name_list:
  1598. try:
  1599. if not algebra_controller.add_symbol(
  1600. name,
  1601. is_generation_,
  1602. is_rational_,
  1603. is_prime_,
  1604. is_even_,
  1605. is_finite_,
  1606. is_complex_,
  1607. is_natural_,
  1608. is_integer_,
  1609. no_constraint_,
  1610. describe_,
  1611. ):
  1612. raise Exception
  1613. except BaseException:
  1614. API.output_prompt_gui(f"新增“{name}”失败")
  1615. raise
  1616. API.output_prompt_gui(f"新增“{describe_}”完成")
  1617. API.update_symbol_algebraic_box_gui()
  1618. def algebraic_factory_main(in_queue, out_queue):
  1619. global SCREEN
  1620. API.output_prompt_gui("加载完成")
  1621. queue_controller.set_queue(in_queue, out_queue)
  1622. queue_controller()
  1623. SCREEN.mainloop()
  1624. queue_controller.stop_process()
  1625. algebra_controller = AlgebraPolynomial(API.output_prompt_gui)
  1626. tkinter.Label(
  1627. SCREEN,
  1628. text="符号名字:",
  1629. bg=bg_color,
  1630. fg=word_color,
  1631. font=FONT,
  1632. width=gui_width,
  1633. height=gui_height,
  1634. ).grid(
  1635. column=column, row=row
  1636. ) # 设置说明
  1637. variable_name = tkinter.Entry(SCREEN, width=gui_width * 2)
  1638. variable_name.grid(
  1639. column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W
  1640. )
  1641. row += 1
  1642. tkinter.Button(
  1643. SCREEN,
  1644. bg=buttom_color,
  1645. fg=word_color,
  1646. text="实数符号(R)",
  1647. command=API.add_real,
  1648. font=FONT,
  1649. width=gui_width,
  1650. height=gui_height,
  1651. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  1652. tkinter.Button(
  1653. SCREEN,
  1654. bg=buttom_color,
  1655. fg=word_color,
  1656. text="整数符号(Z)",
  1657. command=API.add_integer,
  1658. font=FONT,
  1659. width=gui_width,
  1660. height=gui_height,
  1661. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  1662. tkinter.Button(
  1663. SCREEN,
  1664. bg=buttom_color,
  1665. fg=word_color,
  1666. text="非负实数符号",
  1667. command=API.add_non_negative_real,
  1668. font=FONT,
  1669. width=gui_width,
  1670. height=gui_height,
  1671. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  1672. row += 1
  1673. tkinter.Button(
  1674. SCREEN,
  1675. bg=buttom_color,
  1676. fg=word_color,
  1677. text="偶数符号",
  1678. command=API.add_even,
  1679. font=FONT,
  1680. width=gui_width,
  1681. height=gui_height,
  1682. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  1683. tkinter.Button(
  1684. SCREEN,
  1685. bg=buttom_color,
  1686. fg=word_color,
  1687. text="奇数符号",
  1688. command=API.add_odd,
  1689. font=FONT,
  1690. width=gui_width,
  1691. height=gui_height,
  1692. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  1693. tkinter.Button(
  1694. SCREEN,
  1695. bg=buttom_color,
  1696. fg=word_color,
  1697. text="正数符号",
  1698. command=API.add_positive_real,
  1699. font=FONT,
  1700. width=gui_width,
  1701. height=gui_height,
  1702. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  1703. row += 1
  1704. tkinter.Button(
  1705. SCREEN,
  1706. bg=buttom_color,
  1707. fg=word_color,
  1708. text="自然数符号",
  1709. command=API.add_natural,
  1710. font=FONT,
  1711. width=gui_width,
  1712. height=gui_height,
  1713. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  1714. tkinter.Button(
  1715. SCREEN,
  1716. bg=buttom_color,
  1717. fg=word_color,
  1718. text="正整数符号",
  1719. command=API.add_positive_integer,
  1720. font=FONT,
  1721. width=gui_width,
  1722. height=gui_height,
  1723. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  1724. tkinter.Button(
  1725. SCREEN,
  1726. bg=buttom_color,
  1727. fg=word_color,
  1728. text="无约束符号",
  1729. command=API.add_no_constraints,
  1730. font=FONT,
  1731. width=gui_width,
  1732. height=gui_height,
  1733. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  1734. row += 1
  1735. is_generation = tkinter.IntVar() # 代数或者超越数
  1736. lable = ["均可", "代数", "超越数"]
  1737. for i in range(3):
  1738. tkinter.Radiobutton(
  1739. SCREEN,
  1740. bg=bg_color,
  1741. fg=word_color,
  1742. activebackground=bg_color,
  1743. activeforeground=word_color,
  1744. selectcolor=bg_color,
  1745. text=lable[i],
  1746. variable=is_generation,
  1747. value=i,
  1748. ).grid(column=column + i, row=row, sticky=tkinter.W)
  1749. row += 1
  1750. is_rational = tkinter.IntVar() # 有理数或者无理数
  1751. lable = ["均可", "有理数", "无理数"]
  1752. for i in range(3):
  1753. tkinter.Radiobutton(
  1754. SCREEN,
  1755. bg=bg_color,
  1756. fg=word_color,
  1757. activebackground=bg_color,
  1758. activeforeground=word_color,
  1759. selectcolor=bg_color,
  1760. text=lable[i],
  1761. variable=is_rational,
  1762. value=i,
  1763. ).grid(column=column + i, row=row, sticky=tkinter.W)
  1764. row += 1
  1765. is_prime = tkinter.IntVar() # 质数合数
  1766. lable = ["均可", "质数", "合数"]
  1767. for i in range(3):
  1768. tkinter.Radiobutton(
  1769. SCREEN,
  1770. bg=bg_color,
  1771. fg=word_color,
  1772. activebackground=bg_color,
  1773. activeforeground=word_color,
  1774. selectcolor=bg_color,
  1775. text=lable[i],
  1776. variable=is_prime,
  1777. value=i,
  1778. ).grid(column=column + i, row=row, sticky=tkinter.W)
  1779. row += 1
  1780. is_even = tkinter.IntVar() # 奇数偶数
  1781. lable = ["均可", "偶数", "奇数"]
  1782. for i in range(3):
  1783. tkinter.Radiobutton(
  1784. SCREEN,
  1785. bg=bg_color,
  1786. fg=word_color,
  1787. activebackground=bg_color,
  1788. activeforeground=word_color,
  1789. selectcolor=bg_color,
  1790. text=lable[i],
  1791. variable=is_even,
  1792. value=i,
  1793. ).grid(column=column + i, row=row, sticky=tkinter.W)
  1794. row += 1
  1795. is_complex = [] # 实数虚数
  1796. lable = ["复数", "实数", "虚数"]
  1797. for i in range(3):
  1798. is_complex.append(tkinter.IntVar())
  1799. tkinter.Checkbutton(
  1800. SCREEN,
  1801. bg=bg_color,
  1802. fg=word_color,
  1803. activebackground=bg_color,
  1804. activeforeground=word_color,
  1805. selectcolor=bg_color,
  1806. text=lable[i],
  1807. variable=is_complex[-1],
  1808. ).grid(column=column + i, row=row, sticky=tkinter.W)
  1809. row += 1
  1810. is_positives = [] # 正,负,0
  1811. lable = ["正数", "负数", "零"] # 复选框
  1812. for i in range(3):
  1813. is_positives.append(tkinter.IntVar())
  1814. tkinter.Checkbutton(
  1815. SCREEN,
  1816. bg=bg_color,
  1817. fg=word_color,
  1818. activebackground=bg_color,
  1819. activeforeground=word_color,
  1820. selectcolor=bg_color,
  1821. text=lable[i],
  1822. variable=is_positives[-1],
  1823. ).grid(column=column + i, row=row, sticky=tkinter.W)
  1824. row += 1
  1825. is_limited = tkinter.IntVar() # 实数
  1826. lable = ["均可", "有限实数", "无穷数", "广义实数"]
  1827. for i in range(3):
  1828. tkinter.Radiobutton(
  1829. SCREEN,
  1830. bg=bg_color,
  1831. fg=word_color,
  1832. activebackground=bg_color,
  1833. activeforeground=word_color,
  1834. selectcolor=bg_color,
  1835. text=lable[i],
  1836. variable=is_limited,
  1837. value=i,
  1838. ).grid(column=column + i, row=row, sticky=tkinter.W)
  1839. row += 1
  1840. tkinter.Radiobutton(
  1841. SCREEN,
  1842. bg=bg_color,
  1843. fg=word_color,
  1844. activebackground=bg_color,
  1845. activeforeground=word_color,
  1846. selectcolor=bg_color,
  1847. text=lable[3],
  1848. variable=is_limited,
  1849. value=3,
  1850. ).grid(
  1851. column=column, row=row, sticky=tkinter.W
  1852. ) # 同上的
  1853. integer = tkinter.IntVar()
  1854. tkinter.Checkbutton(
  1855. SCREEN,
  1856. bg=bg_color,
  1857. fg=word_color,
  1858. activebackground=bg_color,
  1859. activeforeground=word_color,
  1860. selectcolor=bg_color,
  1861. text="整数",
  1862. variable=integer,
  1863. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  1864. row += 1
  1865. variable_box = tkinter.Listbox(
  1866. SCREEN, width=gui_width * 3, height=gui_height * 4
  1867. ) # 显示符号
  1868. variable_box.grid(
  1869. column=column,
  1870. row=row,
  1871. columnspan=3,
  1872. rowspan=6,
  1873. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  1874. )
  1875. row += 6
  1876. tkinter.Button(
  1877. SCREEN,
  1878. bg=buttom_color,
  1879. fg=word_color,
  1880. text="自定义符号",
  1881. command=API.add_custom_symbol,
  1882. font=FONT,
  1883. width=gui_width,
  1884. height=gui_height,
  1885. ).grid(
  1886. column=column, row=row, sticky=tkinter.E + tkinter.W
  1887. ) # 添加函数
  1888. tkinter.Button(
  1889. SCREEN,
  1890. bg=buttom_color,
  1891. fg=word_color,
  1892. text="查看假设",
  1893. command=API.get_predictions,
  1894. font=FONT,
  1895. width=gui_width,
  1896. height=gui_height,
  1897. ).grid(
  1898. column=column + 1, row=row, sticky=tkinter.E + tkinter.W
  1899. ) # 添加函数
  1900. tkinter.Button(
  1901. SCREEN,
  1902. bg=buttom_color,
  1903. fg=word_color,
  1904. text="删除符号",
  1905. command=API.del_symbol,
  1906. font=FONT,
  1907. width=gui_width,
  1908. height=gui_height,
  1909. ).grid(
  1910. column=column + 2, row=row, sticky=tkinter.E + tkinter.W
  1911. ) # 添加函数
  1912. row += 1
  1913. predictions_box = tkinter.Listbox(
  1914. SCREEN, width=gui_width * 3, height=gui_height * 5
  1915. ) # 显示函数假设
  1916. predictions_box.grid(
  1917. column=column,
  1918. row=row,
  1919. columnspan=3,
  1920. rowspan=5,
  1921. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  1922. )
  1923. column += 3
  1924. tkinter.Label(SCREEN, text="", bg=bg_color, fg=word_color, font=FONT, width=1).grid(
  1925. column=column, row=0
  1926. )
  1927. column += 1
  1928. row = 0
  1929. tkinter.Label(
  1930. SCREEN,
  1931. text="代数式:",
  1932. bg=bg_color,
  1933. fg=word_color,
  1934. font=FONT,
  1935. width=gui_width,
  1936. height=gui_height,
  1937. ).grid(
  1938. column=column, row=row
  1939. ) # 设置说明
  1940. algebra_expression = tkinter.Entry(SCREEN, width=gui_width * 2)
  1941. algebra_expression.grid(
  1942. column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W
  1943. )
  1944. row += 1
  1945. tkinter.Label(
  1946. SCREEN,
  1947. text="标识:",
  1948. bg=bg_color,
  1949. fg=word_color,
  1950. font=FONT,
  1951. width=gui_width,
  1952. height=gui_height,
  1953. ).grid(
  1954. column=column, row=row
  1955. ) # 设置说明
  1956. algebra_name = tkinter.Entry(SCREEN, width=gui_width * 2)
  1957. algebra_name.grid(
  1958. column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W
  1959. )
  1960. row += 1
  1961. tkinter.Label(
  1962. SCREEN,
  1963. text="标准:",
  1964. bg=bg_color,
  1965. fg=word_color,
  1966. font=FONT,
  1967. width=gui_width,
  1968. height=gui_height,
  1969. ).grid(
  1970. column=column, row=row
  1971. ) # 设置说明
  1972. ratdio = tkinter.Entry(SCREEN, width=gui_width * 2)
  1973. ratdio.grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  1974. row += 1
  1975. init_rationalization = tkinter.IntVar()
  1976. tkinter.Checkbutton(
  1977. SCREEN,
  1978. bg=bg_color,
  1979. fg=word_color,
  1980. activebackground=bg_color,
  1981. activeforeground=word_color,
  1982. selectcolor=bg_color,
  1983. text="有理化",
  1984. variable=init_rationalization,
  1985. ).grid(column=column, row=row, sticky=tkinter.W)
  1986. init_ignore_assumptions = tkinter.IntVar()
  1987. tkinter.Checkbutton(
  1988. SCREEN,
  1989. bg=bg_color,
  1990. fg=word_color,
  1991. activebackground=bg_color,
  1992. activeforeground=word_color,
  1993. selectcolor=bg_color,
  1994. text="忽略假设",
  1995. variable=init_ignore_assumptions,
  1996. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  1997. standardization = tkinter.IntVar()
  1998. tkinter.Checkbutton(
  1999. SCREEN,
  2000. bg=bg_color,
  2001. fg=word_color,
  2002. activebackground=bg_color,
  2003. activeforeground=word_color,
  2004. selectcolor=bg_color,
  2005. text="标准化",
  2006. variable=standardization,
  2007. ).grid(column=column + 1, row=row, sticky=tkinter.W)
  2008. row += 1
  2009. tkinter.Button(
  2010. SCREEN,
  2011. bg=buttom_color,
  2012. fg=word_color,
  2013. text="清空代数式",
  2014. command=API.clear_algebra,
  2015. font=FONT,
  2016. width=gui_width,
  2017. height=gui_height,
  2018. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2019. tkinter.Button(
  2020. SCREEN,
  2021. bg=buttom_color,
  2022. fg=word_color,
  2023. text="生成代数式",
  2024. command=API.add_algebraic,
  2025. font=FONT,
  2026. width=gui_width,
  2027. height=gui_height,
  2028. ).grid(
  2029. column=column + 1, row=row, sticky=tkinter.E + tkinter.W
  2030. ) # 添加函数
  2031. tkinter.Button(
  2032. SCREEN,
  2033. bg=buttom_color,
  2034. fg=word_color,
  2035. text="删除代数式",
  2036. command=API.del_algebra,
  2037. font=FONT,
  2038. width=gui_width,
  2039. height=gui_height,
  2040. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2041. row += 1
  2042. algebra_box = tkinter.Listbox(SCREEN, width=gui_width * 3) # 显示代数式
  2043. algebra_box.grid(
  2044. column=column,
  2045. row=row,
  2046. columnspan=3,
  2047. rowspan=4,
  2048. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  2049. )
  2050. row += 4
  2051. tkinter.Label(
  2052. SCREEN,
  2053. text="重写对象:",
  2054. bg=bg_color,
  2055. fg=word_color,
  2056. font=FONT,
  2057. width=gui_width,
  2058. height=gui_height,
  2059. ).grid(
  2060. column=column, row=row
  2061. ) # 设置说明
  2062. rewrite_object = tkinter.Entry(SCREEN, width=gui_width * 2)
  2063. rewrite_object.grid(
  2064. column=column + 1, columnspan=2, row=row, sticky=tkinter.W + tkinter.E
  2065. )
  2066. row += 1
  2067. tkinter.Label(
  2068. SCREEN,
  2069. text="重写方法:",
  2070. bg=bg_color,
  2071. fg=word_color,
  2072. font=FONT,
  2073. width=gui_width,
  2074. height=gui_height,
  2075. ).grid(
  2076. column=column, row=row
  2077. ) # 设置说明
  2078. rewrite_func = tkinter.Entry(SCREEN, width=gui_width * 2)
  2079. rewrite_func.grid(
  2080. column=column + 1, columnspan=2, row=row, sticky=tkinter.W + tkinter.E
  2081. )
  2082. row += 1
  2083. rewrite_deep = tkinter.IntVar()
  2084. tkinter.Checkbutton(
  2085. SCREEN,
  2086. bg=bg_color,
  2087. fg=word_color,
  2088. activebackground=bg_color,
  2089. activeforeground=word_color,
  2090. selectcolor=bg_color,
  2091. text="重写子代数式",
  2092. variable=rewrite_deep,
  2093. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  2094. tkinter.Button(
  2095. SCREEN,
  2096. bg=buttom_color,
  2097. fg=word_color,
  2098. text="重写代数式",
  2099. command=API.rewrite_algebra,
  2100. font=FONT,
  2101. width=gui_width,
  2102. height=gui_height,
  2103. ).grid(column=column, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  2104. row += 1
  2105. tkinter.Label(
  2106. SCREEN,
  2107. text="同类项:",
  2108. bg=bg_color,
  2109. fg=word_color,
  2110. font=FONT,
  2111. width=gui_width,
  2112. height=gui_height,
  2113. ).grid(
  2114. column=column, row=row
  2115. ) # 设置说明
  2116. similar_items = tkinter.Entry(SCREEN, width=gui_width * 2)
  2117. similar_items.grid(
  2118. column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W
  2119. )
  2120. row += 1
  2121. return_type = tkinter.IntVar() # 正,负,0
  2122. lable = ["仅系数(同类项)", "仅代数式", "均保留"] # 复选框
  2123. for i in range(3):
  2124. tkinter.Radiobutton(
  2125. SCREEN,
  2126. bg=bg_color,
  2127. fg=word_color,
  2128. activebackground=bg_color,
  2129. activeforeground=word_color,
  2130. selectcolor=bg_color,
  2131. text=lable[i],
  2132. variable=return_type,
  2133. value=i,
  2134. ).grid(column=column + i, row=row, sticky=tkinter.W)
  2135. row += 1
  2136. tkinter.Label(
  2137. SCREEN,
  2138. text="拆分函数:",
  2139. bg=bg_color,
  2140. fg=word_color,
  2141. font=FONT,
  2142. width=gui_width,
  2143. height=gui_height,
  2144. ).grid(
  2145. column=column, row=row
  2146. ) # 设置说明
  2147. split_func = tkinter.Entry(SCREEN, width=gui_width)
  2148. split_func.grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2149. deep_split = tkinter.IntVar()
  2150. tkinter.Checkbutton(
  2151. SCREEN,
  2152. bg=bg_color,
  2153. fg=word_color,
  2154. activebackground=bg_color,
  2155. activeforeground=word_color,
  2156. selectcolor=bg_color,
  2157. text="完全拆分",
  2158. variable=deep_split,
  2159. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  2160. row += 1
  2161. tkinter.Button(
  2162. SCREEN,
  2163. bg=buttom_color,
  2164. fg=word_color,
  2165. text="同类项拆分",
  2166. command=API.algebraic_similarity_split,
  2167. font=FONT,
  2168. width=gui_width,
  2169. height=gui_height,
  2170. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2171. tkinter.Button(
  2172. SCREEN,
  2173. bg=buttom_color,
  2174. fg=word_color,
  2175. text="乘法拆分",
  2176. command=API.algebraic_factorization,
  2177. font=FONT,
  2178. width=gui_width,
  2179. height=gui_height,
  2180. ).grid(
  2181. column=column + 1, row=row, sticky=tkinter.E + tkinter.W
  2182. ) # 添加函数
  2183. tkinter.Button(
  2184. SCREEN,
  2185. bg=buttom_color,
  2186. fg=word_color,
  2187. text="函数拆分",
  2188. command=API.algebraic_partition,
  2189. font=FONT,
  2190. width=gui_width,
  2191. height=gui_height,
  2192. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2193. row += 1
  2194. on_hold_algebra = tkinter.Listbox(
  2195. SCREEN, width=gui_width * 3, height=gui_height * 4
  2196. ) # 显示代数式
  2197. on_hold_algebra.grid(
  2198. column=column,
  2199. row=row,
  2200. columnspan=3,
  2201. rowspan=4,
  2202. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  2203. )
  2204. row += 4
  2205. tkinter.Button(
  2206. SCREEN,
  2207. bg=buttom_color,
  2208. fg=word_color,
  2209. text="添加",
  2210. command=API.add_operation_algebra,
  2211. font=FONT,
  2212. width=gui_width,
  2213. height=gui_height,
  2214. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2215. tkinter.Button(
  2216. SCREEN,
  2217. bg=buttom_color,
  2218. fg=word_color,
  2219. text="清空",
  2220. command=API.clear_operational_algebra,
  2221. font=FONT,
  2222. width=gui_width,
  2223. height=gui_height,
  2224. ).grid(
  2225. column=column + 1, row=row, sticky=tkinter.E + tkinter.W
  2226. ) # 添加函数
  2227. tkinter.Button(
  2228. SCREEN,
  2229. bg=buttom_color,
  2230. fg=word_color,
  2231. text="删除",
  2232. command=API.del_operation_algebra,
  2233. font=FONT,
  2234. width=gui_width,
  2235. height=gui_height,
  2236. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2237. row += 1
  2238. tkinter.Label(
  2239. SCREEN,
  2240. text="合成函数:",
  2241. bg=bg_color,
  2242. fg=word_color,
  2243. font=FONT,
  2244. width=gui_width,
  2245. height=gui_height,
  2246. ).grid(
  2247. column=column, row=row
  2248. ) # 设置说明
  2249. merge_func = tkinter.Entry(SCREEN, width=gui_width * 2)
  2250. merge_func.grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  2251. row += 1
  2252. tkinter.Button(
  2253. SCREEN,
  2254. bg=buttom_color,
  2255. fg=word_color,
  2256. text="多项式合成",
  2257. command=API.algebraic_addition,
  2258. font=FONT,
  2259. width=gui_width,
  2260. height=gui_height,
  2261. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2262. tkinter.Button(
  2263. SCREEN,
  2264. bg=buttom_color,
  2265. fg=word_color,
  2266. text="因式合成",
  2267. command=API.algebraic_multiplication,
  2268. font=FONT,
  2269. width=gui_width,
  2270. height=gui_height,
  2271. ).grid(
  2272. column=column + 1, row=row, sticky=tkinter.E + tkinter.W
  2273. ) # 添加函数
  2274. tkinter.Button(
  2275. SCREEN,
  2276. bg=buttom_color,
  2277. fg=word_color,
  2278. text="函数合成",
  2279. command=API.algebraic_composition,
  2280. font=FONT,
  2281. width=gui_width,
  2282. height=gui_height,
  2283. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2284. row += 1
  2285. tkinter.Label(
  2286. SCREEN,
  2287. text="有效数字:",
  2288. bg=bg_color,
  2289. fg=word_color,
  2290. font=FONT,
  2291. width=gui_width,
  2292. height=gui_height,
  2293. ).grid(
  2294. column=column + 1, row=row
  2295. ) # 设置说明
  2296. valid_number = tkinter.Entry(SCREEN, width=gui_width)
  2297. valid_number.grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2298. tkinter.Button(
  2299. SCREEN,
  2300. bg=buttom_color,
  2301. fg=word_color,
  2302. text="代数式数字化",
  2303. command=API.algebraic_digitization,
  2304. font=FONT,
  2305. width=gui_width,
  2306. height=gui_height,
  2307. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2308. column += 3
  2309. tkinter.Label(SCREEN, text="", bg=bg_color, fg=word_color, font=FONT, width=1).grid(
  2310. column=column, row=0
  2311. )
  2312. column += 1
  2313. row = 0
  2314. tkinter.Label(
  2315. SCREEN,
  2316. text="【分式恒等变形】",
  2317. bg=bg_color,
  2318. fg=word_color,
  2319. font=FONT,
  2320. width=gui_width * 3,
  2321. height=gui_height,
  2322. ).grid(
  2323. column=column, row=row, columnspan=3
  2324. ) # 设置说明
  2325. row += 1
  2326. fully_divided = tkinter.IntVar()
  2327. tkinter.Label(
  2328. SCREEN,
  2329. text="裂项关注对象:",
  2330. bg=bg_color,
  2331. fg=word_color,
  2332. font=FONT,
  2333. width=gui_width,
  2334. height=gui_height,
  2335. ).grid(
  2336. column=column, row=row
  2337. ) # 设置说明
  2338. apart = tkinter.Entry(SCREEN, width=gui_width)
  2339. apart.grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2340. tkinter.Checkbutton(
  2341. SCREEN,
  2342. bg=bg_color,
  2343. fg=word_color,
  2344. activebackground=bg_color,
  2345. activeforeground=word_color,
  2346. selectcolor=bg_color,
  2347. text="完全转化分式",
  2348. variable=fully_divided,
  2349. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  2350. row += 1
  2351. rationalized_unknown = tkinter.IntVar()
  2352. tkinter.Label(
  2353. SCREEN,
  2354. text="最大无理项:",
  2355. bg=bg_color,
  2356. fg=word_color,
  2357. font=FONT,
  2358. width=gui_width,
  2359. height=gui_height,
  2360. ).grid(
  2361. column=column, row=row
  2362. ) # 设置说明
  2363. maximum_irrational_term = tkinter.Entry(SCREEN, width=gui_width)
  2364. maximum_irrational_term.grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2365. tkinter.Checkbutton(
  2366. SCREEN,
  2367. bg=bg_color,
  2368. fg=word_color,
  2369. activebackground=bg_color,
  2370. activeforeground=word_color,
  2371. selectcolor=bg_color,
  2372. text="有理化符号分母",
  2373. variable=rationalized_unknown,
  2374. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  2375. row += 1
  2376. tkinter.Button(
  2377. SCREEN,
  2378. bg=buttom_color,
  2379. fg=word_color,
  2380. text="最小公分母",
  2381. command=API.fractional_division,
  2382. font=FONT,
  2383. width=gui_width,
  2384. height=gui_height,
  2385. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2386. tkinter.Button(
  2387. SCREEN,
  2388. bg=buttom_color,
  2389. fg=word_color,
  2390. text="分式约分",
  2391. command=API.fraction_reduction,
  2392. font=FONT,
  2393. width=gui_width,
  2394. height=gui_height,
  2395. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2396. tkinter.Button(
  2397. SCREEN,
  2398. bg=buttom_color,
  2399. fg=word_color,
  2400. text="分式裂项",
  2401. command=API.fractional_fission,
  2402. font=FONT,
  2403. width=gui_width,
  2404. height=gui_height,
  2405. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2406. row += 1
  2407. tkinter.Button(
  2408. SCREEN,
  2409. bg=buttom_color,
  2410. fg=word_color,
  2411. text="分母有理化",
  2412. command=API.denominator_rationalization,
  2413. font=FONT,
  2414. width=gui_width,
  2415. height=gui_height,
  2416. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2417. tkinter.Button(
  2418. SCREEN,
  2419. bg=buttom_color,
  2420. fg=word_color,
  2421. text="转化为分式(小改动)",
  2422. command=API.fractional_synthesis,
  2423. font=FONT,
  2424. width=gui_width,
  2425. height=gui_height,
  2426. ).grid(column=column + 1, columnspan=2, row=row, sticky=tkinter.E + tkinter.W)
  2427. row += 1
  2428. tkinter.Label(
  2429. SCREEN,
  2430. text="【三角恒等变换】",
  2431. bg=bg_color,
  2432. fg=word_color,
  2433. font=FONT,
  2434. width=gui_width * 3,
  2435. height=gui_height,
  2436. ).grid(
  2437. column=column, row=row, columnspan=3
  2438. ) # 设置说明
  2439. row += 1
  2440. trig_fully_expand = tkinter.IntVar()
  2441. tkinter.Button(
  2442. SCREEN,
  2443. bg=buttom_color,
  2444. fg=word_color,
  2445. text="展开三角函数",
  2446. command=API.expand_trigonometric,
  2447. font=FONT,
  2448. width=gui_width,
  2449. height=gui_height,
  2450. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2451. tkinter.Button(
  2452. SCREEN,
  2453. bg=buttom_color,
  2454. fg=word_color,
  2455. text="三角函数合成",
  2456. command=API.reduced_trigonometric,
  2457. font=FONT,
  2458. width=gui_width,
  2459. height=gui_height,
  2460. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2461. tkinter.Checkbutton(
  2462. SCREEN,
  2463. bg=bg_color,
  2464. fg=word_color,
  2465. activebackground=bg_color,
  2466. activeforeground=word_color,
  2467. selectcolor=bg_color,
  2468. text="完全展开",
  2469. variable=trig_fully_expand,
  2470. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  2471. row += 1
  2472. tkinter.Label(
  2473. SCREEN,
  2474. text="【乘法、指数、对数恒等变形】",
  2475. bg=bg_color,
  2476. fg=word_color,
  2477. font=FONT,
  2478. width=gui_width * 3,
  2479. height=gui_height,
  2480. ).grid(
  2481. column=column, row=row, columnspan=3
  2482. ) # 设置说明
  2483. row += 1
  2484. ignore_assumptions = tkinter.IntVar()
  2485. fully_expand = tkinter.IntVar()
  2486. tkinter.Checkbutton(
  2487. SCREEN,
  2488. bg=bg_color,
  2489. fg=word_color,
  2490. activebackground=bg_color,
  2491. activeforeground=word_color,
  2492. selectcolor=bg_color,
  2493. text="忽略假设",
  2494. variable=ignore_assumptions,
  2495. ).grid(column=column + 1, row=row, sticky=tkinter.W)
  2496. tkinter.Checkbutton(
  2497. SCREEN,
  2498. bg=bg_color,
  2499. fg=word_color,
  2500. activebackground=bg_color,
  2501. activeforeground=word_color,
  2502. selectcolor=bg_color,
  2503. text="完全展开",
  2504. variable=fully_expand,
  2505. ).grid(column=column, row=row, sticky=tkinter.W)
  2506. row += 1
  2507. tkinter.Button(
  2508. SCREEN,
  2509. bg=buttom_color,
  2510. fg=word_color,
  2511. text="展开乘法",
  2512. command=API.expand_mul,
  2513. font=FONT,
  2514. width=gui_width,
  2515. height=gui_height,
  2516. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2517. tkinter.Button(
  2518. SCREEN,
  2519. bg=buttom_color,
  2520. fg=word_color,
  2521. text="展开加法式幂",
  2522. command=API.expand_additive_index,
  2523. font=FONT,
  2524. width=gui_width,
  2525. height=gui_height,
  2526. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2527. tkinter.Button(
  2528. SCREEN,
  2529. bg=buttom_color,
  2530. fg=word_color,
  2531. text="指数合成",
  2532. command=API.composite_index,
  2533. font=FONT,
  2534. width=gui_width,
  2535. height=gui_height,
  2536. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2537. row += 1
  2538. tkinter.Button(
  2539. SCREEN,
  2540. bg=buttom_color,
  2541. fg=word_color,
  2542. text="化简指数底数",
  2543. command=API.reduce_exp_base,
  2544. font=FONT,
  2545. width=gui_width,
  2546. height=gui_height,
  2547. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2548. tkinter.Button(
  2549. SCREEN,
  2550. bg=buttom_color,
  2551. fg=word_color,
  2552. text="化简指数幂",
  2553. command=API.reduce_exp_index,
  2554. font=FONT,
  2555. width=gui_width,
  2556. height=gui_height,
  2557. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2558. tkinter.Button(
  2559. SCREEN,
  2560. bg=buttom_color,
  2561. fg=word_color,
  2562. text="化简指数",
  2563. command=API.reduced_power,
  2564. font=FONT,
  2565. width=gui_width,
  2566. height=gui_height,
  2567. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2568. row += 1
  2569. tkinter.Button(
  2570. SCREEN,
  2571. bg=buttom_color,
  2572. fg=word_color,
  2573. text="展开指数底数",
  2574. command=API.expand_exp_base,
  2575. font=FONT,
  2576. width=gui_width,
  2577. height=gui_height,
  2578. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2579. tkinter.Button(
  2580. SCREEN,
  2581. bg=buttom_color,
  2582. fg=word_color,
  2583. text="展开指数幂",
  2584. command=API.expand_exp_index,
  2585. font=FONT,
  2586. width=gui_width,
  2587. height=gui_height,
  2588. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2589. tkinter.Button(
  2590. SCREEN,
  2591. bg=buttom_color,
  2592. fg=word_color,
  2593. text="展开指数",
  2594. command=API.expand_power,
  2595. font=FONT,
  2596. width=gui_width,
  2597. height=gui_height,
  2598. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2599. ignore_assumptions_log = tkinter.IntVar()
  2600. log_fully_expand = tkinter.IntVar()
  2601. row += 1
  2602. tkinter.Checkbutton(
  2603. SCREEN,
  2604. bg=bg_color,
  2605. fg=word_color,
  2606. activebackground=bg_color,
  2607. activeforeground=word_color,
  2608. selectcolor=bg_color,
  2609. text="完全展开",
  2610. variable=log_fully_expand,
  2611. ).grid(column=column, row=row, sticky=tkinter.W)
  2612. tkinter.Checkbutton(
  2613. SCREEN,
  2614. bg=bg_color,
  2615. fg=word_color,
  2616. activebackground=bg_color,
  2617. activeforeground=word_color,
  2618. selectcolor=bg_color,
  2619. text="忽略假设",
  2620. variable=ignore_assumptions_log,
  2621. ).grid(column=column + 1, row=row, sticky=tkinter.W)
  2622. row += 1
  2623. tkinter.Button(
  2624. SCREEN,
  2625. bg=buttom_color,
  2626. fg=word_color,
  2627. text="展开对数",
  2628. command=API.expand_log,
  2629. font=FONT,
  2630. width=gui_width,
  2631. height=gui_height,
  2632. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2633. tkinter.Button(
  2634. SCREEN,
  2635. bg=buttom_color,
  2636. fg=word_color,
  2637. text="化简对数",
  2638. command=API.reduce_log,
  2639. font=FONT,
  2640. width=gui_width,
  2641. height=gui_height,
  2642. ).grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  2643. row += 1
  2644. tkinter.Label(
  2645. SCREEN,
  2646. text="【虚数与特殊函数】",
  2647. bg=bg_color,
  2648. fg=word_color,
  2649. font=FONT,
  2650. width=gui_width * 3,
  2651. height=gui_height,
  2652. ).grid(
  2653. column=column, row=row, columnspan=3
  2654. ) # 设置说明
  2655. row += 1
  2656. tkinter.Button(
  2657. SCREEN,
  2658. bg=buttom_color,
  2659. fg=word_color,
  2660. text="展开特殊函数",
  2661. command=API.expand_special,
  2662. font=FONT,
  2663. width=gui_width,
  2664. height=gui_height,
  2665. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2666. tkinter.Button(
  2667. SCREEN,
  2668. bg=buttom_color,
  2669. fg=word_color,
  2670. text="展开虚数",
  2671. command=API.expand_complex,
  2672. font=FONT,
  2673. width=gui_width,
  2674. height=gui_height,
  2675. ).grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  2676. row += 1
  2677. tkinter.Label(
  2678. SCREEN,
  2679. text="【普遍操作类】",
  2680. bg=bg_color,
  2681. fg=word_color,
  2682. font=FONT,
  2683. width=gui_width * 3,
  2684. height=gui_height,
  2685. ).grid(
  2686. column=column, row=row, columnspan=3
  2687. ) # 设置说明
  2688. row += 1
  2689. tkinter.Label(
  2690. SCREEN,
  2691. text="简化方案:",
  2692. bg=bg_color,
  2693. fg=word_color,
  2694. font=FONT,
  2695. width=gui_width,
  2696. height=gui_height,
  2697. ).grid(
  2698. column=column, row=row
  2699. ) # 设置说明
  2700. simplify_func_Input = tkinter.Entry(SCREEN, width=gui_width) # 简化方案
  2701. simplify_func_Input.grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2702. tkinter.Checkbutton(
  2703. SCREEN,
  2704. bg=bg_color,
  2705. fg=word_color,
  2706. activebackground=bg_color,
  2707. activeforeground=word_color,
  2708. selectcolor=bg_color,
  2709. text="有理化",
  2710. variable=init_rationalization,
  2711. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  2712. row += 1
  2713. tkinter.Label(
  2714. SCREEN,
  2715. text="简化比率:",
  2716. bg=bg_color,
  2717. fg=word_color,
  2718. font=FONT,
  2719. width=gui_width,
  2720. height=gui_height,
  2721. ).grid(
  2722. column=column, row=row
  2723. ) # 设置说明
  2724. simplify_ratio_input = tkinter.Entry(SCREEN, width=gui_width) # 简化比率
  2725. simplify_ratio_input.grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2726. tkinter.Checkbutton(
  2727. SCREEN,
  2728. bg=bg_color,
  2729. fg=word_color,
  2730. activebackground=bg_color,
  2731. activeforeground=word_color,
  2732. selectcolor=bg_color,
  2733. text="忽略假设",
  2734. variable=init_ignore_assumptions,
  2735. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  2736. is_gaussian = tkinter.IntVar()
  2737. fully_factor = tkinter.IntVar()
  2738. factor_rat = tkinter.IntVar()
  2739. row += 1
  2740. tkinter.Label(
  2741. SCREEN,
  2742. text="模数:",
  2743. bg=bg_color,
  2744. fg=word_color,
  2745. font=FONT,
  2746. width=gui_width,
  2747. height=gui_height,
  2748. ).grid(
  2749. column=column, row=row
  2750. ) # 设置说明
  2751. modulus = tkinter.Entry(SCREEN, width=gui_width) # 简化比率
  2752. modulus.grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2753. tkinter.Checkbutton(
  2754. SCREEN,
  2755. bg=bg_color,
  2756. fg=word_color,
  2757. activebackground=bg_color,
  2758. activeforeground=word_color,
  2759. selectcolor=bg_color,
  2760. text="高斯因式分解",
  2761. variable=is_gaussian,
  2762. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  2763. row += 1
  2764. tkinter.Checkbutton(
  2765. SCREEN,
  2766. bg=bg_color,
  2767. fg=word_color,
  2768. activebackground=bg_color,
  2769. activeforeground=word_color,
  2770. selectcolor=bg_color,
  2771. text="完全因式分解",
  2772. variable=fully_factor,
  2773. ).grid(column=column, row=row, sticky=tkinter.W)
  2774. tkinter.Checkbutton(
  2775. SCREEN,
  2776. bg=bg_color,
  2777. fg=word_color,
  2778. activebackground=bg_color,
  2779. activeforeground=word_color,
  2780. selectcolor=bg_color,
  2781. text="因式分解有理代数式",
  2782. variable=factor_rat,
  2783. ).grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.W)
  2784. row += 1
  2785. is_expand_complex = tkinter.IntVar()
  2786. tkinter.Label(
  2787. SCREEN,
  2788. text="同类项对象:",
  2789. bg=bg_color,
  2790. fg=word_color,
  2791. font=FONT,
  2792. width=gui_width,
  2793. height=gui_height,
  2794. ).grid(
  2795. column=column, row=row
  2796. ) # 设置说明
  2797. similar_items_object = tkinter.Entry(SCREEN, width=gui_width)
  2798. similar_items_object.grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2799. tkinter.Checkbutton(
  2800. SCREEN,
  2801. bg=bg_color,
  2802. fg=word_color,
  2803. activebackground=bg_color,
  2804. activeforeground=word_color,
  2805. selectcolor=bg_color,
  2806. text="展开复数",
  2807. variable=is_expand_complex,
  2808. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  2809. row += 1
  2810. tkinter.Button(
  2811. SCREEN,
  2812. bg=buttom_color,
  2813. fg=word_color,
  2814. text="化简标准化",
  2815. command=API.simplify_standardization,
  2816. font=FONT,
  2817. width=gui_width,
  2818. height=gui_height,
  2819. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2820. tkinter.Button(
  2821. SCREEN,
  2822. bg=buttom_color,
  2823. fg=word_color,
  2824. text="普遍运算展开",
  2825. command=API.general_expansion,
  2826. font=FONT,
  2827. width=gui_width,
  2828. height=gui_height,
  2829. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2830. tkinter.Button(
  2831. SCREEN,
  2832. bg=buttom_color,
  2833. fg=word_color,
  2834. text="因式分解",
  2835. command=API.factorization,
  2836. font=FONT,
  2837. width=gui_width,
  2838. height=gui_height,
  2839. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2840. row += 1
  2841. tkinter.Button(
  2842. SCREEN,
  2843. bg=buttom_color,
  2844. fg=word_color,
  2845. text="合并同类项",
  2846. command=API.merger_of_similar_items,
  2847. font=FONT,
  2848. width=gui_width,
  2849. height=gui_height,
  2850. ).grid(column=column, row=row, columnspan=3, sticky=tkinter.E + tkinter.W)
  2851. column += 3
  2852. tkinter.Label(SCREEN, text="", bg=bg_color, fg=word_color, font=FONT, width=1).grid(
  2853. column=column, row=0
  2854. )
  2855. column += 1
  2856. row = 0
  2857. tkinter.Label(
  2858. SCREEN,
  2859. text="【联立操作】",
  2860. bg=bg_color,
  2861. fg=word_color,
  2862. font=FONT,
  2863. width=gui_width * 3,
  2864. height=gui_height,
  2865. ).grid(
  2866. column=column, row=row, columnspan=3
  2867. ) # 设置说明
  2868. row += 1
  2869. tkinter.Button(
  2870. SCREEN,
  2871. bg=buttom_color,
  2872. fg=word_color,
  2873. text="选定符号",
  2874. command=API.add_left_simultaneous_values,
  2875. font=FONT,
  2876. width=gui_width,
  2877. height=gui_height,
  2878. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2879. tkinter.Button(
  2880. SCREEN,
  2881. bg=buttom_color,
  2882. fg=word_color,
  2883. text="选定代数式",
  2884. command=API.add_right_simultaneous_algebra,
  2885. font=FONT,
  2886. width=gui_width,
  2887. height=gui_height,
  2888. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2889. tkinter.Button(
  2890. SCREEN,
  2891. bg=buttom_color,
  2892. fg=word_color,
  2893. text="新键联立",
  2894. command=API.add_value_algebraic_simultaneous,
  2895. font=FONT,
  2896. width=gui_width,
  2897. height=gui_height,
  2898. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2899. row += 1
  2900. tkinter.Button(
  2901. SCREEN,
  2902. bg=buttom_color,
  2903. fg=word_color,
  2904. text="生成联立代数式",
  2905. command=API.value_algebraic_simultaneous,
  2906. font=FONT,
  2907. width=gui_width,
  2908. height=gui_height,
  2909. ).grid(column=column, columnspan=2, row=row, sticky=tkinter.E + tkinter.W)
  2910. tkinter.Button(
  2911. SCREEN,
  2912. bg=buttom_color,
  2913. fg=word_color,
  2914. text="删除联立",
  2915. command=API.del_value_algebraic_simultaneous,
  2916. font=FONT,
  2917. width=gui_width,
  2918. height=gui_height,
  2919. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2920. row += 1
  2921. value_algebra_box = tkinter.Listbox(
  2922. SCREEN, width=gui_width * 3, height=gui_height * 4
  2923. ) # 显示代数式
  2924. value_algebra_box.grid(
  2925. column=column,
  2926. row=row,
  2927. columnspan=3,
  2928. rowspan=4,
  2929. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  2930. )
  2931. row += 4
  2932. tkinter.Label(
  2933. SCREEN,
  2934. text="【反向联立操作】",
  2935. bg=bg_color,
  2936. fg=word_color,
  2937. font=FONT,
  2938. width=gui_width * 3,
  2939. height=gui_height,
  2940. ).grid(
  2941. column=column, row=row, columnspan=3
  2942. ) # 设置说明
  2943. # 反向联立系统
  2944. row += 1
  2945. tkinter.Button(
  2946. SCREEN,
  2947. bg=buttom_color,
  2948. fg=word_color,
  2949. text="选定代数式",
  2950. command=API.add_left_simultaneous_algebra,
  2951. font=FONT,
  2952. width=gui_width,
  2953. height=gui_height,
  2954. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2955. tkinter.Button(
  2956. SCREEN,
  2957. bg=buttom_color,
  2958. fg=word_color,
  2959. text="选定符号",
  2960. command=API.add_right_simultaneous_values,
  2961. font=FONT,
  2962. width=gui_width,
  2963. height=gui_height,
  2964. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2965. tkinter.Button(
  2966. SCREEN,
  2967. bg=buttom_color,
  2968. fg=word_color,
  2969. text="新键联立",
  2970. command=API.add_algebraic_values_simultaneously,
  2971. font=FONT,
  2972. width=gui_width,
  2973. height=gui_height,
  2974. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2975. row += 1
  2976. tkinter.Button(
  2977. SCREEN,
  2978. bg=buttom_color,
  2979. fg=word_color,
  2980. text="生成联立代数式",
  2981. command=API.algebragic_value_simultaneous,
  2982. font=FONT,
  2983. width=gui_width,
  2984. height=gui_height,
  2985. ).grid(column=column, columnspan=2, row=row, sticky=tkinter.E + tkinter.W)
  2986. tkinter.Button(
  2987. SCREEN,
  2988. bg=buttom_color,
  2989. fg=word_color,
  2990. text="删除联立",
  2991. command=API.del_algebraic_value_simultaneousness,
  2992. font=FONT,
  2993. width=gui_width,
  2994. height=gui_height,
  2995. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2996. row += 1
  2997. algebra_value_box = tkinter.Listbox(
  2998. SCREEN, width=gui_width * 3, height=gui_height * 4
  2999. ) # 显示代数式
  3000. algebra_value_box.grid(
  3001. column=column,
  3002. row=row,
  3003. columnspan=3,
  3004. rowspan=4,
  3005. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  3006. )
  3007. # 代数运算
  3008. row += 4
  3009. tkinter.Label(
  3010. SCREEN,
  3011. text="【赋值运算操作】",
  3012. bg=bg_color,
  3013. fg=word_color,
  3014. font=FONT,
  3015. width=gui_width * 3,
  3016. height=gui_height,
  3017. ).grid(
  3018. column=column, row=row, columnspan=3
  3019. ) # 设置说明
  3020. row += 1
  3021. tkinter.Label(
  3022. SCREEN,
  3023. text="数值:",
  3024. bg=bg_color,
  3025. fg=word_color,
  3026. font=FONT,
  3027. width=gui_width,
  3028. height=gui_height,
  3029. ).grid(
  3030. column=column, row=row
  3031. ) # 设置说明
  3032. number = tkinter.Entry(SCREEN, width=gui_width + 2)
  3033. number.grid(column=column + 1, row=row, sticky=tkinter.W)
  3034. tkinter.Button(
  3035. SCREEN,
  3036. bg=buttom_color,
  3037. fg=word_color,
  3038. text="指定符号",
  3039. command=API.add_variable_assignment,
  3040. font=FONT,
  3041. width=gui_width,
  3042. height=gui_height,
  3043. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  3044. row += 1
  3045. number_type = tkinter.IntVar() # 正,负,0
  3046. lable = ["浮点数", "整数", "分数有理数", "无约束数字"] # 复选框
  3047. for i in range(3):
  3048. tkinter.Radiobutton(
  3049. SCREEN,
  3050. bg=bg_color,
  3051. fg=word_color,
  3052. activebackground=bg_color,
  3053. activeforeground=word_color,
  3054. selectcolor=bg_color,
  3055. text=lable[i],
  3056. variable=number_type,
  3057. value=i,
  3058. ).grid(column=column + i, row=row, sticky=tkinter.W)
  3059. row += 1
  3060. tkinter.Radiobutton(
  3061. SCREEN,
  3062. bg=bg_color,
  3063. fg=word_color,
  3064. activebackground=bg_color,
  3065. activeforeground=word_color,
  3066. selectcolor=bg_color,
  3067. text=lable[3],
  3068. variable=number_type,
  3069. value=3,
  3070. ).grid(column=column + 1, row=row, sticky=tkinter.W)
  3071. row += 1
  3072. tkinter.Button(
  3073. SCREEN,
  3074. bg=buttom_color,
  3075. fg=word_color,
  3076. text="生成赋值代数式",
  3077. command=API.algebraic_assignment,
  3078. font=FONT,
  3079. width=gui_width,
  3080. height=gui_height,
  3081. ).grid(column=column, columnspan=2, row=row, sticky=tkinter.E + tkinter.W)
  3082. tkinter.Button(
  3083. SCREEN,
  3084. bg=buttom_color,
  3085. fg=word_color,
  3086. text="删除赋值",
  3087. command=API.del_variable_assignment,
  3088. font=FONT,
  3089. width=gui_width,
  3090. height=gui_height,
  3091. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  3092. row += 1
  3093. variable_assignment_box = tkinter.Listbox(
  3094. SCREEN, width=gui_width * 3, height=gui_height * 4
  3095. ) # 显示代数式
  3096. variable_assignment_box.grid(
  3097. column=column,
  3098. row=row,
  3099. columnspan=3,
  3100. rowspan=5,
  3101. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  3102. )
  3103. column += 3
  3104. tkinter.Label(SCREEN, text="", bg=bg_color, fg=word_color, font=FONT, width=1).grid(
  3105. column=column, row=0
  3106. )
  3107. column += 1
  3108. row = 0
  3109. tkinter.Label(
  3110. SCREEN,
  3111. text="【方程联立】",
  3112. bg=bg_color,
  3113. fg=word_color,
  3114. font=FONT,
  3115. width=gui_width * 3,
  3116. height=gui_height,
  3117. ).grid(
  3118. column=column, row=row, columnspan=3
  3119. ) # 设置说明
  3120. row += 1
  3121. tkinter.Button(
  3122. SCREEN,
  3123. bg=buttom_color,
  3124. fg=word_color,
  3125. text="左代数式",
  3126. command=API.add_equation_left,
  3127. font=FONT,
  3128. width=gui_width,
  3129. height=gui_height,
  3130. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  3131. tkinter.Button(
  3132. SCREEN,
  3133. bg=buttom_color,
  3134. fg=word_color,
  3135. text="右代数式",
  3136. command=API.add_equation_right,
  3137. font=FONT,
  3138. width=gui_width,
  3139. height=gui_height,
  3140. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  3141. tkinter.Button(
  3142. SCREEN,
  3143. bg=buttom_color,
  3144. fg=word_color,
  3145. text="新建方程",
  3146. command=API.generating_equation,
  3147. font=FONT,
  3148. width=gui_width,
  3149. height=gui_height,
  3150. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  3151. row += 1
  3152. tkinter.Button(
  3153. SCREEN,
  3154. bg=buttom_color,
  3155. fg=word_color,
  3156. text="解联立方程",
  3157. command=API.solve_simultaneous_equations,
  3158. font=FONT,
  3159. width=gui_width,
  3160. height=gui_height,
  3161. ).grid(column=column, columnspan=2, row=row, sticky=tkinter.E + tkinter.W)
  3162. tkinter.Button(
  3163. SCREEN,
  3164. bg=buttom_color,
  3165. fg=word_color,
  3166. text="删除方程",
  3167. command=API.del_equation,
  3168. font=FONT,
  3169. width=gui_width,
  3170. height=gui_height,
  3171. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  3172. row += 1
  3173. equation_box = tkinter.Listbox(
  3174. SCREEN, width=gui_width * 3, height=gui_height * 2
  3175. ) # 显示代数式
  3176. equation_box.grid(
  3177. column=column,
  3178. row=row,
  3179. columnspan=3,
  3180. rowspan=2,
  3181. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  3182. )
  3183. row += 2
  3184. tkinter.Button(
  3185. SCREEN,
  3186. bg=buttom_color,
  3187. fg=word_color,
  3188. text="应用为代数式",
  3189. command=API.add_to_algebraic_box,
  3190. font=FONT,
  3191. width=gui_width,
  3192. height=gui_height,
  3193. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  3194. tkinter.Button(
  3195. SCREEN,
  3196. bg=buttom_color,
  3197. fg=word_color,
  3198. text="添加联立",
  3199. command=API.add_to_value_algebraic_box,
  3200. font=FONT,
  3201. width=gui_width,
  3202. height=gui_height,
  3203. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  3204. tkinter.Button(
  3205. SCREEN,
  3206. bg=buttom_color,
  3207. fg=word_color,
  3208. text="添加反联立",
  3209. command=API.add_to_algebraic_value_box,
  3210. font=FONT,
  3211. width=gui_width,
  3212. height=gui_height,
  3213. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  3214. row += 1
  3215. equation_solution_box = tkinter.Listbox(
  3216. SCREEN, width=gui_width * 3, height=gui_height * 2
  3217. ) # 显示代数式
  3218. equation_solution_box.grid(
  3219. column=column,
  3220. row=row,
  3221. columnspan=3,
  3222. rowspan=2,
  3223. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  3224. )
  3225. row += 2
  3226. tkinter.Label(
  3227. SCREEN,
  3228. text="【解不等式】",
  3229. bg=bg_color,
  3230. fg=word_color,
  3231. font=FONT,
  3232. width=gui_width * 3,
  3233. height=gui_height,
  3234. ).grid(
  3235. column=column, row=row, columnspan=3
  3236. ) # 设置说明
  3237. row += 1
  3238. tkinter.Button(
  3239. SCREEN,
  3240. bg=buttom_color,
  3241. fg=word_color,
  3242. text="左代数式",
  3243. command=API.add_left_algebra,
  3244. font=FONT,
  3245. width=gui_width,
  3246. height=gui_height,
  3247. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  3248. tkinter.Button(
  3249. SCREEN,
  3250. bg=buttom_color,
  3251. fg=word_color,
  3252. text="右代数式",
  3253. command=API.add_right_algebra,
  3254. font=FONT,
  3255. width=gui_width,
  3256. height=gui_height,
  3257. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  3258. tkinter.Button(
  3259. SCREEN,
  3260. bg=buttom_color,
  3261. fg=word_color,
  3262. text="不等式运算",
  3263. command=API.inequality_solve,
  3264. font=FONT,
  3265. width=gui_width,
  3266. height=gui_height,
  3267. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  3268. row += 1
  3269. inequality_box = tkinter.Listbox(
  3270. SCREEN, width=gui_width * 3, height=gui_height
  3271. ) # 显示代数式
  3272. inequality_box.grid(
  3273. column=column,
  3274. row=row,
  3275. columnspan=3,
  3276. rowspan=1,
  3277. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  3278. )
  3279. row += 1
  3280. inequality_symbol = tkinter.IntVar() # 实数
  3281. lable = ["大于>", "小于<", "大于等于>=", "小于等于<="]
  3282. for i in range(2):
  3283. tkinter.Radiobutton(
  3284. SCREEN,
  3285. command=API.update_inequality_box_gui,
  3286. bg=bg_color,
  3287. fg=word_color,
  3288. activebackground=bg_color,
  3289. activeforeground=word_color,
  3290. selectcolor=bg_color,
  3291. text=lable[i],
  3292. variable=inequality_symbol,
  3293. value=i,
  3294. ).grid(column=column + i, row=row, sticky=tkinter.W)
  3295. row += 1
  3296. for i in range(2):
  3297. i += 2
  3298. tkinter.Radiobutton(
  3299. SCREEN,
  3300. command=API.update_inequality_box_gui,
  3301. bg=bg_color,
  3302. fg=word_color,
  3303. activebackground=bg_color,
  3304. activeforeground=word_color,
  3305. selectcolor=bg_color,
  3306. text=lable[i],
  3307. variable=inequality_symbol,
  3308. value=i,
  3309. ).grid(column=column + i - 2, row=row, sticky=tkinter.W)
  3310. row += 1
  3311. inequality_solution_box = tkinter.Listbox(
  3312. SCREEN, width=gui_width * 3, height=gui_height
  3313. ) # 显示代数式
  3314. inequality_solution_box.grid(
  3315. column=column,
  3316. row=row,
  3317. columnspan=3,
  3318. rowspan=2,
  3319. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  3320. )
  3321. row += 2
  3322. tkinter.Label(
  3323. SCREEN,
  3324. text="【代数式画图】",
  3325. bg=bg_color,
  3326. fg=word_color,
  3327. font=FONT,
  3328. width=gui_width * 3,
  3329. height=gui_height,
  3330. ).grid(
  3331. column=column, row=row, columnspan=3
  3332. ) # 设置说明
  3333. row += 1
  3334. tkinter.Label(
  3335. SCREEN,
  3336. text="符号取值范围:",
  3337. bg=bg_color,
  3338. fg=word_color,
  3339. font=FONT,
  3340. width=gui_width,
  3341. height=gui_height,
  3342. ).grid(
  3343. column=column, row=row
  3344. ) # 设置说明
  3345. range_of_values = tkinter.Entry(SCREEN, width=gui_width + 2)
  3346. range_of_values.grid(column=column + 1, row=row, sticky=tkinter.W)
  3347. tkinter.Button(
  3348. SCREEN,
  3349. bg=buttom_color,
  3350. fg=word_color,
  3351. text="指定符号",
  3352. command=API.add_plot_value,
  3353. font=FONT,
  3354. width=gui_width,
  3355. height=gui_height,
  3356. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  3357. row += 1
  3358. plot_object_box = tkinter.Listbox(
  3359. SCREEN, width=gui_width * 3, height=gui_height
  3360. ) # 显示代数式
  3361. plot_object_box.grid(
  3362. column=column,
  3363. row=row,
  3364. columnspan=3,
  3365. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  3366. )
  3367. row += 1
  3368. plot_type = tkinter.IntVar() # 实数
  3369. lable = ["二维图像", "三维图像"]
  3370. for i in range(2):
  3371. tkinter.Radiobutton(
  3372. SCREEN,
  3373. command=API.update_plot_value_gui,
  3374. bg=bg_color,
  3375. fg=word_color,
  3376. activebackground=bg_color,
  3377. activeforeground=word_color,
  3378. selectcolor=bg_color,
  3379. text=lable[i],
  3380. variable=plot_type,
  3381. value=i,
  3382. ).grid(column=column + i, row=row, sticky=tkinter.W)
  3383. tkinter.Button(
  3384. SCREEN,
  3385. bg=buttom_color,
  3386. fg=word_color,
  3387. text="绘制图像",
  3388. command=API.drawing_image,
  3389. font=FONT,
  3390. width=gui_width,
  3391. height=gui_height,
  3392. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  3393. row += 1
  3394. tkinter.Button(
  3395. SCREEN,
  3396. bg=buttom_color,
  3397. fg=word_color,
  3398. text="绘制代数式",
  3399. command=API.draw_algebra_core,
  3400. font=FONT,
  3401. width=gui_width,
  3402. height=gui_height,
  3403. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  3404. tkinter.Button(
  3405. SCREEN,
  3406. bg=buttom_color,
  3407. fg=word_color,
  3408. text="绘制树状图",
  3409. command=API.show_algebraic,
  3410. font=FONT,
  3411. width=gui_width,
  3412. height=gui_height,
  3413. ).grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  3414. row += 1
  3415. bracket = tkinter.IntVar()
  3416. log_bracket = tkinter.IntVar()
  3417. can_input = tkinter.Entry(SCREEN, width=gui_width)
  3418. can_input.grid(column=column, row=row, sticky=tkinter.W + tkinter.E)
  3419. tkinter.Checkbutton(
  3420. SCREEN,
  3421. bg=bg_color,
  3422. fg=word_color,
  3423. activebackground=bg_color,
  3424. activeforeground=word_color,
  3425. selectcolor=bg_color,
  3426. text="每项绘制括号",
  3427. variable=bracket,
  3428. ).grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.W)
  3429. tkinter.Checkbutton(
  3430. SCREEN,
  3431. bg=bg_color,
  3432. fg=word_color,
  3433. activebackground=bg_color,
  3434. activeforeground=word_color,
  3435. selectcolor=bg_color,
  3436. text="对数绘制括号",
  3437. variable=log_bracket,
  3438. ).grid(column=column + 2, row=row, columnspan=2, sticky=tkinter.W)
  3439. row += 1
  3440. prompt_box = tkinter.Listbox(SCREEN, width=gui_width * 3, height=gui_height) # 显示代数式
  3441. prompt_box.grid(
  3442. column=column,
  3443. row=row,
  3444. columnspan=3,
  3445. rowspan=3,
  3446. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  3447. )