gui.py 104 KB

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