gui.py 73 KB

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