1
0

gui.py 79 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089
  1. import os
  2. import webbrowser
  3. import tkinter
  4. from newtkinter import askopenfilename, asksaveasfilename
  5. import tkinter.messagebox
  6. from tkinter.scrolledtext import ScrolledText
  7. import chardet
  8. import datascience.controller
  9. render_dict = {} # 保存了画图的List
  10. learn_dict = {} # 保存数据处理
  11. PATH = os.getcwd()
  12. sheet_list = []
  13. machine_controller = datascience.controller.MachineLearner()
  14. SCREEN = tkinter.Tk()
  15. bg_color = "#FFFAFA" # 主颜色
  16. buttom_bg_color = "#FFFAFA" # 按钮颜色
  17. word_color = "#000000" # 文字颜色
  18. SCREEN["bg"] = bg_color
  19. FONT = ("黑体", 11) # 设置字体
  20. FONT1 = ("黑体", 13)
  21. SCREEN.title("CoTan数据处理")
  22. SCREEN.resizable(width=False, height=False)
  23. SCREEN.geometry("+10+10") # 设置所在位置
  24. gui_width = 13 # 标准宽度
  25. gui_height = 2
  26. row = 0
  27. column = 0
  28. stored_list = []
  29. clean_list = []
  30. # 层叠多图
  31. base_image = None
  32. top_image = None
  33. # 数据清洗
  34. clean_default_script = """#输入你的数据清洗执行代码
  35. Done_Row=[] #输入操作的行号
  36. Done_Column=[] #输入操作的列号
  37. axis=True #True-操作行,False-操作列
  38. name='' #方法代号
  39. def check(data, row, column, get, R, C): #检查方法
  40. return True
  41. def done(data, row, column, get, R, C): #应用修正方法
  42. return DEL
  43. """
  44. clean_help = """
  45. 使用Python代码进行数据清洗
  46. 1)代码结构
  47. Done_Row=[] 代码用来检测的数据的列号
  48. Done_Column=[] 代码用来检测的数据的行号
  49. 不在以上指定范围内的数据将不会被检测,若为空则整个表格检测
  50. axis 执行删除方法时删除行或者列
  51. name 方法代号
  52. check 检查方法
  53. 输入:当前的值(输入的是一个值而不是一行(列)或整个列表)
  54. 输入:row和column当前值来自的行号(row)和列号(column)
  55. 输入:get当前检查的所有数据:类型是表格
  56. 输入:R和C当前值所来自的行和列的所有数据:类型是一维表格
  57. 输出:输出布尔为True代表该值可以使用,输出布尔为假表示该值不可使用
  58. done 不可使用的数值改造方法
  59. 输入:内容同上
  60. 输出:改造值或者DEL
  61. DEL:代表删除改值所在的行(axis=True)或列(axis=False)
  62. 2)扩展
  63. 默认:pd-pandas,re-re[正则表达式],Sheet-包含所有表格,用Sheet['name']访问名字为name的表格(注意引号别漏了)
  64. 支持:可以使用import导入语句,支持python语法
  65. """
  66. drawing_parameters = """
  67. 输入python变量赋值代码:渲染设置
  68. title #设置标题:str
  69. vice_title #设置副标题:str
  70. show_Legend #是否显示图例:bool
  71. show_Visual_mapping #是否使用视觉映射:bool
  72. is_color_Visual_mapping #是否为颜色视觉映射:bool[否则为大小视觉映射]
  73. min_Visual_mapping #映射的最小值
  74. max_Visual_mapping #映射的最大值
  75. ......(我太懒了, 设置太多不想写了)
  76. """
  77. class UIAPI:
  78. @staticmethod
  79. def add_from_python_gui():
  80. file_dir = askopenfilename(
  81. title="选择载入的py", filetypes=[("Python", ".py"), ("Txt", ".txt")]
  82. )
  83. name = sheet_name.get().replace(" ", "")
  84. if name == "":
  85. name = os.path.splitext(os.path.split(file_dir)[1])[0]
  86. with open(file_dir, "r") as f:
  87. code = f.read()
  88. return code, name
  89. @staticmethod
  90. def get_sheet_name_gui(): # 获得名字统一接口
  91. global sheet_list
  92. try:
  93. return sheet_list[sheet_box.curselection()[0]]
  94. except BaseException:
  95. try:
  96. return sheet_list[0]
  97. except BaseException:
  98. return None
  99. @staticmethod
  100. def update_sheet_box_gui():
  101. global SCREEN, sheet_box, sheet_list
  102. sheet_list = machine_controller.get_sheet_list()
  103. sheet_box.delete(0, tkinter.END)
  104. sheet_box.insert(tkinter.END, *sheet_list)
  105. @staticmethod
  106. def update_combo_box_gui():
  107. overlap_box.delete(0, tkinter.END)
  108. if base_image is not None:
  109. overlap_box.insert(tkinter.END, f"底图: {base_image}")
  110. if top_image is not None:
  111. overlap_box.insert(tkinter.END, f"顶图: {top_image}")
  112. @staticmethod
  113. def add_csv_gui():
  114. file_dir = askopenfilename(title="选择载入的CSV", filetypes=[("CSV", ".csv")])
  115. csv_sep = sep.get()
  116. csv_encoding = encoding.get()
  117. str_ = bool(str_must.get())
  118. index = bool(index_must.get())
  119. name = sheet_name.get().replace(" ", "")
  120. if name == "":
  121. name = os.path.splitext(os.path.split(file_dir)[1])[0]
  122. if csv_encoding == "":
  123. with open(file_dir, "rb") as f:
  124. csv_encoding = chardet.detect(f.read())["encoding"]
  125. if csv_sep == "":
  126. csv_sep = ","
  127. return csv_encoding, csv_sep, file_dir, index, name, str_
  128. @staticmethod
  129. def to_csv_gui():
  130. save_dir = asksaveasfilename(title="选择保存的CSV", filetypes=[("CSV", ".csv")])
  131. csv_sep = sep.get()
  132. return csv_sep, save_dir
  133. @staticmethod
  134. def update_index_box_gui(index):
  135. global SCREEN, index_box
  136. index_box.delete(0, tkinter.END)
  137. index_box.insert(tkinter.END, *index)
  138. @staticmethod
  139. def vitables_gui(data, name):
  140. global bg_color, FONT1
  141. new_top = tkinter.Toplevel(bg=bg_color)
  142. new_top.title(name)
  143. new_top.geometry("+10+10") # 设置所在位置
  144. text = ScrolledText(new_top, font=FONT1, height=50)
  145. text.pack(fill=tkinter.BOTH)
  146. text.insert("0.0", data)
  147. text.config(state=tkinter.DISABLED)
  148. new_top.resizable(width=False, height=False)
  149. @staticmethod
  150. def get_des_bool_gui():
  151. return bool(des_bool.get())
  152. @staticmethod
  153. def sort_by_column_gui():
  154. ascending = not bool(ascending_type.get())
  155. new = bool(ascending_new.get())
  156. return new, ascending
  157. @staticmethod
  158. def add_baseline_gui(ascending_type, sort_by):
  159. ascending = not bool(ascending_type.get())
  160. value = int(sort_by.get())
  161. return ascending, value
  162. @staticmethod
  163. def update_sort_box_gui():
  164. global stored_list, stored_box
  165. re = []
  166. d = {True: "正序", False: "倒叙"}
  167. for i in stored_list:
  168. re.append(f"列号:{i[0]}, 排序方式{d[i[1]]}")
  169. stored_box.delete(0, tkinter.END)
  170. stored_box.insert(tkinter.END, *re)
  171. @staticmethod
  172. def get_stored_box_index_gui():
  173. return stored_box.curselection()[0]
  174. @staticmethod
  175. def get_ascending_new_gui():
  176. new = bool(ascending_new.get())
  177. return new
  178. @staticmethod
  179. def slice_data_gui():
  180. def split_slice_core(slice_list, func_type):
  181. a = []
  182. for i in slice_list:
  183. b = i.get().replace(" ", "")
  184. if b == "":
  185. a.append(None)
  186. else:
  187. try:
  188. a.append(func_type(b))
  189. except BaseException:
  190. a.append(None)
  191. if a[0] is not None and a[1] is None:
  192. a[1] = a[0] + 1
  193. a[2] = None
  194. return a
  195. the_column_type = column_type.get()
  196. is_iloc = True
  197. if the_column_type == 0: # 输入的列号
  198. column = slice(*split_slice_core(column_clist, int))
  199. elif the_column_type == 1:
  200. is_iloc = False
  201. column = slice(*split_slice_core(column_clist, str))
  202. else:
  203. get = column_clist[0].get().replace(" ", "").split(",")
  204. column = []
  205. for i in get:
  206. try:
  207. column.append(int(i))
  208. except BaseException:
  209. pass
  210. the_row_type = row_type.get()
  211. if the_row_type == 0: # 输入的列号
  212. row = slice(*split_slice_core(row_clist, int))
  213. elif the_row_type == 1:
  214. row = slice(*split_slice_core(row_clist, str))
  215. else:
  216. get = row_clist[0].get().replace(" ", "").split(",")
  217. row = []
  218. for i in get:
  219. try:
  220. row.append(int(i))
  221. except BaseException:
  222. pass
  223. new = bool(slice_new.get())
  224. return column, is_iloc, new, row
  225. @staticmethod
  226. def del_data_gui():
  227. column = column_clist[0].get().replace(" ", "").split(",")
  228. row = row_clist[0].get().replace(" ", "").split(",")
  229. new = bool(slice_new.get())
  230. return column, new, row
  231. @staticmethod
  232. def get_clean_code_gui():
  233. exp = clean_code.get("0.0", tkinter.END)
  234. return exp
  235. @staticmethod
  236. def view_cleaning_script_gui():
  237. name = clean_list[API.get_clean_func_box_index_gui()]
  238. API.update_clean_code(machine_controller.get_clean_code(name))
  239. @staticmethod
  240. def get_clean_func_box_index_gui():
  241. return clean_func_box.curselection()[0]
  242. @staticmethod
  243. def show_dictionary_gui():
  244. tkinter.messagebox.showinfo("帮助字典", clean_help)
  245. @staticmethod
  246. def open_python_for_clean_gui():
  247. global clean_code
  248. file_dir = askopenfilename(
  249. title="打开Python脚本", filetypes=[("Python", ".py"), ("TXT", ".txt")]
  250. )
  251. with open(file_dir) as f:
  252. get = f.read()
  253. clean_code.delete("0.0", tkinter.END)
  254. clean_code.insert("0.0", get)
  255. @staticmethod
  256. def reset_clean_code_gui():
  257. global clean_code, clean_default_script
  258. API.update_clean_code(clean_default_script)
  259. @staticmethod
  260. def update_render_box_gui():
  261. global render_dict, render_box, machine_controller
  262. render_dict = machine_controller.get_all_render()
  263. render_box.delete(0, tkinter.END)
  264. render_box.insert(tkinter.END, *render_dict.keys())
  265. @staticmethod
  266. def get_draw_as_well_gui():
  267. return bool(draw_as_well.get())
  268. @staticmethod
  269. def render_box_index_gui():
  270. return render_box.curselection()[0]
  271. @staticmethod
  272. def rendering_one_gui():
  273. render_dir = asksaveasfilename(title="选择渲染保存地址", filetypes=[("HTML", ".html")])
  274. try:
  275. if render_dir[-5:] != ".html":
  276. raise Exception
  277. except BaseException:
  278. render_dir += ".html"
  279. return render_dir
  280. @staticmethod
  281. def rendering_gui():
  282. render_dir = asksaveasfilename(title="选择渲染保存地址", filetypes=[("HTML", ".html")])
  283. try:
  284. if render_dir[-5:] != ".html":
  285. raise Exception
  286. except BaseException:
  287. render_dir += ".html"
  288. return render_dir
  289. @staticmethod
  290. def set_dtype_gui():
  291. type_ = bool(dtype_func.get())
  292. name = API.get_sheet_name_gui()
  293. column_list = dtype_column.get().split(",")
  294. if column_list == [""]:
  295. column_list = []
  296. dtype = dtype_input.get()
  297. wrong = dtype_wrong.get()
  298. return column_list, dtype, name, type_, wrong
  299. @staticmethod
  300. def datetime_index_gui():
  301. is_column = bool(replace_index.get()) # 操作行名-False,操作列名-True
  302. save = bool(replace_type[0].get())
  303. k = ["start", "end", "freq"]
  304. init = {}
  305. for i in range(len(date_input)):
  306. data = date_input[i].get()
  307. if data == "":
  308. continue
  309. init[k[i]] = data
  310. if len(init) == 3:
  311. if bool(date_type.get()): # 使用间隔
  312. del init["end"]
  313. else:
  314. del init["freq"]
  315. return init, is_column, save
  316. @staticmethod
  317. def num_with_name_gui():
  318. is_column = bool(replace_index.get()) # 操作行名-False,操作列名-True
  319. save = bool(replace_type[0].get())
  320. return is_column, save
  321. @staticmethod
  322. def num_to_name_gui():
  323. is_column = bool(replace_index.get()) # 操作行名-False,操作列名-True
  324. save = bool(replace_type[0].get())
  325. return is_column, save
  326. @staticmethod
  327. def change_index_gui():
  328. is_column = bool(replace_index.get()) # 操作行名-False,操作列名-True
  329. iloc = int(replace_iloc.get()) # 替换的列号(行号)
  330. save = bool(replace_type[0].get())
  331. drop = not bool(replace_type[1].get())
  332. return drop, iloc, is_column, save
  333. @staticmethod
  334. def replace_index_func_gui():
  335. the_replace_dict = eval(replace_dict.get())
  336. is_column = bool(replace_index.get()) # 操作行-False,操作列-True
  337. save = bool(replace_type[0].get())
  338. return is_column, save, the_replace_dict
  339. @staticmethod
  340. def update_leaner_box_gui():
  341. global learn_dict, learner_box
  342. learn_dict = machine_controller.return_learner()
  343. learner_box.delete(0, tkinter.END)
  344. learner_box.insert(tkinter.END, *learn_dict.keys())
  345. @staticmethod
  346. def get_data_split_gui():
  347. try:
  348. split = float(data_split.get())
  349. if split < 0 or 1 < split:
  350. raise Exception
  351. except BaseException:
  352. split = 0.3
  353. return split
  354. @staticmethod
  355. def set_learner_gui():
  356. global chose_learner
  357. chose_learner.set(API.get_learner_name_gui(True))
  358. @staticmethod
  359. def get_learner_name_gui(learner_type=False):
  360. global learn_dict, learner_box, chose_learner
  361. if learner_type:
  362. try:
  363. return list(learn_dict.keys())[learner_box.curselection()[0]]
  364. except BaseException:
  365. # raise
  366. try:
  367. return list(learn_dict.keys)[0]
  368. except BaseException:
  369. return None
  370. else:
  371. try:
  372. return chose_learner.get()
  373. except BaseException:
  374. return None
  375. @staticmethod
  376. def askokcancel_gui(messgae):
  377. return tkinter.messagebox.askokcancel("提示", messgae)
  378. @staticmethod
  379. def show_tips_gui():
  380. tkinter.messagebox.showinfo("使用提示", drawing_parameters)
  381. @staticmethod
  382. def show_sorry_gui():
  383. tkinter.messagebox.showinfo("非常抱歉", "高级别的机器学习请到机器学习板块深入研究...")
  384. class API(UIAPI):
  385. @staticmethod
  386. def clear_rendering():
  387. machine_controller.clean_render()
  388. API.update_render_box_gui()
  389. @staticmethod
  390. def del_form():
  391. name = API.get_sheet_name_gui()
  392. machine_controller.del_sheet(name)
  393. API.update_sheet_box_gui()
  394. @staticmethod
  395. def del_learner():
  396. learner = API.get_learner_name_gui(True)
  397. set_learne = API.get_learner_name_gui(False) # 获取学习器Learner
  398. if set_learne != learner:
  399. machine_controller.del_leaner(learner)
  400. API.update_leaner_box_gui()
  401. @staticmethod
  402. def visual_learner():
  403. learner = API.get_learner_name_gui(True)
  404. data = machine_controller.visual_learner(
  405. learner, API.askokcancel_gui(f"是否将数据生成表格。\n(可绘制成散点图对比数据)")
  406. )
  407. API.vitables_gui(
  408. f"对象:{learner}\n\n{data[0]}\n\n\n{data[1]}", f"CoTan数据处理 查看数据:{learner}"
  409. )
  410. API.update_sheet_box_gui()
  411. @staticmethod
  412. def get_learner_config():
  413. return learner_parameters.get("0.0", tkinter.END)
  414. @staticmethod
  415. def test_learner():
  416. name = API.get_sheet_name_gui() # 表格数据
  417. learner = API.get_learner_name_gui()
  418. try:
  419. split = float(data_split.get())
  420. if split < 0 or 1 < split:
  421. raise Exception
  422. except BaseException:
  423. split = 0.3
  424. socore = machine_controller.training_machine(
  425. name, learner, Score_Only=True, split=split
  426. )[1]
  427. tkinter.messagebox.showinfo("测试完成", f"针对测试数据评分结果为:{socore}")
  428. @staticmethod
  429. def predict_learner():
  430. name = API.get_sheet_name_gui() # 表格数据
  431. learner = API.get_learner_name_gui()
  432. data = machine_controller.predict(name, learner)
  433. title = f"CoTan数据处理 表格:{name} 学习器:{learner}"
  434. API.vitables_gui(data, title)
  435. API.update_sheet_box_gui()
  436. @staticmethod
  437. def fit_learner():
  438. name = API.get_sheet_name_gui() # 表格数据
  439. learner = API.get_learner_name_gui()
  440. split = API.get_data_split_gui()
  441. socore = machine_controller.training_machine(
  442. name, learner, parameters=API.get_learner_config(), split=split
  443. )
  444. tkinter.messagebox.showinfo(
  445. "训练完成",
  446. f"针对训练数据({(1 - split) * 100}%)评分结果为:{socore[0]}\n"
  447. f"针对测试数据评分({split * 100}%)结果为:{socore[1]}",
  448. )
  449. @staticmethod
  450. def add_knn_class():
  451. API.add_learner_core("Knn_class")
  452. @staticmethod
  453. def add_logistic_regression():
  454. API.add_learner_core("LogisticRegression")
  455. @staticmethod
  456. def add_lasso():
  457. API.add_learner_core("Lasso")
  458. @staticmethod
  459. def add_knn_regression():
  460. API.add_learner_core("Knn")
  461. @staticmethod
  462. def add_ridge():
  463. API.add_learner_core("Ridge")
  464. @staticmethod
  465. def add_generalized_linear():
  466. API.add_learner_core("Line")
  467. @staticmethod
  468. def add_learner_core(learner_type): # 添加Lenear的核心
  469. machine_controller.add_learner(learner_type, parameters=API.get_learner_config())
  470. API.update_leaner_box_gui()
  471. @staticmethod
  472. def feature_extraction():
  473. name = API.get_sheet_name_gui()
  474. machine_controller.decision_tree_classifier(name)
  475. API.update_sheet_box_gui()
  476. @staticmethod
  477. def replace_index_func():
  478. name = API.get_sheet_name_gui()
  479. is_column, save, the_replace_dict = API.replace_index_func_gui()
  480. machine_controller.replace_index(name, is_column, the_replace_dict, save)
  481. API.update_sheet_box_gui()
  482. @staticmethod
  483. def change_index():
  484. name = API.get_sheet_name_gui() # 名字
  485. drop, iloc, is_column, save = API.change_index_gui()
  486. machine_controller.change_index(name, is_column, iloc, save, drop)
  487. API.update_sheet_box_gui()
  488. @staticmethod
  489. def num_to_name():
  490. name = API.get_sheet_name_gui() # 名字
  491. is_column, save = API.num_to_name_gui()
  492. machine_controller.number_naming(name, is_column, save)
  493. API.update_sheet_box_gui()
  494. @staticmethod
  495. def num_with_name():
  496. name = API.get_sheet_name_gui() # 名字
  497. is_column, save = API.num_with_name_gui()
  498. machine_controller.name_with_number(name, is_column, save)
  499. API.update_sheet_box_gui()
  500. @staticmethod
  501. def datetime_index(is_date=True):
  502. name = API.get_sheet_name_gui() # 名字
  503. init, is_column, save = API.datetime_index_gui()
  504. if is_date:
  505. machine_controller.date_index(name, is_column, save, **init)
  506. else:
  507. machine_controller.time_naming(name, is_column, save, **init)
  508. API.update_sheet_box_gui()
  509. @staticmethod
  510. def date_index():
  511. API.datetime_index(True)
  512. @staticmethod
  513. def time_index():
  514. API.datetime_index(False)
  515. @staticmethod
  516. def set_dtype():
  517. column_list, dtype, name, type_, wrong = API.set_dtype_gui()
  518. if type_: # 软转换
  519. if wrong != "ignore":
  520. wrong = "coerce"
  521. machine_controller.set_dtype(name, column_list, dtype, wrong)
  522. else:
  523. machine_controller.as_dtype(name, column_list, dtype, "ignore")
  524. API.update_sheet_box_gui()
  525. @staticmethod
  526. def python_render(): # 导入绘制方法
  527. file_dir = askopenfilename(
  528. title="打开Python脚本", filetypes=[("Python", ".py"), ("TXT", ".txt")]
  529. )
  530. with open(file_dir) as f:
  531. code = f.read()
  532. API.new_render(machine_controller.custom_graph(code), "自定义图")
  533. @staticmethod
  534. def get_rendering_parameters(): # 获取画图的args
  535. return rendering_parameters.get("0.0", tkinter.END)
  536. @staticmethod
  537. def rendering():
  538. render_dir = API.rendering_gui()
  539. webbrowser.open(
  540. machine_controller.render_all(API.get_rendering_parameters(), render_dir)
  541. )
  542. API.update_render_box_gui()
  543. @staticmethod
  544. def rendering_one():
  545. render_dir = API.rendering_one_gui()
  546. list(render_dict.values())[API.render_box_index_gui()].render(render_dir)
  547. webbrowser.open(render_dir)
  548. API.update_render_box_gui()
  549. @staticmethod
  550. def make_overlap():
  551. global top_image, base_image
  552. if base_image is not None and top_image is not None:
  553. try:
  554. API.new_render(machine_controller.overlap(base_image, top_image), f"合成图")
  555. except BaseException:
  556. raise
  557. base_image = None
  558. top_image = None
  559. API.update_combo_box_gui()
  560. @staticmethod
  561. def add_basemap():
  562. global base_image
  563. base_image = list(render_dict.keys())[API.render_box_index_gui()]
  564. API.update_combo_box_gui()
  565. @staticmethod
  566. def add_top_image():
  567. global top_image
  568. top_image = list(render_dict.keys())[API.render_box_index_gui()]
  569. API.update_combo_box_gui()
  570. @staticmethod
  571. def del_rendering():
  572. key = list(render_dict.keys())[API.render_box_index_gui()]
  573. machine_controller.del_render(key)
  574. API.update_render_box_gui()
  575. @staticmethod
  576. def new_render(c, name):
  577. if API.get_draw_as_well_gui():
  578. c.render(f"{PATH}\\{name}.html")
  579. API.update_render_box_gui()
  580. @staticmethod
  581. def to_geo():
  582. name = API.get_sheet_name_gui()
  583. API.new_render(machine_controller.to_geo(name, API.get_rendering_parameters()), "Geo地图")
  584. @staticmethod
  585. def to_map():
  586. name = API.get_sheet_name_gui()
  587. API.new_render(machine_controller.to_map(name, API.get_rendering_parameters()), "Map地图")
  588. @staticmethod
  589. def to_scattergeo():
  590. name = API.get_sheet_name_gui()
  591. API.new_render(
  592. machine_controller.to_scattergeo(name, API.get_rendering_parameters()), "Geo点地图"
  593. )
  594. @staticmethod
  595. def to_treemap():
  596. name = API.get_sheet_name_gui()
  597. API.new_render(machine_controller.to_tree_map(name, API.get_rendering_parameters()), "矩形树图")
  598. @staticmethod
  599. def to_tree():
  600. name = API.get_sheet_name_gui()
  601. API.new_render(machine_controller.to_tree(name, API.get_rendering_parameters()), "树状图")
  602. @staticmethod
  603. def to_sankey():
  604. name = API.get_sheet_name_gui()
  605. API.new_render(machine_controller.to_sankey(name, API.get_rendering_parameters()), "桑基图")
  606. @staticmethod
  607. def to_sunburst():
  608. name = API.get_sheet_name_gui()
  609. API.new_render(machine_controller.to_sunburst(name, API.get_rendering_parameters()), "旭日图")
  610. @staticmethod
  611. def to_theme_river():
  612. name = API.get_sheet_name_gui()
  613. API.new_render(
  614. machine_controller.to_theme_river(name, API.get_rendering_parameters()), "河流图"
  615. )
  616. @staticmethod
  617. def to_calendar():
  618. name = API.get_sheet_name_gui()
  619. API.new_render(machine_controller.to_calendar(name, API.get_rendering_parameters()), "日历图")
  620. @staticmethod
  621. def to_gauge():
  622. name = API.get_sheet_name_gui()
  623. API.new_render(machine_controller.to_gauge(name, API.get_rendering_parameters()), "仪表图")
  624. @staticmethod
  625. def to_liquid():
  626. name = API.get_sheet_name_gui()
  627. API.new_render(machine_controller.to_liquid(name, API.get_rendering_parameters()), "水球图")
  628. @staticmethod
  629. def to_line3d():
  630. name = API.get_sheet_name_gui()
  631. API.new_render(machine_controller.to_line3d(name, API.get_rendering_parameters()), "3D折线图")
  632. @staticmethod
  633. def to_scatter3d():
  634. name = API.get_sheet_name_gui()
  635. API.new_render(
  636. machine_controller.to_scatter3d(name, API.get_rendering_parameters()), "3D散点图"
  637. )
  638. @staticmethod
  639. def to_bar3d():
  640. name = API.get_sheet_name_gui()
  641. API.new_render(machine_controller.to_bar3d(name, API.get_rendering_parameters()), "3D柱状图")
  642. @staticmethod
  643. def to_word_cloud():
  644. name = API.get_sheet_name_gui()
  645. API.new_render(
  646. machine_controller.to_word_cloud(name, API.get_rendering_parameters()), "词云图"
  647. )
  648. @staticmethod
  649. def to_radar():
  650. name = API.get_sheet_name_gui()
  651. API.new_render(machine_controller.to_radar(name, API.get_rendering_parameters()), "雷达图")
  652. @staticmethod
  653. def to_polar():
  654. name = API.get_sheet_name_gui()
  655. API.new_render(machine_controller.to_polar(name, API.get_rendering_parameters()), "极坐标图")
  656. @staticmethod
  657. def to_pie():
  658. name = API.get_sheet_name_gui()
  659. API.new_render(machine_controller.to_pie(name, API.get_rendering_parameters()), "饼图")
  660. @staticmethod
  661. def to_parallel():
  662. name = API.get_sheet_name_gui()
  663. API.new_render(machine_controller.to_parallel(name, API.get_rendering_parameters()), "多轴图")
  664. @staticmethod
  665. def to_graph():
  666. name = API.get_sheet_name_gui()
  667. API.new_render(machine_controller.to_graph(name, API.get_rendering_parameters()), "关系图")
  668. @staticmethod
  669. def to_format_graph():
  670. name = API.get_sheet_name_gui()
  671. API.new_render(
  672. machine_controller.to_format_graph(name, API.get_rendering_parameters()), "关系图"
  673. )
  674. @staticmethod
  675. def to_funnel():
  676. name = API.get_sheet_name_gui()
  677. API.new_render(machine_controller.to_funnel(name, API.get_rendering_parameters()), "漏斗图")
  678. @staticmethod
  679. def to_heat_map():
  680. name = API.get_sheet_name_gui()
  681. API.new_render(machine_controller.to_heatmap(name, API.get_rendering_parameters()), "热力图")
  682. @staticmethod
  683. def to_boxpolt():
  684. name = API.get_sheet_name_gui()
  685. API.new_render(machine_controller.to_boxpolt(name, API.get_rendering_parameters()), "箱形图")
  686. @staticmethod
  687. def to_pictorialbar():
  688. name = API.get_sheet_name_gui()
  689. API.new_render(
  690. machine_controller.to_pictorialbar(name, API.get_rendering_parameters()), "象形柱状图"
  691. )
  692. @staticmethod
  693. def to_scatter():
  694. name = API.get_sheet_name_gui()
  695. API.new_render(machine_controller.to_scatter(name, API.get_rendering_parameters()), "散点图")
  696. @staticmethod
  697. def to_line():
  698. name = API.get_sheet_name_gui()
  699. API.new_render(machine_controller.to_line(name, API.get_rendering_parameters()), "折线图")
  700. @staticmethod
  701. def to_bar():
  702. name = API.get_sheet_name_gui()
  703. API.new_render(machine_controller.to_bar(name, API.get_rendering_parameters()), "柱状图")
  704. @staticmethod
  705. def update_clean_code(clean_default_script):
  706. clean_code.delete("0.0", tkinter.END)
  707. clean_code.insert("0.0", clean_default_script)
  708. @staticmethod
  709. def empty_cleaning_script():
  710. machine_controller.del_all_clean_func()
  711. API.update_sheet_box_gui()
  712. @staticmethod
  713. def execute_cleaning_script():
  714. name = API.get_sheet_name_gui()
  715. data = machine_controller.data_clean(name)
  716. title = f"CoTan数据处理 表格:{name}.数据清洗"
  717. API.vitables_gui(data, title)
  718. API.update_sheet_box_gui()
  719. @staticmethod
  720. def del_cleaning_script():
  721. name = clean_list[API.get_clean_func_box_index_gui()]
  722. machine_controller.del_clean_func(name)
  723. API.update_cleaning_script_box()
  724. @staticmethod
  725. def update_cleaning_script_box():
  726. clean_list = machine_controller.get_clean_func()
  727. clean_func_box.delete(0, tkinter.END)
  728. clean_func_box.insert(tkinter.END, *clean_list)
  729. @staticmethod
  730. def add_cleaning_script():
  731. exp = API.get_clean_code_gui()
  732. machine_controller.add_clean_func(exp)
  733. API.update_cleaning_script_box()
  734. @staticmethod
  735. def clean_nan_row():
  736. name = API.get_sheet_name_gui()
  737. data = machine_controller.del_nan(name, True)
  738. title = f"CoTan数据处理 表格:{name}.NaN"
  739. API.vitables_gui(data, title)
  740. API.update_sheet_box_gui()
  741. @staticmethod
  742. def is_nan():
  743. name = API.get_sheet_name_gui()
  744. data = machine_controller.is_nan(name)
  745. title = f"CoTan数据处理 表格:{name}.NaN"
  746. API.vitables_gui(data, title)
  747. API.update_sheet_box_gui()
  748. @staticmethod
  749. def to_bool():
  750. the_bool_exp = bool_exp.get()
  751. name = API.get_sheet_name_gui()
  752. data = machine_controller.to_bool(name, the_bool_exp, True)
  753. title = f"CoTan数据处理 表格:{name} 布尔化"
  754. API.vitables_gui(data, title)
  755. API.update_sheet_box_gui()
  756. @staticmethod
  757. def del_data():
  758. name = API.get_sheet_name_gui()
  759. column, new, row = API.del_data_gui()
  760. try:
  761. data = machine_controller.del_slice(name, column, row, new)
  762. except BaseException:
  763. data = "None 你的操作不被允许"
  764. title = f"CoTan数据处理 表格:{name}"
  765. API.vitables_gui(data, title)
  766. API.update_sheet_box_gui()
  767. @staticmethod
  768. def slice_data():
  769. column, is_iloc, new, row = API.slice_data_gui()
  770. name = API.get_sheet_name_gui()
  771. try:
  772. data = machine_controller.get_slice(name, column, row, is_iloc, new)
  773. except BaseException:
  774. data = "None 你的操作不被允许"
  775. title = f"CoTan数据处理 表格:{name}"
  776. API.vitables_gui(data, title)
  777. API.update_sheet_box_gui()
  778. @staticmethod
  779. def sample_data():
  780. name = API.get_sheet_name_gui()
  781. new = API.get_ascending_new_gui()
  782. data = machine_controller.sample(name, new)
  783. title = f"CoTan数据处理 打乱表格:{name}"
  784. API.vitables_gui(data, title)
  785. API.update_sheet_box_gui()
  786. @staticmethod
  787. def stored_value():
  788. name = API.get_sheet_name_gui()
  789. new = API.get_ascending_new_gui()
  790. data = machine_controller.stored_value(name, stored_list, new)
  791. title = f"CoTan数据处理 表格:{name}.Stored"
  792. API.vitables_gui(data, title)
  793. API.update_sheet_box_gui()
  794. @staticmethod
  795. def del_baseline():
  796. global stored_list, stored_box
  797. del stored_list[API.get_stored_box_index_gui()]
  798. API.update_sort_box_gui()
  799. @staticmethod
  800. def add_baseline(): # 按基准列排行
  801. try:
  802. ascending, value = API.add_baseline_gui(ascending_type, sort_by)
  803. stored_list.append((value, ascending))
  804. except BaseException:
  805. pass
  806. API.update_sort_box_gui()
  807. @staticmethod
  808. def sort_by_column(): # 行
  809. name = API.get_sheet_name_gui()
  810. new, ascending = API.sort_by_column_gui()
  811. data = machine_controller.sorted_index(name, False, new, ascending)
  812. title = f"CoTan数据处理 表格:{name}.Stored by Column"
  813. API.vitables_gui(data, title)
  814. API.update_sheet_box_gui()
  815. @staticmethod
  816. def sort_by_tow(): # 行
  817. name = API.get_sheet_name_gui()
  818. new, ascending = API.sort_by_column_gui()
  819. data = machine_controller.sorted_index(name, True, new, ascending)
  820. title = f"CoTan数据处理 表格:{name}.Stored by Row"
  821. API.vitables_gui(data, title)
  822. API.update_sheet_box_gui()
  823. @staticmethod
  824. def transpose():
  825. name = API.get_sheet_name_gui()
  826. new = API.get_ascending_new_gui()
  827. data = machine_controller.transpose(name, new)
  828. title = f"CoTan数据处理 表格:{name}.T"
  829. API.vitables_gui(data, title)
  830. API.update_sheet_box_gui()
  831. @staticmethod
  832. def show_report():
  833. if not API.askokcancel_gui(f"是否统计数据,大量的数据需要耗费一定的时间(确定后,系统会在后台统计)"):
  834. raise Exception
  835. report_dir = f"{PATH}/$Show_Des_Sheet.html"
  836. try:
  837. name = API.get_sheet_name_gui()
  838. if name is None:
  839. raise Exception
  840. machine_controller.to_report(name, report_dir)
  841. webbrowser.open(report_dir)
  842. except BaseException:
  843. pass
  844. @staticmethod
  845. def show_describe():
  846. describe = API.get_des_bool_gui()
  847. name = API.get_sheet_name_gui()
  848. title = f"CoTan数据处理 表格:{name}_describe"
  849. data = str(machine_controller.describe(name, describe))
  850. API.vitables_gui(data, title)
  851. API.update_sheet_box_gui()
  852. @staticmethod
  853. def show_sheet():
  854. name = API.get_sheet_name_gui()
  855. title = f"CoTan数据处理 表格:{name}"
  856. data = str(machine_controller.get_sheet(name))
  857. API.vitables_gui(data, title)
  858. @staticmethod
  859. def get_column(): # 列名(横行竖列,列名是上面的)
  860. name = API.get_sheet_name_gui()
  861. API.update_index_box_gui(machine_controller.get_column(name))
  862. @staticmethod
  863. def get_row(): # 行名(横行竖列,行名左)
  864. name = API.get_sheet_name_gui()
  865. API.update_index_box_gui(machine_controller.get_index(name))
  866. @staticmethod
  867. def show_one_sheet_html():
  868. global PATH, to_html_type
  869. html_dir = f"{PATH}/$Show_Sheet.html"
  870. try:
  871. name = API.get_sheet_name_gui()
  872. if name is None:
  873. raise Exception
  874. machine_controller.render_html_one(name, html_dir)
  875. webbrowser.open(html_dir)
  876. except BaseException:
  877. pass
  878. @staticmethod
  879. def show_sheet_html():
  880. global PATH, to_html_type
  881. html_dir = f"{PATH}/$Show_Sheet.html"
  882. try:
  883. name = API.get_sheet_name_gui()
  884. if name is None:
  885. raise Exception
  886. machine_controller.render_html_all(name, html_dir, to_html_type.get())
  887. webbrowser.open(html_dir)
  888. except BaseException:
  889. pass
  890. @staticmethod
  891. def to_csv():
  892. global SCREEN, sep, encoding, str_must, index_must
  893. csv_sep, save_dir = API.to_csv_gui()
  894. name = API.get_sheet_name_gui()
  895. machine_controller.to_csv(name, save_dir, csv_sep)
  896. API.update_sheet_box_gui()
  897. @staticmethod
  898. def add_csv():
  899. global SCREEN, sep, encoding, str_must, index_must, sheet_name
  900. csv_encoding, csv_sep, file_dir, index, name, str_ = API.add_csv_gui()
  901. machine_controller.add_csv(file_dir, name, csv_sep, csv_encoding, str_, index)
  902. API.update_sheet_box_gui()
  903. @staticmethod
  904. def add_from_python():
  905. global SCREEN, sep, encoding, str_must, index_must
  906. code, name = API.add_from_python_gui()
  907. machine_controller.add_python(code, name)
  908. API.update_sheet_box_gui()
  909. def machine_learning():
  910. global SCREEN
  911. SCREEN.mainloop()
  912. tkinter.Button(
  913. SCREEN,
  914. bg=buttom_bg_color,
  915. fg=word_color,
  916. text="导入CSV",
  917. command=API.add_csv,
  918. font=FONT,
  919. width=gui_width,
  920. height=gui_height,
  921. ).grid(
  922. column=column,
  923. row=row,
  924. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  925. )
  926. tkinter.Button(
  927. SCREEN,
  928. bg=buttom_bg_color,
  929. fg=word_color,
  930. text="导入Py",
  931. command=API.add_from_python,
  932. font=FONT,
  933. width=gui_width,
  934. height=gui_height,
  935. ).grid(
  936. column=column + 1,
  937. row=row,
  938. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  939. )
  940. tkinter.Button(
  941. SCREEN,
  942. bg=buttom_bg_color,
  943. fg=word_color,
  944. text="导出CSV",
  945. command=API.to_csv,
  946. font=FONT,
  947. width=gui_width,
  948. height=gui_height,
  949. ).grid(
  950. column=column + 2,
  951. row=row,
  952. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  953. )
  954. row += 1
  955. tkinter.Label(
  956. SCREEN,
  957. text="表格名称:",
  958. bg=bg_color,
  959. fg=word_color,
  960. font=FONT,
  961. width=gui_width,
  962. height=gui_height,
  963. ).grid(
  964. column=column, row=row
  965. ) # 设置说明
  966. sheet_name = tkinter.Entry(SCREEN, width=gui_width)
  967. sheet_name.grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  968. row += 1
  969. tkinter.Button(
  970. SCREEN,
  971. bg=buttom_bg_color,
  972. fg=word_color,
  973. text="删除表格",
  974. command=API.del_form,
  975. font=FONT,
  976. width=gui_width,
  977. height=gui_height,
  978. ).grid(
  979. column=column,
  980. row=row,
  981. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  982. )
  983. tkinter.Button(
  984. SCREEN,
  985. bg=buttom_bg_color,
  986. fg=word_color,
  987. text="查看表格",
  988. command=API.show_sheet_html,
  989. font=FONT,
  990. width=gui_width,
  991. height=gui_height,
  992. ).grid(
  993. column=column + 1,
  994. row=row,
  995. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  996. )
  997. tkinter.Button(
  998. SCREEN,
  999. bg=buttom_bg_color,
  1000. fg=word_color,
  1001. text="查看单一表格",
  1002. command=API.show_one_sheet_html,
  1003. font=FONT,
  1004. width=gui_width,
  1005. height=gui_height,
  1006. ).grid(
  1007. column=column + 2,
  1008. row=row,
  1009. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1010. )
  1011. row += 1
  1012. to_html_type = tkinter.IntVar() # 正,负,0
  1013. lable = ["选项卡型", "可移动型", "自适应型"] # 复选框
  1014. for i in range(3):
  1015. tkinter.Radiobutton(
  1016. SCREEN,
  1017. bg=bg_color,
  1018. fg=word_color,
  1019. activebackground=bg_color,
  1020. activeforeground=word_color,
  1021. selectcolor=bg_color,
  1022. text=lable[i],
  1023. variable=to_html_type,
  1024. value=i,
  1025. ).grid(column=column + i, row=row, sticky=tkinter.W)
  1026. str_must = tkinter.IntVar()
  1027. index_must = tkinter.IntVar()
  1028. row += 1
  1029. tkinter.Label(
  1030. SCREEN,
  1031. text="编码方式:",
  1032. bg=bg_color,
  1033. fg=word_color,
  1034. font=FONT,
  1035. width=gui_width,
  1036. height=gui_height,
  1037. ).grid(
  1038. column=column, row=row
  1039. ) # 设置说明
  1040. encoding = tkinter.Entry(SCREEN, width=gui_width)
  1041. encoding.grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  1042. buttom = tkinter.Checkbutton(
  1043. SCREEN,
  1044. bg=bg_color,
  1045. fg=word_color,
  1046. activebackground=bg_color,
  1047. activeforeground=word_color,
  1048. selectcolor=bg_color,
  1049. text="字符串类型",
  1050. variable=str_must,
  1051. )
  1052. buttom.grid(column=column + 2, row=row, sticky=tkinter.W)
  1053. row += 1
  1054. tkinter.Label(
  1055. SCREEN,
  1056. text="CSV分隔符:",
  1057. bg=bg_color,
  1058. fg=word_color,
  1059. font=FONT,
  1060. width=gui_width,
  1061. height=gui_height,
  1062. ).grid(
  1063. column=column, row=row
  1064. ) # 设置说明
  1065. sep = tkinter.Entry(SCREEN, width=gui_width)
  1066. sep.grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  1067. tkinter.Checkbutton(
  1068. SCREEN,
  1069. bg=bg_color,
  1070. fg=word_color,
  1071. activebackground=bg_color,
  1072. activeforeground=word_color,
  1073. selectcolor=bg_color,
  1074. text="重置列名",
  1075. variable=index_must,
  1076. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  1077. row += 1
  1078. sheet_box = tkinter.Listbox(SCREEN, width=gui_width * 3, height=gui_height * 5) # 显示符号
  1079. sheet_box.grid(
  1080. column=column,
  1081. row=row,
  1082. columnspan=3,
  1083. rowspan=5,
  1084. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  1085. )
  1086. row += 5
  1087. tkinter.Button(
  1088. SCREEN,
  1089. bg=buttom_bg_color,
  1090. fg=word_color,
  1091. text="查看行名",
  1092. command=API.get_row,
  1093. font=FONT,
  1094. width=gui_width,
  1095. height=gui_height,
  1096. ).grid(
  1097. column=column,
  1098. row=row,
  1099. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1100. )
  1101. tkinter.Button(
  1102. SCREEN,
  1103. bg=buttom_bg_color,
  1104. fg=word_color,
  1105. text="查看列名",
  1106. command=API.get_column,
  1107. font=FONT,
  1108. width=gui_width,
  1109. height=gui_height,
  1110. ).grid(
  1111. column=column + 1,
  1112. row=row,
  1113. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1114. )
  1115. tkinter.Button(
  1116. SCREEN,
  1117. bg=buttom_bg_color,
  1118. fg=word_color,
  1119. text="显示表格",
  1120. command=API.show_sheet,
  1121. font=FONT,
  1122. width=gui_width,
  1123. height=gui_height,
  1124. ).grid(
  1125. column=column + 2,
  1126. row=row,
  1127. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1128. )
  1129. row += 1
  1130. tkinter.Label(
  1131. SCREEN,
  1132. text="最大显示行数:",
  1133. bg=bg_color,
  1134. fg=word_color,
  1135. font=FONT,
  1136. width=gui_width,
  1137. height=gui_height,
  1138. ).grid(
  1139. column=column, row=row
  1140. ) # 设置说明
  1141. max_row = tkinter.Entry(SCREEN, width=gui_width * 2)
  1142. max_row.grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  1143. row += 1
  1144. tkinter.Label(
  1145. SCREEN,
  1146. text="最大显示列数:",
  1147. bg=bg_color,
  1148. fg=word_color,
  1149. font=FONT,
  1150. width=gui_width,
  1151. height=gui_height,
  1152. ).grid(
  1153. column=column, row=row
  1154. ) # 设置说明
  1155. max_column = tkinter.Entry(SCREEN, width=gui_width * 2)
  1156. max_column.grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  1157. # Row与Column Row是横行,tkinter布局中Row变大,表示所在行数变大,向下移动如:
  1158. # 1,2,3,4,5,6
  1159. # 7,8,9,a,b,c
  1160. # 其中数字1-6是第一行,1-c是第二行,第二行在第一行下面,row变大向下移动(Row是横向行而不是横向移动) to 搞不清楚横行竖列的人
  1161. row += 1
  1162. index_box = tkinter.Listbox(SCREEN, width=gui_width * 3, height=gui_height * 10) # 显示符号
  1163. index_box.grid(
  1164. column=column,
  1165. row=row,
  1166. columnspan=3,
  1167. rowspan=10,
  1168. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  1169. )
  1170. row += 10
  1171. tkinter.Button(
  1172. SCREEN,
  1173. bg=buttom_bg_color,
  1174. fg=word_color,
  1175. text="查看数据分析",
  1176. command=API.show_report,
  1177. font=FONT,
  1178. width=gui_width,
  1179. height=gui_height,
  1180. ).grid(
  1181. column=column,
  1182. row=row,
  1183. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1184. )
  1185. tkinter.Button(
  1186. SCREEN,
  1187. bg=buttom_bg_color,
  1188. fg=word_color,
  1189. text="简单数据统计",
  1190. command=API.show_describe,
  1191. font=FONT,
  1192. width=gui_width,
  1193. height=gui_height,
  1194. ).grid(
  1195. column=column + 1,
  1196. row=row,
  1197. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1198. )
  1199. des_bool = tkinter.IntVar() # 是否启用
  1200. tkinter.Checkbutton(
  1201. SCREEN,
  1202. bg=bg_color,
  1203. fg=word_color,
  1204. activebackground=bg_color,
  1205. activeforeground=word_color,
  1206. selectcolor=bg_color,
  1207. text="生成统计表格",
  1208. variable=des_bool,
  1209. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  1210. column += 3
  1211. tkinter.Label(SCREEN, text="", bg=bg_color, fg=word_color, font=FONT, width=1).grid(
  1212. column=column, row=row
  1213. ) # 设置说明
  1214. column += 1
  1215. row = 0
  1216. tkinter.Label(
  1217. SCREEN,
  1218. text="【数据清洗】",
  1219. bg=bg_color,
  1220. fg=word_color,
  1221. font=FONT,
  1222. width=gui_width * 3,
  1223. height=gui_height,
  1224. ).grid(
  1225. column=column,
  1226. columnspan=3,
  1227. row=row,
  1228. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1229. ) # 设置说明
  1230. column_clist = []
  1231. row_clist = []
  1232. label = ["启始(列号):", "终止(列):", "间隔(列):"]
  1233. for i in range(3):
  1234. row += 1
  1235. tkinter.Label(
  1236. SCREEN,
  1237. text=label[i],
  1238. bg=bg_color,
  1239. fg=word_color,
  1240. font=FONT,
  1241. width=gui_width,
  1242. height=gui_height,
  1243. ).grid(
  1244. column=column, row=row
  1245. ) # 设置说明
  1246. column_clist.append(tkinter.Entry(SCREEN, width=gui_width * 2))
  1247. column_clist[-1].grid(
  1248. column=column + 1, row=row, columnspan=2, sticky=tkinter.W + tkinter.E
  1249. )
  1250. label = ["启始(行号):", "终止(行):", "间隔(行):"]
  1251. for i in range(3):
  1252. row += 1
  1253. tkinter.Label(
  1254. SCREEN,
  1255. text=label[i],
  1256. bg=bg_color,
  1257. fg=word_color,
  1258. font=FONT,
  1259. width=gui_width,
  1260. height=gui_height,
  1261. ).grid(
  1262. column=column, row=row
  1263. ) # 设置说明
  1264. row_clist.append(tkinter.Entry(SCREEN, width=gui_width * 2))
  1265. row_clist[-1].grid(
  1266. column=column + 1, row=row, columnspan=2, sticky=tkinter.W + tkinter.E
  1267. )
  1268. row += 1
  1269. column_type = tkinter.IntVar()
  1270. lable = ["根据列号", "根据列名", "输入列号"] # 复选框
  1271. for i in range(3):
  1272. tkinter.Radiobutton(
  1273. SCREEN,
  1274. bg=bg_color,
  1275. fg=word_color,
  1276. activebackground=bg_color,
  1277. activeforeground=word_color,
  1278. selectcolor=bg_color,
  1279. text=lable[i],
  1280. variable=column_type,
  1281. value=i,
  1282. ).grid(column=column + i, row=row, sticky=tkinter.W)
  1283. row += 1
  1284. row_type = tkinter.IntVar()
  1285. lable = ["根据行号", "根据行名", "输入行号"] # 复选框
  1286. for i in range(3):
  1287. tkinter.Radiobutton(
  1288. SCREEN,
  1289. bg=bg_color,
  1290. fg=word_color,
  1291. activebackground=bg_color,
  1292. activeforeground=word_color,
  1293. selectcolor=bg_color,
  1294. text=lable[i],
  1295. variable=row_type,
  1296. value=i,
  1297. ).grid(column=column + i, row=row, sticky=tkinter.W)
  1298. row += 1
  1299. slice_new = tkinter.IntVar()
  1300. tkinter.Button(
  1301. SCREEN,
  1302. bg=buttom_bg_color,
  1303. fg=word_color,
  1304. text="切片选定",
  1305. command=API.slice_data,
  1306. font=FONT,
  1307. width=gui_width,
  1308. height=gui_height,
  1309. ).grid(
  1310. column=column,
  1311. row=row,
  1312. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1313. )
  1314. tkinter.Button(
  1315. SCREEN,
  1316. bg=buttom_bg_color,
  1317. fg=word_color,
  1318. text="删除选定",
  1319. command=API.del_data,
  1320. font=FONT,
  1321. width=gui_width,
  1322. height=gui_height,
  1323. ).grid(
  1324. column=column + 1,
  1325. row=row,
  1326. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1327. )
  1328. tkinter.Checkbutton(
  1329. SCREEN,
  1330. bg=bg_color,
  1331. fg=word_color,
  1332. activebackground=bg_color,
  1333. activeforeground=word_color,
  1334. selectcolor=bg_color,
  1335. text="生成新表格",
  1336. variable=slice_new,
  1337. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  1338. row += 1
  1339. tkinter.Label(
  1340. SCREEN,
  1341. text="布尔逻辑:",
  1342. bg=bg_color,
  1343. fg=word_color,
  1344. font=FONT,
  1345. width=gui_width,
  1346. height=gui_height,
  1347. ).grid(
  1348. column=column,
  1349. row=row,
  1350. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1351. ) # 设置说明
  1352. bool_exp = tkinter.Entry(SCREEN, width=gui_width * 2)
  1353. bool_exp.grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.W + tkinter.E)
  1354. row += 1
  1355. tkinter.Label(
  1356. SCREEN,
  1357. text="操作的列号:",
  1358. bg=bg_color,
  1359. fg=word_color,
  1360. font=FONT,
  1361. width=gui_width,
  1362. height=gui_height,
  1363. ).grid(
  1364. column=column,
  1365. row=row,
  1366. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1367. ) # 设置说明
  1368. drop_column = tkinter.Entry(SCREEN, width=gui_width * 2)
  1369. drop_column.grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.W + tkinter.E)
  1370. row += 1
  1371. tkinter.Button(
  1372. SCREEN,
  1373. bg=buttom_bg_color,
  1374. fg=word_color,
  1375. text="生成布尔表格",
  1376. command=API.to_bool,
  1377. font=FONT,
  1378. width=gui_width,
  1379. height=gui_height,
  1380. ).grid(
  1381. column=column,
  1382. row=row,
  1383. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1384. )
  1385. tkinter.Button(
  1386. SCREEN,
  1387. bg=buttom_bg_color,
  1388. fg=word_color,
  1389. text="查看空值",
  1390. command=API.is_nan,
  1391. font=FONT,
  1392. width=gui_width,
  1393. height=gui_height,
  1394. ).grid(
  1395. column=column + 1,
  1396. row=row,
  1397. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1398. )
  1399. tkinter.Button(
  1400. SCREEN,
  1401. bg=buttom_bg_color,
  1402. fg=word_color,
  1403. text="清洗空值(按行)",
  1404. command=API.clean_nan_row,
  1405. font=FONT,
  1406. width=gui_width,
  1407. height=gui_height,
  1408. ).grid(
  1409. column=column + 2,
  1410. row=row,
  1411. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1412. )
  1413. row += 1
  1414. tkinter.Button(
  1415. SCREEN,
  1416. bg=buttom_bg_color,
  1417. fg=word_color,
  1418. text="添加执行方法",
  1419. command=API.add_cleaning_script,
  1420. font=FONT,
  1421. width=gui_width,
  1422. height=gui_height,
  1423. ).grid(
  1424. column=column,
  1425. row=row,
  1426. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1427. )
  1428. tkinter.Button(
  1429. SCREEN,
  1430. bg=buttom_bg_color,
  1431. fg=word_color,
  1432. text="删除执行方法",
  1433. command=API.del_cleaning_script,
  1434. font=FONT,
  1435. width=gui_width,
  1436. height=gui_height,
  1437. ).grid(
  1438. column=column + 1,
  1439. row=row,
  1440. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1441. )
  1442. tkinter.Button(
  1443. SCREEN,
  1444. bg=buttom_bg_color,
  1445. fg=word_color,
  1446. text="数据特征提取",
  1447. command=API.feature_extraction,
  1448. font=FONT,
  1449. width=gui_width,
  1450. height=gui_height,
  1451. ).grid(
  1452. column=column + 2,
  1453. row=row,
  1454. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1455. )
  1456. row += 1
  1457. clean_func_box = tkinter.Listbox(SCREEN, width=gui_width * 3, height=gui_height * 2)
  1458. clean_func_box.grid(
  1459. column=column,
  1460. row=row,
  1461. columnspan=3,
  1462. rowspan=2,
  1463. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  1464. )
  1465. row += 2
  1466. tkinter.Button(
  1467. SCREEN,
  1468. bg=buttom_bg_color,
  1469. fg=word_color,
  1470. text="查看词典",
  1471. command=API.show_dictionary_gui,
  1472. font=FONT,
  1473. width=gui_width,
  1474. height=gui_height,
  1475. ).grid(
  1476. column=column,
  1477. row=row,
  1478. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1479. )
  1480. tkinter.Button(
  1481. SCREEN,
  1482. bg=buttom_bg_color,
  1483. fg=word_color,
  1484. text="恢复显示",
  1485. command=API.reset_clean_code_gui,
  1486. font=FONT,
  1487. width=gui_width,
  1488. height=gui_height,
  1489. ).grid(
  1490. column=column + 1,
  1491. row=row,
  1492. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1493. )
  1494. tkinter.Button(
  1495. SCREEN,
  1496. bg=buttom_bg_color,
  1497. fg=word_color,
  1498. text="执行数据清洗",
  1499. command=API.execute_cleaning_script,
  1500. font=FONT,
  1501. width=gui_width,
  1502. height=gui_height,
  1503. ).grid(
  1504. column=column + 2,
  1505. row=row,
  1506. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1507. )
  1508. row += 1
  1509. clean_code = tkinter.Text(SCREEN, width=gui_width * 3, height=gui_height * 7)
  1510. clean_code.grid(
  1511. column=column,
  1512. row=row,
  1513. columnspan=3,
  1514. rowspan=7,
  1515. sticky=tkinter.E + tkinter.W + tkinter.N + tkinter.S,
  1516. )
  1517. clean_code.insert("0.0", clean_default_script)
  1518. row += 7
  1519. tkinter.Button(
  1520. SCREEN,
  1521. bg=buttom_bg_color,
  1522. fg=word_color,
  1523. text="清空执行方法",
  1524. command=API.empty_cleaning_script,
  1525. font=FONT,
  1526. width=gui_width,
  1527. height=gui_height,
  1528. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  1529. tkinter.Button(
  1530. SCREEN,
  1531. bg=buttom_bg_color,
  1532. fg=word_color,
  1533. text="查看执行方法",
  1534. command=API.view_cleaning_script_gui,
  1535. font=FONT,
  1536. width=gui_width,
  1537. height=gui_height,
  1538. ).grid(
  1539. column=column + 1,
  1540. row=row,
  1541. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1542. )
  1543. tkinter.Button(
  1544. SCREEN,
  1545. bg=buttom_bg_color,
  1546. fg=word_color,
  1547. text="导入执行方法",
  1548. command=API.open_python_for_clean_gui,
  1549. font=FONT,
  1550. width=gui_width,
  1551. height=gui_height,
  1552. ).grid(
  1553. column=column + 2,
  1554. row=row,
  1555. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1556. )
  1557. column += 3
  1558. tkinter.Label(SCREEN, text="", bg=bg_color, fg=word_color, font=FONT, width=1).grid(
  1559. column=column, row=row
  1560. ) # 设置说明
  1561. column += 1
  1562. row = 0
  1563. tkinter.Label(
  1564. SCREEN,
  1565. text="【数据可视化】",
  1566. bg=bg_color,
  1567. fg=word_color,
  1568. font=FONT,
  1569. width=gui_width * 3,
  1570. height=gui_height,
  1571. ).grid(
  1572. column=column,
  1573. columnspan=3,
  1574. row=row,
  1575. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1576. ) # 设置说明
  1577. row += 1
  1578. tkinter.Button(
  1579. SCREEN,
  1580. bg=buttom_bg_color,
  1581. fg=word_color,
  1582. text="生成柱状图",
  1583. command=API.to_bar,
  1584. font=FONT,
  1585. width=gui_width,
  1586. height=gui_height,
  1587. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  1588. tkinter.Button(
  1589. SCREEN,
  1590. bg=buttom_bg_color,
  1591. fg=word_color,
  1592. text="生成3D柱状图",
  1593. command=API.to_bar3d,
  1594. font=FONT,
  1595. width=gui_width,
  1596. height=gui_height,
  1597. ).grid(
  1598. column=column + 1,
  1599. row=row,
  1600. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1601. )
  1602. tkinter.Button(
  1603. SCREEN,
  1604. bg=buttom_bg_color,
  1605. fg=word_color,
  1606. text="生成折线图",
  1607. command=API.to_line,
  1608. font=FONT,
  1609. width=gui_width,
  1610. height=gui_height,
  1611. ).grid(
  1612. column=column + 2,
  1613. row=row,
  1614. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1615. )
  1616. row += 1
  1617. tkinter.Button(
  1618. SCREEN,
  1619. bg=buttom_bg_color,
  1620. fg=word_color,
  1621. text="生成3D折线图",
  1622. command=API.to_line3d,
  1623. font=FONT,
  1624. width=gui_width,
  1625. height=gui_height,
  1626. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  1627. tkinter.Button(
  1628. SCREEN,
  1629. bg=buttom_bg_color,
  1630. fg=word_color,
  1631. text="生成象形柱状图",
  1632. command=API.to_pictorialbar,
  1633. font=FONT,
  1634. width=gui_width,
  1635. height=gui_height,
  1636. ).grid(
  1637. column=column + 1,
  1638. row=row,
  1639. columnspan=2,
  1640. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  1641. )
  1642. row += 1
  1643. tkinter.Button(
  1644. SCREEN,
  1645. bg=buttom_bg_color,
  1646. fg=word_color,
  1647. text="生成散点图",
  1648. command=API.to_scatter,
  1649. font=FONT,
  1650. width=gui_width,
  1651. height=gui_height,
  1652. ).grid(
  1653. column=column,
  1654. row=row,
  1655. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1656. )
  1657. tkinter.Button(
  1658. SCREEN,
  1659. bg=buttom_bg_color,
  1660. fg=word_color,
  1661. text="生成3D散点图",
  1662. command=API.to_scatter3d,
  1663. font=FONT,
  1664. width=gui_width,
  1665. height=gui_height,
  1666. ).grid(
  1667. column=column + 1,
  1668. row=row,
  1669. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1670. )
  1671. tkinter.Button(
  1672. SCREEN,
  1673. bg=buttom_bg_color,
  1674. fg=word_color,
  1675. text="生成箱形图",
  1676. command=API.to_boxpolt,
  1677. font=FONT,
  1678. width=gui_width,
  1679. height=gui_height,
  1680. ).grid(
  1681. column=column + 2,
  1682. row=row,
  1683. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1684. )
  1685. row += 1
  1686. tkinter.Button(
  1687. SCREEN,
  1688. bg=buttom_bg_color,
  1689. fg=word_color,
  1690. text="生成漏斗图",
  1691. command=API.to_funnel,
  1692. font=FONT,
  1693. width=gui_width,
  1694. height=gui_height,
  1695. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  1696. tkinter.Button(
  1697. SCREEN,
  1698. bg=buttom_bg_color,
  1699. fg=word_color,
  1700. text="生成热力图",
  1701. command=API.to_heat_map,
  1702. font=FONT,
  1703. width=gui_width,
  1704. height=gui_height,
  1705. ).grid(
  1706. column=column + 1,
  1707. row=row,
  1708. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1709. )
  1710. tkinter.Button(
  1711. SCREEN,
  1712. bg=buttom_bg_color,
  1713. fg=word_color,
  1714. text="生成饼图",
  1715. command=API.to_pie,
  1716. font=FONT,
  1717. width=gui_width,
  1718. height=gui_height,
  1719. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  1720. row += 1
  1721. tkinter.Button(
  1722. SCREEN,
  1723. bg=buttom_bg_color,
  1724. fg=word_color,
  1725. text="生成多轴图",
  1726. command=API.to_parallel,
  1727. font=FONT,
  1728. width=gui_width,
  1729. height=gui_height,
  1730. ).grid(
  1731. column=column,
  1732. row=row,
  1733. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1734. )
  1735. tkinter.Button(
  1736. SCREEN,
  1737. bg=buttom_bg_color,
  1738. fg=word_color,
  1739. text="生成极坐标图",
  1740. command=API.to_polar,
  1741. font=FONT,
  1742. width=gui_width,
  1743. height=gui_height,
  1744. ).grid(
  1745. column=column + 1,
  1746. row=row,
  1747. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1748. )
  1749. tkinter.Button(
  1750. SCREEN,
  1751. bg=buttom_bg_color,
  1752. fg=word_color,
  1753. text="生成雷达图",
  1754. command=API.to_radar,
  1755. font=FONT,
  1756. width=gui_width,
  1757. height=gui_height,
  1758. ).grid(
  1759. column=column + 2,
  1760. row=row,
  1761. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1762. )
  1763. row += 1
  1764. tkinter.Button(
  1765. SCREEN,
  1766. bg=buttom_bg_color,
  1767. fg=word_color,
  1768. text="生成词云",
  1769. command=API.to_word_cloud,
  1770. font=FONT,
  1771. width=gui_width,
  1772. height=gui_height,
  1773. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
  1774. tkinter.Button(
  1775. SCREEN,
  1776. bg=buttom_bg_color,
  1777. fg=word_color,
  1778. text="生成关系图",
  1779. command=API.to_format_graph,
  1780. font=FONT,
  1781. width=gui_width,
  1782. height=gui_height,
  1783. ).grid(
  1784. column=column + 1,
  1785. row=row,
  1786. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1787. )
  1788. tkinter.Button(
  1789. SCREEN,
  1790. bg=buttom_bg_color,
  1791. fg=word_color,
  1792. text="生成XY关系图",
  1793. command=API.to_graph,
  1794. font=FONT,
  1795. width=gui_width,
  1796. height=gui_height,
  1797. ).grid(
  1798. column=column + 2,
  1799. row=row,
  1800. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1801. )
  1802. row += 1
  1803. tkinter.Button(
  1804. SCREEN,
  1805. bg=buttom_bg_color,
  1806. fg=word_color,
  1807. text="生成水球图",
  1808. command=API.to_liquid,
  1809. font=FONT,
  1810. width=gui_width,
  1811. height=gui_height,
  1812. ).grid(
  1813. column=column,
  1814. row=row,
  1815. columnspan=2,
  1816. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  1817. )
  1818. tkinter.Button(
  1819. SCREEN,
  1820. bg=buttom_bg_color,
  1821. fg=word_color,
  1822. text="生成仪表图",
  1823. command=API.to_gauge,
  1824. font=FONT,
  1825. width=gui_width,
  1826. height=gui_height,
  1827. ).grid(
  1828. column=column + 2,
  1829. row=row,
  1830. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1831. )
  1832. row += 1
  1833. tkinter.Button(
  1834. SCREEN,
  1835. bg=buttom_bg_color,
  1836. fg=word_color,
  1837. text="生成日历图",
  1838. command=API.to_calendar,
  1839. font=FONT,
  1840. width=gui_width,
  1841. height=gui_height,
  1842. ).grid(
  1843. column=column,
  1844. row=row,
  1845. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1846. )
  1847. tkinter.Button(
  1848. SCREEN,
  1849. bg=buttom_bg_color,
  1850. fg=word_color,
  1851. text="生成河流图",
  1852. command=API.to_theme_river,
  1853. font=FONT,
  1854. width=gui_width,
  1855. height=gui_height,
  1856. ).grid(
  1857. column=column + 1,
  1858. row=row,
  1859. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1860. )
  1861. tkinter.Button(
  1862. SCREEN,
  1863. bg=buttom_bg_color,
  1864. fg=word_color,
  1865. text="生成旭日图",
  1866. command=API.to_sunburst,
  1867. font=FONT,
  1868. width=gui_width,
  1869. height=gui_height,
  1870. ).grid(
  1871. column=column + 2,
  1872. row=row,
  1873. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1874. )
  1875. row += 1
  1876. tkinter.Button(
  1877. SCREEN,
  1878. bg=buttom_bg_color,
  1879. fg=word_color,
  1880. text="生成桑基图",
  1881. command=API.to_sankey,
  1882. font=FONT,
  1883. width=gui_width,
  1884. height=gui_height,
  1885. ).grid(
  1886. column=column,
  1887. row=row,
  1888. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1889. )
  1890. tkinter.Button(
  1891. SCREEN,
  1892. bg=buttom_bg_color,
  1893. fg=word_color,
  1894. text="生成树状图",
  1895. command=API.to_tree,
  1896. font=FONT,
  1897. width=gui_width,
  1898. height=gui_height,
  1899. ).grid(
  1900. column=column + 1,
  1901. row=row,
  1902. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1903. )
  1904. tkinter.Button(
  1905. SCREEN,
  1906. bg=buttom_bg_color,
  1907. fg=word_color,
  1908. text="生成矩形树图",
  1909. command=API.to_treemap,
  1910. font=FONT,
  1911. width=gui_width,
  1912. height=gui_height,
  1913. ).grid(
  1914. column=column + 2,
  1915. row=row,
  1916. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1917. )
  1918. row += 1
  1919. tkinter.Button(
  1920. SCREEN,
  1921. bg=buttom_bg_color,
  1922. fg=word_color,
  1923. text="生成Map地图",
  1924. command=API.to_map,
  1925. font=FONT,
  1926. width=gui_width,
  1927. height=gui_height,
  1928. ).grid(
  1929. column=column,
  1930. row=row,
  1931. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1932. )
  1933. tkinter.Button(
  1934. SCREEN,
  1935. bg=buttom_bg_color,
  1936. fg=word_color,
  1937. text="生成Geo点地图",
  1938. command=API.to_scattergeo,
  1939. font=FONT,
  1940. width=gui_width,
  1941. height=gui_height,
  1942. ).grid(
  1943. column=column + 1,
  1944. row=row,
  1945. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1946. )
  1947. tkinter.Button(
  1948. SCREEN,
  1949. bg=buttom_bg_color,
  1950. fg=word_color,
  1951. text="生成Geo地图",
  1952. command=API.to_geo,
  1953. font=FONT,
  1954. width=gui_width,
  1955. height=gui_height,
  1956. ).grid(
  1957. column=column + 2,
  1958. row=row,
  1959. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1960. )
  1961. row += 1
  1962. tkinter.Button(
  1963. SCREEN,
  1964. bg=buttom_bg_color,
  1965. fg=word_color,
  1966. text="选择底图",
  1967. command=API.add_basemap,
  1968. font=FONT,
  1969. width=gui_width,
  1970. height=gui_height,
  1971. ).grid(
  1972. column=column,
  1973. row=row,
  1974. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1975. )
  1976. tkinter.Button(
  1977. SCREEN,
  1978. bg=buttom_bg_color,
  1979. fg=word_color,
  1980. text="选择顶图",
  1981. command=API.add_top_image,
  1982. font=FONT,
  1983. width=gui_width,
  1984. height=gui_height,
  1985. ).grid(
  1986. column=column + 1,
  1987. row=row,
  1988. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  1989. )
  1990. tkinter.Button(
  1991. SCREEN,
  1992. bg=buttom_bg_color,
  1993. fg=word_color,
  1994. text="生成层叠图",
  1995. command=API.make_overlap,
  1996. font=FONT,
  1997. width=gui_width,
  1998. height=gui_height,
  1999. ).grid(
  2000. column=column + 2,
  2001. row=row,
  2002. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2003. )
  2004. row += 1
  2005. overlap_box = tkinter.Listbox(SCREEN, width=gui_width * 3, height=gui_height * 2)
  2006. overlap_box.grid(
  2007. column=column,
  2008. row=row,
  2009. columnspan=3,
  2010. rowspan=2,
  2011. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  2012. )
  2013. row += 1
  2014. tkinter.Button(
  2015. SCREEN,
  2016. bg=buttom_bg_color,
  2017. fg=word_color,
  2018. text="渲染HTML",
  2019. command=API.rendering,
  2020. font=FONT,
  2021. width=gui_width,
  2022. height=gui_height,
  2023. ).grid(
  2024. column=column,
  2025. row=row,
  2026. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2027. )
  2028. tkinter.Button(
  2029. SCREEN,
  2030. bg=buttom_bg_color,
  2031. fg=word_color,
  2032. text="单独渲染HTML",
  2033. command=API.rendering_one,
  2034. font=FONT,
  2035. width=gui_width,
  2036. height=gui_height,
  2037. ).grid(
  2038. column=column + 1,
  2039. row=row,
  2040. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2041. )
  2042. tkinter.Button(
  2043. SCREEN,
  2044. bg=buttom_bg_color,
  2045. fg=word_color,
  2046. text="删除渲染",
  2047. command=API.del_rendering,
  2048. font=FONT,
  2049. width=gui_width,
  2050. height=gui_height,
  2051. ).grid(
  2052. column=column + 2,
  2053. row=row,
  2054. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2055. )
  2056. row += 1
  2057. render_box = tkinter.Listbox(SCREEN, width=gui_width * 3, height=gui_height)
  2058. render_box.grid(
  2059. column=column,
  2060. row=row,
  2061. columnspan=3,
  2062. rowspan=2,
  2063. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  2064. )
  2065. row += 2
  2066. draw_as_well = tkinter.IntVar()
  2067. tkinter.Button(
  2068. SCREEN,
  2069. bg=buttom_bg_color,
  2070. fg=word_color,
  2071. text="清空渲染",
  2072. command=API.clear_rendering,
  2073. font=FONT,
  2074. width=gui_width,
  2075. height=gui_height,
  2076. ).grid(
  2077. column=column,
  2078. row=row,
  2079. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2080. )
  2081. tkinter.Button(
  2082. SCREEN,
  2083. bg=buttom_bg_color,
  2084. fg=word_color,
  2085. text="导入渲染",
  2086. command=API.python_render,
  2087. font=FONT,
  2088. width=gui_width,
  2089. height=gui_height,
  2090. ).grid(
  2091. column=column + 1,
  2092. row=row,
  2093. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2094. )
  2095. tkinter.Checkbutton(
  2096. SCREEN,
  2097. bg=bg_color,
  2098. fg=word_color,
  2099. activebackground=bg_color,
  2100. activeforeground=word_color,
  2101. selectcolor=bg_color,
  2102. text="马上渲染",
  2103. variable=draw_as_well,
  2104. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  2105. row += 1
  2106. rendering_parameters = tkinter.Text(SCREEN, width=gui_width * 3, height=gui_height * 7)
  2107. rendering_parameters.grid(
  2108. column=column,
  2109. row=row,
  2110. columnspan=3,
  2111. rowspan=7,
  2112. sticky=tkinter.E + tkinter.W + tkinter.N + tkinter.S,
  2113. )
  2114. row += 7
  2115. tkinter.Button(
  2116. SCREEN,
  2117. bg=buttom_bg_color,
  2118. fg=word_color,
  2119. text="查看词典",
  2120. command=API.show_dictionary_gui,
  2121. font=FONT,
  2122. width=gui_width,
  2123. height=gui_height,
  2124. ).grid(
  2125. column=column,
  2126. row=row,
  2127. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2128. )
  2129. tkinter.Button(
  2130. SCREEN,
  2131. bg=buttom_bg_color,
  2132. fg=word_color,
  2133. text="恢复显示",
  2134. command=API.show_tips_gui,
  2135. font=FONT,
  2136. width=gui_width,
  2137. height=gui_height,
  2138. ).grid(
  2139. column=column + 1,
  2140. row=row,
  2141. columnspan=2,
  2142. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2143. )
  2144. column += 3
  2145. tkinter.Label(SCREEN, text="", bg=bg_color, fg=word_color, font=FONT, width=1).grid(
  2146. column=column, row=row
  2147. ) # 设置说明
  2148. column += 1
  2149. row = 0
  2150. tkinter.Label(
  2151. SCREEN,
  2152. text="【行名与列名】",
  2153. bg=bg_color,
  2154. fg=word_color,
  2155. font=FONT,
  2156. width=gui_width * 3,
  2157. height=gui_height,
  2158. ).grid(
  2159. column=column,
  2160. columnspan=3,
  2161. row=row,
  2162. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2163. ) # 设置说明
  2164. row += 1
  2165. replace_index = tkinter.IntVar()
  2166. lable = ["(列数据)调整行名", "(行数据)调整列名"] # 复选框
  2167. for i in range(2):
  2168. tkinter.Radiobutton(
  2169. SCREEN,
  2170. bg=bg_color,
  2171. fg=word_color,
  2172. activebackground=bg_color,
  2173. activeforeground=word_color,
  2174. selectcolor=bg_color,
  2175. text=lable[i],
  2176. variable=replace_index,
  2177. value=i,
  2178. ).grid(column=column + i, row=row, sticky=tkinter.W)
  2179. tkinter.Button(
  2180. SCREEN,
  2181. bg=buttom_bg_color,
  2182. fg=word_color,
  2183. text="植入行(列)号",
  2184. command=API.num_with_name,
  2185. font=FONT,
  2186. width=gui_width,
  2187. height=gui_height,
  2188. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2189. row += 1
  2190. replace_type = []
  2191. lable = ["保留原值", "保留新值"] # 复选框
  2192. for i in range(2):
  2193. replace_type.append(tkinter.IntVar())
  2194. tkinter.Checkbutton(
  2195. SCREEN,
  2196. bg=bg_color,
  2197. fg=word_color,
  2198. activebackground=bg_color,
  2199. activeforeground=word_color,
  2200. selectcolor=bg_color,
  2201. text=lable[i],
  2202. variable=replace_type[-1],
  2203. ).grid(column=column + i, row=row, sticky=tkinter.W)
  2204. tkinter.Button(
  2205. SCREEN,
  2206. bg=buttom_bg_color,
  2207. fg=word_color,
  2208. text="统一行(列)号",
  2209. command=API.num_to_name,
  2210. font=FONT,
  2211. width=gui_width,
  2212. height=gui_height,
  2213. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2214. row += 1
  2215. tkinter.Label(
  2216. SCREEN,
  2217. text="替换字典:",
  2218. bg=bg_color,
  2219. fg=word_color,
  2220. font=FONT,
  2221. width=gui_width,
  2222. height=gui_height,
  2223. ).grid(
  2224. column=column, row=row
  2225. ) # 设置说明
  2226. replace_dict = tkinter.Entry(SCREEN, width=gui_width * 2)
  2227. replace_dict.grid(
  2228. column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W
  2229. )
  2230. row += 1
  2231. tkinter.Label(
  2232. SCREEN,
  2233. text="替换列(行):",
  2234. bg=bg_color,
  2235. fg=word_color,
  2236. font=FONT,
  2237. width=gui_width,
  2238. height=gui_height,
  2239. ).grid(
  2240. column=column, row=row
  2241. ) # 设置说明
  2242. replace_iloc = tkinter.Entry(SCREEN, width=gui_width * 2)
  2243. replace_iloc.grid(
  2244. column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W
  2245. )
  2246. row += 1
  2247. tkinter.Button(
  2248. SCREEN,
  2249. bg=buttom_bg_color,
  2250. fg=word_color,
  2251. text="执行替换已有列(行)操作",
  2252. command=API.change_index,
  2253. font=FONT,
  2254. width=gui_width * 2,
  2255. height=gui_height,
  2256. ).grid(column=column, columnspan=2, row=row, sticky=tkinter.E + tkinter.W)
  2257. tkinter.Button(
  2258. SCREEN,
  2259. bg=buttom_bg_color,
  2260. fg=word_color,
  2261. text="执行替换操作",
  2262. command=API.replace_index_func,
  2263. font=FONT,
  2264. width=gui_width,
  2265. height=gui_height,
  2266. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2267. label = ["起点", "终点", "间隔"]
  2268. date_input = []
  2269. for i in range(3):
  2270. row += 1
  2271. tkinter.Label(
  2272. SCREEN,
  2273. text="时间序列" + label[i],
  2274. bg=bg_color,
  2275. fg=word_color,
  2276. font=FONT,
  2277. width=gui_width,
  2278. height=gui_height,
  2279. ).grid(
  2280. column=column, row=row
  2281. ) # 设置说明
  2282. date_input.append(tkinter.Entry(SCREEN, width=gui_width * 2))
  2283. date_input[-1].grid(
  2284. column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W
  2285. )
  2286. row += 1
  2287. date_type = tkinter.IntVar()
  2288. tkinter.Button(
  2289. SCREEN,
  2290. bg=buttom_bg_color,
  2291. fg=word_color,
  2292. text="刷入Date序列",
  2293. command=API.date_index,
  2294. font=FONT,
  2295. width=gui_width,
  2296. height=gui_height,
  2297. ).grid(column=column, row=row, sticky=tkinter.E + tkinter.W)
  2298. tkinter.Button(
  2299. SCREEN,
  2300. bg=buttom_bg_color,
  2301. fg=word_color,
  2302. text="刷入Time序列",
  2303. command=API.time_index,
  2304. font=FONT,
  2305. width=gui_width,
  2306. height=gui_height,
  2307. ).grid(column=column + 1, row=row, sticky=tkinter.E + tkinter.W)
  2308. tkinter.Checkbutton(
  2309. SCREEN,
  2310. bg=bg_color,
  2311. fg=word_color,
  2312. activebackground=bg_color,
  2313. activeforeground=word_color,
  2314. selectcolor=bg_color,
  2315. text="使用间隔",
  2316. variable=date_type,
  2317. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  2318. row += 1
  2319. tkinter.Label(
  2320. SCREEN,
  2321. text="【数据类型管理】",
  2322. bg=bg_color,
  2323. fg=word_color,
  2324. font=FONT,
  2325. width=gui_width * 3,
  2326. height=gui_height,
  2327. ).grid(
  2328. column=column,
  2329. columnspan=3,
  2330. row=row,
  2331. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2332. ) # 设置说明
  2333. row += 1
  2334. tkinter.Label(
  2335. SCREEN,
  2336. text="修改(列号):",
  2337. bg=bg_color,
  2338. fg=word_color,
  2339. font=FONT,
  2340. width=gui_width,
  2341. height=gui_height,
  2342. ).grid(
  2343. column=column, row=row
  2344. ) # 设置说明
  2345. dtype_column = tkinter.Entry(SCREEN, width=gui_width * 2)
  2346. dtype_column.grid(
  2347. column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W
  2348. )
  2349. row += 1
  2350. tkinter.Label(
  2351. SCREEN,
  2352. text="数据类型:",
  2353. bg=bg_color,
  2354. fg=word_color,
  2355. font=FONT,
  2356. width=gui_width,
  2357. height=gui_height,
  2358. ).grid(
  2359. column=column, row=row
  2360. ) # 设置说明
  2361. dtype_input = tkinter.Entry(SCREEN, width=gui_width * 2)
  2362. dtype_input.grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  2363. row += 1
  2364. tkinter.Label(
  2365. SCREEN,
  2366. text="错误值:",
  2367. bg=bg_color,
  2368. fg=word_color,
  2369. font=FONT,
  2370. width=gui_width,
  2371. height=gui_height,
  2372. ).grid(
  2373. column=column, row=row
  2374. ) # 设置说明
  2375. dtype_wrong = tkinter.Entry(SCREEN, width=gui_width * 2)
  2376. dtype_wrong.grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  2377. row += 1
  2378. tkinter.Button(
  2379. SCREEN,
  2380. bg=buttom_bg_color,
  2381. fg=word_color,
  2382. text="执行转换",
  2383. command=API.set_dtype,
  2384. font=FONT,
  2385. width=gui_width,
  2386. height=gui_height,
  2387. ).grid(
  2388. column=column,
  2389. row=row,
  2390. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2391. )
  2392. dtype_func = tkinter.IntVar() # 正,负,0
  2393. lable = ["硬转换", "软转换"] # 复选框
  2394. for i in range(2):
  2395. tkinter.Radiobutton(
  2396. SCREEN,
  2397. bg=bg_color,
  2398. fg=word_color,
  2399. activebackground=bg_color,
  2400. activeforeground=word_color,
  2401. selectcolor=bg_color,
  2402. text=lable[i],
  2403. variable=dtype_func,
  2404. value=i,
  2405. ).grid(column=column + 1 + i, row=row, sticky=tkinter.W)
  2406. row += 1
  2407. tkinter.Label(
  2408. SCREEN,
  2409. text="【排序操作】",
  2410. bg=bg_color,
  2411. fg=word_color,
  2412. font=FONT,
  2413. width=gui_width * 3,
  2414. height=gui_height,
  2415. ).grid(
  2416. column=column, columnspan=3, row=row
  2417. ) # 设置说明
  2418. row += 1
  2419. tkinter.Button(
  2420. SCREEN,
  2421. bg=buttom_bg_color,
  2422. fg=word_color,
  2423. text=".T",
  2424. command=API.transpose,
  2425. font=FONT,
  2426. width=gui_width,
  2427. height=gui_height,
  2428. ).grid(
  2429. column=column,
  2430. row=row,
  2431. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2432. )
  2433. tkinter.Button(
  2434. SCREEN,
  2435. bg=buttom_bg_color,
  2436. fg=word_color,
  2437. text="按行名排序",
  2438. command=API.sort_by_tow,
  2439. font=FONT,
  2440. width=gui_width,
  2441. height=gui_height,
  2442. ).grid(
  2443. column=column + 1,
  2444. row=row,
  2445. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2446. )
  2447. tkinter.Button(
  2448. SCREEN,
  2449. bg=buttom_bg_color,
  2450. fg=word_color,
  2451. text="按列名排序",
  2452. command=API.sort_by_column,
  2453. font=FONT,
  2454. width=gui_width,
  2455. height=gui_height,
  2456. ).grid(
  2457. column=column + 2,
  2458. row=row,
  2459. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2460. )
  2461. row += 1
  2462. tkinter.Label(
  2463. SCREEN,
  2464. text="基准列(列号):",
  2465. bg=bg_color,
  2466. fg=word_color,
  2467. font=FONT,
  2468. width=gui_width,
  2469. height=gui_height,
  2470. ).grid(
  2471. column=column, row=row
  2472. ) # 设置说明
  2473. sort_by = tkinter.Entry(SCREEN, width=gui_width + 2)
  2474. sort_by.grid(column=column + 1, row=row, sticky=tkinter.W)
  2475. tkinter.Button(
  2476. SCREEN,
  2477. bg=buttom_bg_color,
  2478. fg=word_color,
  2479. text="按数据排序",
  2480. command=API.stored_value,
  2481. font=FONT,
  2482. width=gui_width,
  2483. height=gui_height,
  2484. ).grid(
  2485. column=column + 2,
  2486. row=row,
  2487. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2488. )
  2489. row += 1
  2490. ascending_type = tkinter.IntVar()
  2491. ascending_new = tkinter.IntVar()
  2492. lable = ["正序排列", "倒序排列"] # 复选框
  2493. for i in range(2):
  2494. tkinter.Radiobutton(
  2495. SCREEN,
  2496. bg=bg_color,
  2497. fg=word_color,
  2498. activebackground=bg_color,
  2499. activeforeground=word_color,
  2500. selectcolor=bg_color,
  2501. text=lable[i],
  2502. variable=ascending_type,
  2503. value=i,
  2504. ).grid(column=column + i, row=row, sticky=tkinter.W)
  2505. tkinter.Checkbutton(
  2506. SCREEN,
  2507. bg=bg_color,
  2508. fg=word_color,
  2509. activebackground=bg_color,
  2510. activeforeground=word_color,
  2511. selectcolor=bg_color,
  2512. text="生成新表格",
  2513. variable=ascending_new,
  2514. ).grid(column=column + 2, row=row, sticky=tkinter.W)
  2515. row += 1
  2516. stored_box = tkinter.Listbox(SCREEN, width=gui_width * 3, height=gui_height * 4) # 显示符号
  2517. stored_box.grid(
  2518. column=column,
  2519. row=row,
  2520. columnspan=3,
  2521. rowspan=5,
  2522. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  2523. )
  2524. row += 5
  2525. tkinter.Button(
  2526. SCREEN,
  2527. bg=buttom_bg_color,
  2528. fg=word_color,
  2529. text="添加基准",
  2530. command=API.add_baseline,
  2531. font=FONT,
  2532. width=gui_width,
  2533. height=gui_height,
  2534. ).grid(
  2535. column=column,
  2536. row=row,
  2537. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2538. )
  2539. tkinter.Button(
  2540. SCREEN,
  2541. bg=buttom_bg_color,
  2542. fg=word_color,
  2543. text="删除基准",
  2544. command=API.del_baseline,
  2545. font=FONT,
  2546. width=gui_width,
  2547. height=gui_height,
  2548. ).grid(
  2549. column=column + 1,
  2550. row=row,
  2551. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2552. )
  2553. tkinter.Button(
  2554. SCREEN,
  2555. bg=buttom_bg_color,
  2556. fg=word_color,
  2557. text="打乱表格",
  2558. command=API.sample_data,
  2559. font=FONT,
  2560. width=gui_width,
  2561. height=gui_height,
  2562. ).grid(
  2563. column=column + 2,
  2564. row=row,
  2565. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2566. )
  2567. column += 3
  2568. tkinter.Label(SCREEN, text="", bg=bg_color, fg=word_color, font=FONT, width=1).grid(
  2569. column=column, row=row
  2570. ) # 设置说明
  2571. column += 1
  2572. row = 0
  2573. tkinter.Label(
  2574. SCREEN,
  2575. text="【机器学习】",
  2576. bg=bg_color,
  2577. fg=word_color,
  2578. font=FONT,
  2579. width=gui_width * 3,
  2580. height=gui_height,
  2581. ).grid(
  2582. column=column,
  2583. columnspan=3,
  2584. row=row,
  2585. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2586. ) # 设置说明
  2587. row += 1
  2588. chose_learner = tkinter.StringVar()
  2589. put = tkinter.Entry(SCREEN, width=gui_width * 2, textvariable=chose_learner)
  2590. put.grid(column=column, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  2591. put["state"] = "readonly"
  2592. tkinter.Button(
  2593. SCREEN,
  2594. bg=buttom_bg_color,
  2595. fg=word_color,
  2596. text="选用学习器",
  2597. command=API.set_learner_gui,
  2598. font=FONT,
  2599. width=gui_width,
  2600. height=gui_height,
  2601. ).grid(column=column + 2, row=row, sticky=tkinter.E + tkinter.W)
  2602. row += 1
  2603. tkinter.Label(
  2604. SCREEN,
  2605. text="测试数据分割:",
  2606. bg=bg_color,
  2607. fg=word_color,
  2608. font=FONT,
  2609. width=gui_width,
  2610. height=gui_height,
  2611. ).grid(column=column, row=row)
  2612. data_split = tkinter.Entry(SCREEN, width=gui_width * 2)
  2613. data_split.grid(column=column + 1, row=row, columnspan=2, sticky=tkinter.E + tkinter.W)
  2614. row += 1
  2615. learner_box = tkinter.Listbox(SCREEN, width=gui_width * 3, height=gui_height * 5)
  2616. learner_box.grid(
  2617. column=column,
  2618. row=row,
  2619. columnspan=3,
  2620. rowspan=5,
  2621. sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N,
  2622. )
  2623. row += 5
  2624. tkinter.Button(
  2625. SCREEN,
  2626. bg=buttom_bg_color,
  2627. fg=word_color,
  2628. text="导入学习器",
  2629. command=API.rendering,
  2630. font=FONT,
  2631. width=gui_width,
  2632. height=gui_height,
  2633. ).grid(
  2634. column=column,
  2635. row=row,
  2636. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2637. )
  2638. tkinter.Button(
  2639. SCREEN,
  2640. bg=buttom_bg_color,
  2641. fg=word_color,
  2642. text="查看数据",
  2643. command=API.visual_learner,
  2644. font=FONT,
  2645. width=gui_width,
  2646. height=gui_height,
  2647. ).grid(
  2648. column=column + 1,
  2649. row=row,
  2650. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2651. )
  2652. tkinter.Button(
  2653. SCREEN,
  2654. bg=buttom_bg_color,
  2655. fg=word_color,
  2656. text="删除学习器",
  2657. command=API.del_learner,
  2658. font=FONT,
  2659. width=gui_width,
  2660. height=gui_height,
  2661. ).grid(
  2662. column=column + 2,
  2663. row=row,
  2664. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2665. )
  2666. row += 1
  2667. tkinter.Button(
  2668. SCREEN,
  2669. bg=buttom_bg_color,
  2670. fg=word_color,
  2671. text="训练机器",
  2672. command=API.fit_learner,
  2673. font=FONT,
  2674. width=gui_width,
  2675. height=gui_height,
  2676. ).grid(
  2677. column=column,
  2678. row=row,
  2679. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2680. )
  2681. tkinter.Button(
  2682. SCREEN,
  2683. bg=buttom_bg_color,
  2684. fg=word_color,
  2685. text="测试机器",
  2686. command=API.test_learner,
  2687. font=FONT,
  2688. width=gui_width,
  2689. height=gui_height,
  2690. ).grid(
  2691. column=column + 1,
  2692. row=row,
  2693. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2694. )
  2695. tkinter.Button(
  2696. SCREEN,
  2697. bg=buttom_bg_color,
  2698. fg=word_color,
  2699. text="数据预测",
  2700. command=API.predict_learner,
  2701. font=FONT,
  2702. width=gui_width,
  2703. height=gui_height,
  2704. ).grid(
  2705. column=column + 2,
  2706. row=row,
  2707. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2708. )
  2709. row += 1
  2710. tkinter.Label(
  2711. SCREEN,
  2712. text="【学习器选择和配置】",
  2713. bg=bg_color,
  2714. fg=word_color,
  2715. font=FONT,
  2716. width=gui_width * 3,
  2717. height=gui_height,
  2718. ).grid(
  2719. column=column,
  2720. columnspan=3,
  2721. row=row,
  2722. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2723. ) # 设置说明
  2724. row += 1
  2725. tkinter.Button(
  2726. SCREEN,
  2727. bg=buttom_bg_color,
  2728. fg=word_color,
  2729. text="线性回归",
  2730. command=API.add_generalized_linear,
  2731. font=FONT,
  2732. width=gui_width,
  2733. height=gui_height,
  2734. ).grid(
  2735. column=column,
  2736. row=row,
  2737. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2738. )
  2739. tkinter.Button(
  2740. SCREEN,
  2741. bg=buttom_bg_color,
  2742. fg=word_color,
  2743. text="岭回归",
  2744. command=API.add_ridge,
  2745. font=FONT,
  2746. width=gui_width,
  2747. height=gui_height,
  2748. ).grid(
  2749. column=column + 1,
  2750. row=row,
  2751. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2752. )
  2753. tkinter.Button(
  2754. SCREEN,
  2755. bg=buttom_bg_color,
  2756. fg=word_color,
  2757. text="Lasso",
  2758. command=API.add_lasso,
  2759. font=FONT,
  2760. width=gui_width,
  2761. height=gui_height,
  2762. ).grid(
  2763. column=column + 2,
  2764. row=row,
  2765. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2766. )
  2767. row += 1
  2768. tkinter.Button(
  2769. SCREEN,
  2770. bg=buttom_bg_color,
  2771. fg=word_color,
  2772. text="逻辑回归",
  2773. command=API.add_logistic_regression,
  2774. font=FONT,
  2775. width=gui_width,
  2776. height=gui_height,
  2777. ).grid(
  2778. column=column,
  2779. row=row,
  2780. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2781. )
  2782. tkinter.Button(
  2783. SCREEN,
  2784. bg=buttom_bg_color,
  2785. fg=word_color,
  2786. text="决策树",
  2787. command=API.show_sorry_gui,
  2788. font=FONT,
  2789. width=gui_width,
  2790. height=gui_height,
  2791. ).grid(
  2792. column=column + 1,
  2793. row=row,
  2794. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2795. )
  2796. tkinter.Button(
  2797. SCREEN,
  2798. bg=buttom_bg_color,
  2799. fg=word_color,
  2800. text="SVM",
  2801. command=API.show_sorry_gui,
  2802. font=FONT,
  2803. width=gui_width,
  2804. height=gui_height,
  2805. ).grid(
  2806. column=column + 2,
  2807. row=row,
  2808. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2809. )
  2810. row += 1
  2811. tkinter.Button(
  2812. SCREEN,
  2813. bg=buttom_bg_color,
  2814. fg=word_color,
  2815. text="朴素贝叶斯",
  2816. command=API.show_sorry_gui,
  2817. font=FONT,
  2818. width=gui_width,
  2819. height=gui_height,
  2820. ).grid(
  2821. column=column,
  2822. row=row,
  2823. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2824. )
  2825. tkinter.Button(
  2826. SCREEN,
  2827. bg=buttom_bg_color,
  2828. fg=word_color,
  2829. text="K邻近分类",
  2830. command=API.add_knn_regression,
  2831. font=FONT,
  2832. width=gui_width,
  2833. height=gui_height,
  2834. ).grid(
  2835. column=column + 1,
  2836. row=row,
  2837. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2838. )
  2839. tkinter.Button(
  2840. SCREEN,
  2841. bg=buttom_bg_color,
  2842. fg=word_color,
  2843. text="K邻近预测",
  2844. command=API.add_knn_class,
  2845. font=FONT,
  2846. width=gui_width,
  2847. height=gui_height,
  2848. ).grid(
  2849. column=column + 2,
  2850. row=row,
  2851. sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N,
  2852. )
  2853. row += 1
  2854. learner_parameters = tkinter.Text(SCREEN, width=gui_width * 3, height=gui_height * 11)
  2855. learner_parameters.grid(
  2856. column=column,
  2857. row=row,
  2858. columnspan=3,
  2859. rowspan=11,
  2860. sticky=tkinter.E + tkinter.W + tkinter.N + tkinter.S,
  2861. )