1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627 |
- import tkinter
- from tkinter.filedialog import askopenfilename, asksaveasfilename
- import tkinter.messagebox
- from Data_Science import Learn
- import webbrowser
- import os
- from tkinter.scrolledtext import ScrolledText
- import chardet
- # 数据清洗
- Clean_Text = '''#输入你的数据清洗执行代码
- Done_Row=[] #输入操作的行号
- Done_Column=[] #输入操作的列号
- axis=True #True-操作行,False-操作列
- name='' #方法代号
- def check(data, row, column, get, R, C): #检查方法
- return True
- def done(data, row, column, get, R, C): #应用修正方法
- return DEL
- '''
- Clean_Help = '''
- 使用Python代码进行数据清洗
- 1)代码结构
- Done_Row=[] 代码用来检测的数据的列号
- Done_Column=[] 代码用来检测的数据的行号
- 不在以上指定范围内的数据将不会被检测,若为空则整个表格检测
- axis 执行删除方法时删除行或者列
- name 方法代号
-
- check 检查方法
- 输入:当前的值(输入的是一个值而不是一行(列)或整个列表)
- 输入:row和column当前值来自的行号(row)和列号(column)
- 输入:get当前检查的所有数据:类型是表格
- 输入:R和C当前值所来自的行和列的所有数据:类型是一维表格
-
- 输出:输出布尔为True代表该值可以使用,输出布尔为假表示该值不可使用
-
- done 不可使用的数值改造方法
- 输入:内容同上
- 输出:改造值或者DEL
- DEL:代表删除改值所在的行(axis=True)或列(axis=False)
- 2)扩展
- 默认:pd-pandas,re-re[正则表达式],Sheet-包含所有表格,用Sheet['name']访问名字为name的表格(注意引号别漏了)
- 支持:可以使用import导入语句,支持python语法
- '''
- Args_Help = '''
- 输入python变量赋值代码:渲染设置
- title #设置标题:str
- vice_title #设置副标题:str
- show_Legend #是否显示图例:bool
- show_Visual_mapping #是否使用视觉映射:bool
- is_color_Visual_mapping #是否为颜色视觉映射:bool[否则为大小视觉映射]
- min_Visual_mapping #映射的最小值
- max_Visual_mapping #映射的最大值
- ......(我太懒了, 设置太多不想写了)
- '''
- # top = None
- # ML = None
- # Form_List = None
- # PATH = None
- # bg = None
- # ft1 = None
- # Stored_List = None
- # Clean_List = None
- # R_Dic = None
- # Over_Up = None
- # Over_Down = None
- #
- # Form_BOX = None
- # Index_BOX = None
- # Column_BOX = None
- # to_HTML_Type = None
- # Seq_Input = None
- # Code_Input = None
- # str_must = None
- # Index_must = None
- def Machine_learning():
- global top, ML, Form_List, PATH, bg, ft1, Stored_List, Clean_List, R_Dic, Over_Up, Over_Down,Learn_Dic
- R_Dic = {} # 保存了画图的List
- Learn_Dic = {} #保存数据处理
- PATH = os.getcwd()
- Form_List = []
- ML = Learn.Machine_Learner()
- top = tkinter.Tk()
- bg = '#FFFAFA' # 主颜色
- bbg = '#FFFAFA' # 按钮颜色
- fg = '#000000' # 文字颜色
- top["bg"] = bg
- FONT = ('黑体', 11) # 设置字体
- ft1 = ('黑体', 13)
- top.title('CoTan数据处理')
- top.resizable(width=False, height=False)
- top.geometry('+10+10') # 设置所在位置
- width_B = 13 # 标准宽度
- height_B = 2
- a_y = 0
- a_x = 0
- Stored_List = []
- Clean_List = []
- # 层叠多图
- Over_Down = None
- Over_Up = None
- tkinter.Button(top, bg=bbg, fg=fg, text='导入CSV', command=Add_CSV, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='导入Py', command=Add_Python, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='导出CSV', command=to_CSV,font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 2, row=a_y,sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- global name_Input
- a_y += 1
- tkinter.Label(top, text='表格名称:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
- row=a_y) # 设置说明
- name_Input = tkinter.Entry(top, width=width_B)
- name_Input.grid(column=a_x + 1, row=a_y,columnspan=2, sticky=tkinter.E + tkinter.W)
- a_y += 1
- tkinter.Button(top, bg=bbg, fg=fg, text='删除表格',command=Del_Sheet, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='查看表格', command=Show, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='查看单一表格', command=Show_One,font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- global Form_BOX, Index_BOX, Column_BOX, to_HTML_Type, Seq_Input, Code_Input, str_must, Index_must
- a_y += 1
- to_HTML_Type = tkinter.IntVar() # 正,负,0
- lable = ['选项卡型', '可移动型', '自适应型'] # 复选框
- for i in range(3):
- tkinter.Radiobutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text=lable[i],
- variable=to_HTML_Type,
- value=i).grid(column=a_x + i, row=a_y, sticky=tkinter.W)
- str_must = tkinter.IntVar()
- Index_must = tkinter.IntVar()
- a_y += 1
- tkinter.Label(top, text='编码方式:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
- row=a_y) # 设置说明
- Code_Input = tkinter.Entry(top, width=width_B)
- Code_Input.grid(column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W)
- buttom = tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg,
- text='字符串类型',
- variable=str_must)
- buttom.grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
- a_y += 1
- tkinter.Label(top, text='CSV分隔符:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
- row=a_y) # 设置说明
- Seq_Input = tkinter.Entry(top, width=width_B)
- Seq_Input.grid(column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W)
- tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='重置列名',
- variable=Index_must).grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
- a_y += 1
- Form_BOX = tkinter.Listbox(top, width=width_B * 3, height=height_B * 5) # 显示符号
- Form_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=5, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
- a_y += 5
- tkinter.Button(top, bg=bbg, fg=fg, text='查看行名', command=get_Index, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='查看列名', command=get_Column, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='显示表格', command=Write_Sheet, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- global Max_Row, Max_Column
- a_y += 1
- tkinter.Label(top, text='最大显示行数:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
- row=a_y) # 设置说明
- Max_Row = tkinter.Entry(top, width=width_B * 2)
- Max_Row.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
- a_y += 1
- tkinter.Label(top, text='最大显示列数:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
- row=a_y) # 设置说明
- Max_Column = tkinter.Entry(top, width=width_B * 2)
- Max_Column.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
- # Row与Column Row是横行,tkinter布局中Row变大,表示所在行数变大,向下移动如:
- # 1,2,3,4,5,6
- # 7,8,9,a,b,c
- # 其中数字1-6是第一行,1-c是第二行,第二行在第一行下面,row变大向下移动(Row是横向行而不是横向移动) to 搞不清楚横行竖列的人
- a_y += 1
- Index_BOX = tkinter.Listbox(top, width=width_B * 3, height=height_B * 10) # 显示符号
- Index_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=10, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
- global Des_Bool
- a_y += 10
- tkinter.Button(top, bg=bbg, fg=fg, text='查看数据分析', command=Show_Des, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='简单数据统计', command=Show_describe, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- Des_Bool = tkinter.IntVar() # 是否启用
- tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='生成统计表格',
- variable=Des_Bool).grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
- a_x += 3
- tkinter.Label(top, text='', bg=bg, fg=fg, font=FONT, width=1).grid(column=a_x, row=a_y) # 设置说明
- a_x += 1
- a_y = 0
- tkinter.Label(top, text='【数据清洗】', bg=bg, fg=fg, font=FONT, width=width_B * 3, height=height_B).grid(column=a_x,
- columnspan=3,
- row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N) # 设置说明
- global Slice_new, Column_Type, Row_Type, Column_clist, Row_clist
- Column_clist = []
- Row_clist = []
- label = ['启始(列号):', '终止(列):', '间隔(列):']
- for i in range(3):
- a_y += 1
- tkinter.Label(top, text=label[i], bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
- row=a_y) # 设置说明
- Column_clist.append(tkinter.Entry(top, width=width_B * 2))
- Column_clist[-1].grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.W + tkinter.E)
- label = ['启始(行号):', '终止(行):', '间隔(行):']
- for i in range(3):
- a_y += 1
- tkinter.Label(top, text=label[i], bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
- row=a_y) # 设置说明
- Row_clist.append(tkinter.Entry(top, width=width_B * 2))
- Row_clist[-1].grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.W + tkinter.E)
- a_y += 1
- Column_Type = tkinter.IntVar()
- lable = ['根据列号', '根据列名', '输入列号'] # 复选框
- for i in range(3):
- tkinter.Radiobutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text=lable[i],
- variable=Column_Type, value=i). \
- grid(column=a_x + i, row=a_y, sticky=tkinter.W)
- a_y += 1
- Row_Type = tkinter.IntVar()
- lable = ['根据行号', '根据行名', '输入行号'] # 复选框
- for i in range(3):
- tkinter.Radiobutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text=lable[i],
- variable=Row_Type, value=i). \
- grid(column=a_x + i, row=a_y, sticky=tkinter.W)
- a_y += 1
- Slice_new = tkinter.IntVar()
- tkinter.Button(top, bg=bbg, fg=fg, text='切片选定', command=Slice_Data, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='删除选定', command=Del_Data, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='生成新表格',
- variable=Slice_new).grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
- global Bool_E, Drop_Column
- a_y += 1
- tkinter.Label(top, text='布尔逻辑:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
- row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N) # 设置说明
- Bool_E = tkinter.Entry(top, width=width_B * 2)
- Bool_E.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.W + tkinter.E)
- a_y += 1
- tkinter.Label(top, text='操作的列号:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
- row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N) # 设置说明
- Drop_Column = tkinter.Entry(top, width=width_B * 2)
- Drop_Column.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.W + tkinter.E)
- a_y += 1
- tkinter.Button(top, bg=bbg, fg=fg, text='生成布尔表格', command=Make_BoolSheet, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='查看空值', command=is_Na, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='清洗空值(按行)', command=Done_NaN, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- a_y += 1
- tkinter.Button(top, bg=bbg, fg=fg, text='添加执行方法', command=Add_Clean, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='删除执行方法', command=Del_Clean, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='数据特征提取', command=DecisionTreeClassifier, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- global Done_CleanBox, Done_Func
- a_y += 1
- Done_CleanBox = tkinter.Listbox(top, width=width_B * 3, height=height_B * 2)
- Done_CleanBox.grid(column=a_x, row=a_y, columnspan=3, rowspan=2,
- sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
- a_y += 2
- tkinter.Button(top, bg=bbg, fg=fg, text='查看词典', command=Show_Help, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='恢复显示', command=get_InsertClean_Text, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='执行数据清洗', command=Done_Clean, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- a_y += 1
- Done_Func = tkinter.Text(top, width=width_B * 3, height=height_B * 7)
- Done_Func.grid(column=a_x, row=a_y, columnspan=3, rowspan=7, sticky=tkinter.E + tkinter.W + tkinter.N + tkinter.S)
- Done_Func.insert('0.0', Clean_Text)
- a_y += 7
- tkinter.Button(top, bg=bbg, fg=fg, text='清空执行方法', command=Tra_Clean, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='查看执行方法', command=get_CleanEXP, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='导入执行方法', command=Open_Python, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- a_x += 3
- tkinter.Label(top, text='', bg=bg, fg=fg, font=FONT, width=1).grid(column=a_x, row=a_y) # 设置说明
- a_x += 1
- a_y = 0
- tkinter.Label(top, text='【数据可视化】', bg=bg, fg=fg, font=FONT, width=width_B * 3, height=height_B).grid(column=a_x,
- columnspan=3,
- row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N) # 设置说明
- a_y += 1
- tkinter.Button(top, bg=bbg, fg=fg, text='生成柱状图', command=to_Bar, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='生成3D柱状图', command=to_Bar3d, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='生成折线图', command=to_Line, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- a_y += 1
- tkinter.Button(top, bg=bbg, fg=fg, text='生成3D折线图', command=to_Line3D, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='生成象形柱状图', command=to_Pictorialbar, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y, columnspan=2,
- sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
- a_y += 1
- tkinter.Button(top, bg=bbg, fg=fg, text='生成散点图', command=to_Scatter, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='生成3D散点图', command=to_Scatter3D, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='生成箱形图', command=to_Boxpolt, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- a_y += 1
- tkinter.Button(top, bg=bbg, fg=fg, text='生成漏斗图', command=to_Funnel, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='生成热力图', command=to_HeatMap, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='生成饼图', command=to_Pie, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
- a_y += 1
- tkinter.Button(top, bg=bbg, fg=fg, text='生成多轴图', command=to_Parallel, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='生成极坐标图', command=to_Polar, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='生成雷达图', command=to_Radar, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- a_y += 1
- tkinter.Button(top, bg=bbg, fg=fg, text='生成词云', command=to_WordCloud, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='生成关系图', command=to_Graph, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='生成XY关系图', command=to_XY_Graph, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- a_y += 1
- tkinter.Button(top, bg=bbg, fg=fg, text='生成水球图', command=to_Liquid, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y, columnspan=2,
- sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='生成仪表图', command=to_Gauge, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- a_y += 1
- tkinter.Button(top, bg=bbg, fg=fg, text='生成日历图', command=to_Calendar, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='生成河流图', command=to_ThemeRiver, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='生成旭日图', command=to_Sunburst, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- a_y += 1
- tkinter.Button(top, bg=bbg, fg=fg, text='生成桑基图', command=to_Sankey, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='生成树状图', command=to_Tree, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='生成矩形树图', command=to_TreeMap, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- a_y += 1
- tkinter.Button(top, bg=bbg, fg=fg, text='生成Map地图', command=to_Map, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='生成Geo点地图', command=to_ScatterGeo, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='生成Geo地图', command=to_Geo, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- a_y += 1
- tkinter.Button(top, bg=bbg, fg=fg, text='选择底图', command=Over_Down_Add, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='选择顶图', command=Over_UP_Add, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='生成层叠图', command=to_OverLap, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- a_y += 1
- global R_BOX, Args_Input, Over_BOX
- Over_BOX = tkinter.Listbox(top, width=width_B * 3, height=height_B * 2)
- Over_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=2, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
- a_y += 1
- tkinter.Button(top, bg=bbg, fg=fg, text='渲染HTML', command=Draw, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='单独渲染HTML', command=Draw_One, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='删除渲染', command=Del_R_BOX, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- a_y += 1
- R_BOX = tkinter.Listbox(top, width=width_B * 3, height=height_B)
- R_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=2, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
- a_y += 2
- global Draw_asWell
- Draw_asWell = tkinter.IntVar()
- tkinter.Button(top, bg=bbg, fg=fg, text='清空渲染', command=Tra_RDic, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='导入渲染', command=Import_c, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='马上渲染',
- variable=Draw_asWell).grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
- a_y += 1
- Args_Input = tkinter.Text(top, width=width_B * 3, height=height_B * 7)
- Args_Input.grid(column=a_x, row=a_y, columnspan=3, rowspan=7, sticky=tkinter.E + tkinter.W + tkinter.N + tkinter.S)
- a_y += 7
- tkinter.Button(top, bg=bbg, fg=fg, text='查看词典',command=Show_Help, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='恢复显示',command=Show_Help, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y, columnspan=2,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- a_x += 3
- tkinter.Label(top, text='', bg=bg, fg=fg, font=FONT, width=1).grid(column=a_x, row=a_y) # 设置说明
- a_x += 1
- a_y = 0
- tkinter.Label(top, text='【行名与列名】', bg=bg, fg=fg, font=FONT, width=width_B * 3, height=height_B).grid(column=a_x,
- columnspan=3,
- row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N) # 设置说明
- global replace_Dic, Repalce_RC, replace_iloc, Date_Input, RC_Type
- a_y += 1
- Repalce_RC = tkinter.IntVar()
- lable = ['(列数据)调整行名', '(行数据)调整列名'] # 复选框
- for i in range(2):
- tkinter.Radiobutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text=lable[i],
- variable=Repalce_RC, value=i).grid(column=a_x + i, row=a_y, sticky=tkinter.W)
- tkinter.Button(top, bg=bbg, fg=fg, text='植入行(列)号', command=num_withName, font=FONT, width=width_B, height=height_B). \
- grid(column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
- a_y += 1
- RC_Type = []
- lable = ['保留原值', '保留新值'] # 复选框
- for i in range(2):
- RC_Type.append(tkinter.IntVar())
- tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text=lable[i],
- variable=RC_Type[-1]).grid(column=a_x + i, row=a_y, sticky=tkinter.W)
- tkinter.Button(top, bg=bbg, fg=fg, text='统一行(列)号', command=num_toName, font=FONT, width=width_B, height=height_B). \
- grid(column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
- a_y += 1
- tkinter.Label(top, text='替换字典:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
- row=a_y) # 设置说明
- replace_Dic = tkinter.Entry(top, width=width_B * 2)
- replace_Dic.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
- a_y += 1
- tkinter.Label(top, text='替换列(行):', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
- row=a_y) # 设置说明
- replace_iloc = tkinter.Entry(top, width=width_B * 2)
- replace_iloc.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
- a_y += 1
- tkinter.Button(top, bg=bbg, fg=fg, text='执行替换已有列(行)操作', command=Change_Index, font=FONT, width=width_B * 2,
- height=height_B). \
- grid(column=a_x, columnspan=2, row=a_y, sticky=tkinter.E + tkinter.W)
- tkinter.Button(top, bg=bbg, fg=fg, text='执行替换操作', command=Replace_Index, font=FONT, width=width_B, height=height_B). \
- grid(column=a_x + 2, row=a_y, sticky=tkinter.E + tkinter.W)
- label = ['起点', '终点', '间隔']
- Date_Input = []
- for i in range(3):
- a_y += 1
- tkinter.Label(top, text='时间序列' + label[i], bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(
- column=a_x, row=a_y) # 设置说明
- Date_Input.append(tkinter.Entry(top, width=width_B * 2))
- Date_Input[-1].grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
- global Date_Type
- a_y += 1
- Date_Type = tkinter.IntVar()
- tkinter.Button(top, bg=bbg, fg=fg, text='刷入Date序列', command=Date_Index, font=FONT, width=width_B, height=height_B). \
- grid(column=a_x, row=a_y, sticky=tkinter.E + tkinter.W)
- tkinter.Button(top, bg=bbg, fg=fg, text='刷入Time序列', command=Time_index, font=FONT, width=width_B, height=height_B). \
- grid(column=a_x + 1, row=a_y, sticky=tkinter.E + tkinter.W)
- tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='使用间隔',
- variable=Date_Type).grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
- global Dtype_Column, Dtype_Input, Dtype_Wrong, Dtype_Func
- a_y += 1
- tkinter.Label(top, text='【数据类型管理】', bg=bg, fg=fg, font=FONT, width=width_B * 3, height=height_B).grid(column=a_x,
- columnspan=3,
- row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N) # 设置说明
- a_y += 1
- tkinter.Label(top, text='修改(列号):', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
- row=a_y) # 设置说明
- Dtype_Column = tkinter.Entry(top, width=width_B * 2)
- Dtype_Column.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
- a_y += 1
- tkinter.Label(top, text='数据类型:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
- row=a_y) # 设置说明
- Dtype_Input = tkinter.Entry(top, width=width_B * 2)
- Dtype_Input.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
- a_y += 1
- tkinter.Label(top, text='错误值:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
- row=a_y) # 设置说明
- Dtype_Wrong = tkinter.Entry(top, width=width_B * 2)
- Dtype_Wrong.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
- a_y += 1
- tkinter.Button(top, bg=bbg, fg=fg, text='执行转换', command=DTYPE, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- Dtype_Func = tkinter.IntVar() # 正,负,0
- lable = ['硬转换', '软转换'] # 复选框
- for i in range(2):
- tkinter.Radiobutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text=lable[i],
- variable=Dtype_Func, value=i).grid(column=a_x + 1 + i, row=a_y, sticky=tkinter.W)
- a_y += 1
- tkinter.Label(top, text='【排序操作】', bg=bg, fg=fg, font=FONT, width=width_B * 3, height=height_B).grid(column=a_x,
- columnspan=3,
- row=a_y) # 设置说明
- a_y += 1
- tkinter.Button(top, bg=bbg, fg=fg, text='.T', command=T, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='按行名排序', command=Stored_Row, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='按列名排序', command=Stored_Column, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- global Sort_By, Ascending_Type, Ascending_New, Stored_BOX
- a_y += 1
- tkinter.Label(top, text='基准列(列号):', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,
- row=a_y) # 设置说明
- Sort_By = tkinter.Entry(top, width=width_B + 2)
- Sort_By.grid(column=a_x + 1, row=a_y, sticky=tkinter.W)
- tkinter.Button(top, bg=bbg, fg=fg, text='按数据排序', command=Stored_Value, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- a_y += 1
- Ascending_Type = tkinter.IntVar()
- Ascending_New = tkinter.IntVar()
- lable = ['正序排列', '倒序排列'] # 复选框
- for i in range(2):
- tkinter.Radiobutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text=lable[i],
- variable=Ascending_Type, value=i). \
- grid(column=a_x + i, row=a_y, sticky=tkinter.W)
- tkinter.Checkbutton(top, bg=bg, fg=fg, activebackground=bg, activeforeground=fg, selectcolor=bg, text='生成新表格',
- variable=Ascending_New).grid(column=a_x + 2, row=a_y, sticky=tkinter.W)
- a_y += 1
- Stored_BOX = tkinter.Listbox(top, width=width_B * 3, height=height_B * 4) # 显示符号
- Stored_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=5, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
- a_y += 5
- tkinter.Button(top, bg=bbg, fg=fg, text='添加基准', command=add_Stored_Value, font=FONT, width=width_B,
- height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='删除基准', command=Delete_Stored_Value, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='打乱表格', command=Sample_Data, font=FONT, width=width_B,
- height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- a_x += 3
- tkinter.Label(top, text='', bg=bg, fg=fg, font=FONT, width=1).grid(column=a_x, row=a_y) # 设置说明
- a_x += 1
- a_y = 0
- tkinter.Label(top, text='【机器学习】', bg=bg, fg=fg, font=FONT, width=width_B * 3, height=height_B).grid(column=a_x,
- columnspan=3,
- row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N) # 设置说明
- global ML_BOX,ML_OUT
- a_y += 1
- ML_OUT = tkinter.StringVar()
- Put = tkinter.Entry(top, width=width_B * 2,textvariable = ML_OUT)
- Put.grid(column=a_x, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
- Put['state'] = 'readonly'
- tkinter.Button(top, bg=bbg, fg=fg, text='选用学习器',command=set_Learner, font=FONT, width=width_B,height=height_B).grid(column=a_x+2, row=a_y, sticky=tkinter.E + tkinter.W)
- global Split_Input
- a_y += 1
- tkinter.Label(top, text='测试数据分割:', bg=bg, fg=fg, font=FONT, width=width_B, height=height_B).grid(column=a_x,row=a_y)
- Split_Input = tkinter.Entry(top, width=width_B * 2)
- Split_Input.grid(column=a_x + 1, row=a_y, columnspan=2, sticky=tkinter.E + tkinter.W)
- a_y += 1
- ML_BOX = tkinter.Listbox(top, width=width_B * 3, height=height_B*5)
- ML_BOX.grid(column=a_x, row=a_y, columnspan=3, rowspan=5, sticky=tkinter.E + tkinter.W + tkinter.S + tkinter.N)
- a_y += 5
- tkinter.Button(top, bg=bbg, fg=fg, text='导入学习器', command=Draw, font=FONT, width=width_B,height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='查看数据', command=Show_Args, font=FONT, width=width_B,height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='删除学习器', command=Del_Leaner, font=FONT, width=width_B,height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- a_y += 1
- tkinter.Button(top, bg=bbg, fg=fg, text='训练机器', command=Fit_Learner, font=FONT, width=width_B,height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='测试机器', command=Score_Learner, font=FONT, width=width_B,height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='数据预测', command=Predict_Learner, font=FONT, width=width_B,height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- a_y += 1
- tkinter.Label(top, text='【学习器选择和配置】', bg=bg, fg=fg, font=FONT, width=width_B * 3, height=height_B).grid(column=a_x,
- columnspan=3,
- row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N) # 设置说明
- a_y += 1
- tkinter.Button(top, bg=bbg, fg=fg, text='线性回归', command=Add_Line, font=FONT, width=width_B,height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='岭回归', command=Add_Ridge, font=FONT, width=width_B,height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='Lasso', command=Add_Lasso, font=FONT, width=width_B,height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- a_y += 1
- tkinter.Button(top, bg=bbg, fg=fg, text='逻辑回归', command=Add_LogisticRegression, font=FONT, width=width_B,height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='决策树', command=ML_Sorry, font=FONT, width=width_B,height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='SVM', command=ML_Sorry, font=FONT, width=width_B,height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- a_y += 1
- tkinter.Button(top, bg=bbg, fg=fg, text='朴素贝叶斯', command=ML_Sorry, font=FONT, width=width_B,height=height_B).grid(column=a_x, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='K邻近分类', command=Add_Knn, font=FONT, width=width_B,height=height_B).grid(column=a_x + 1, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- tkinter.Button(top, bg=bbg, fg=fg, text='K邻近预测', command=Add_Knn_Class, font=FONT, width=width_B,height=height_B).grid(column=a_x + 2, row=a_y,
- sticky=tkinter.E + tkinter.W + tkinter.W + tkinter.S + tkinter.N)
- global Args_Learner
- a_y += 1
- Args_Learner = tkinter.Text(top, width=width_B * 3, height=height_B * 11)
- Args_Learner.grid(column=a_x, row=a_y, columnspan=3, rowspan=11, sticky=tkinter.E + tkinter.W + tkinter.N + tkinter.S)
- top.mainloop()
- def Show_Help():
- tkinter.messagebox.showinfo('使用提示', Args_Help)
- def ML_Sorry():
- tkinter.messagebox.showinfo('非常抱歉', '高级别的机器学习请到机器学习板块深入研究...')
- def Tra_RDic():
- ML.Tra_RDic()
- Update_R_BOX()
- def Del_Sheet():
- name = get_Name()
- ML.Del_Form(name)
- Updat_BOX()
- def Del_Leaner():
- Learn = get_Learner(True)
- set_Learne = get_Learner(False)#获取学习器Learner
- if set_Learne != Learn:
- ML.Del_Leaner(Learn)
- Update_Leaner()
- def Show_Args():
- learner = get_Learner(True)
- new = tkinter.messagebox.askokcancel('提示', f'是否将数据生成表格。\n(可绘制成散点图对比数据)')
- print(new)
- Data = ML.Show_Args(learner,new)
- title = f'CoTan数据处理 查看数据:{learner}'
- Creat_TextSheet(f'对象:{learner}\n\n{Data[0]}\n\n\n{Data[1]}', title)
- Updat_BOX()
- def get_Args_Learner():
- global Args_Learner
- return Args_Learner.get('0.0',tkinter.END)
- def Score_Learner():
- name = get_Name()#表格数据
- learner = get_Learner()
- try:
- split = float(Split_Input.get())
- if split < 0 or 1 < split:raise Exception
- except:split = 0.3
- socore = ML.Fit(name,learner,Score_Only=True,split=split)[1]
- tkinter.messagebox.showinfo('测试完成', f'针对测试数据评分结果为:{socore}')
- def Predict_Learner():
- name = get_Name()#表格数据
- learner = get_Learner()
- Data = ML.Predict(name,learner)
- title = f'CoTan数据处理 表格:{name} 学习器:{learner}'
- Creat_TextSheet(Data, title)
- Updat_BOX()
- def Fit_Learner():
- name = get_Name()#表格数据
- learner = get_Learner()
- try:
- split = float(Split_Input.get())
- if split < 0 or 1 < split:raise Exception
- except:split = 0.3
- socore = ML.Fit(name,learner,Text=get_Args_Learner(),split=split)
- tkinter.messagebox.showinfo('训练完成', f'针对训练数据({(1-split)*100}%)评分结果为:{socore[0]}\n'
- f'针对测试数据评分({split*100}%)结果为:{socore[1]}')
- def set_Learner():
- global ML_OUT
- ML_OUT.set(get_Learner(True))
- def get_Learner(Type=False):
- global Learn_Dic,ML_BOX,ML_OUT
- if Type:
- try:
- return list(Learn_Dic.keys())[ML_BOX.curselection()[0]]
- except:
- # raise
- try:
- return list(Learn_Dic.keys)[0]
- except:
- return None
- else:
- try:
- return ML_OUT.get()
- except:
- return None
- def Add_Knn_Class():
- Add_leaner('Knn_class')
- def Add_LogisticRegression():
- Add_leaner('LogisticRegression')
- def Add_Lasso():
- Add_leaner('Lasso')
- def Add_Knn():
- Add_leaner('Knn')
- def Add_Ridge():
- Add_leaner('Ridge')
- def Add_Line():
- Add_leaner('Line')
- def Add_leaner(Type):#添加Lenear的核心
- ML.Add_Learner(Type,Text=get_Args_Learner())
- Update_Leaner()
- def Update_Leaner():
- global Learn_Dic,ML_BOX
- Learn_Dic = ML.Return_Learner()
- ML_BOX.delete(0,tkinter.END)
- ML_BOX.insert(tkinter.END,*Learn_Dic.keys())
- def DecisionTreeClassifier():
- name = get_Name()
- ML.DecisionTreeClassifier(name)
- Updat_BOX()
- def Replace_Index():
- global replace_Dic, Repalce_RC, ML
- name = get_Name()
- Dic = eval(replace_Dic.get())
- is_Column = bool(Repalce_RC.get()) # 操作行-False,操作列-True
- save = bool(RC_Type[0].get())
- ML.Replace_Index(name, is_Column, Dic, save)
- Updat_BOX()
- def Change_Index():
- global Repalce_RC, replace_iloc, RC_Type, ML
- name = get_Name() # 名字
- is_Column = bool(Repalce_RC.get()) # 操作行名-False,操作列名-True
- iloc = int(replace_iloc.get()) # 替换的列号(行号)
- save = bool(RC_Type[0].get())
- drop = not bool(RC_Type[1].get())
- ML.Change_Index(name, is_Column, iloc, save, drop)
- Updat_BOX()
- def num_toName():
- global Repalce_RC, replace_iloc, RC_Type, ML
- name = get_Name() # 名字
- is_Column = bool(Repalce_RC.get()) # 操作行名-False,操作列名-True
- save = bool(RC_Type[0].get())
- ML.num_toName(name, is_Column, save)
- Updat_BOX()
- def num_withName():
- global Repalce_RC, RC_Type, ML
- name = get_Name() # 名字
- is_Column = bool(Repalce_RC.get()) # 操作行名-False,操作列名-True
- save = bool(RC_Type[0].get())
- ML.num_withName(name, is_Column, save)
- Updat_BOX()
- def DateTime_Index(is_Date=True):
- global Repalce_RC, RC_Type, ML, Date_Input, Date_Type
- name = get_Name() # 名字
- is_Column = bool(Repalce_RC.get()) # 操作行名-False,操作列名-True
- save = bool(RC_Type[0].get())
- k = ['start', 'end', 'freq']
- Init = {}
- for i in range(len(Date_Input)):
- Input = Date_Input[i].get()
- if Input == '': continue
- Init[k[i]] = Input
- if len(Init) == 3:
- if bool(Date_Type.get()): # 使用间隔
- del Init['end']
- else:
- del Init['freq']
- if is_Date:
- ML.Date_Index(name, is_Column, save, **Init)
- else:
- ML.Time_Index(name, is_Column, save, **Init)
- Updat_BOX()
- def Date_Index():
- DateTime_Index(True)
- def Time_index():
- DateTime_Index(False)
- def DTYPE():
- global Dtype_Column, Dtype_Input, Dtype_Wrong, Dtype_Func, ML
- type_ = bool(Dtype_Func.get())
- name = get_Name()
- column_list = Dtype_Column.get().split(',')
- if column_list == ['']: column_list = []
- dtype = Dtype_Input.get()
- wrong = Dtype_Wrong.get()
- if type_: # 软转换
- if wrong != 'ignore': wrong = 'coerce'
- ML.Reasonable_Type(name, column_list, dtype, wrong)
- else:
- ML.as_Type(name, column_list, dtype, 'ignore')
- Updat_BOX()
- def Import_c(): # 导入绘制方法
- global Done_Func
- Dic = askopenfilename(title='打开Python脚本', filetypes=[("Python", ".py"), ("TXT", ".txt")])
- with open(Dic) as f:
- get = f.read()
- Render_ToHTML(ML.Import_c(get), '自定义图')
- def get_ARGS(): # 获取画图的args
- global Args_Input
- return Args_Input.get('0.0', tkinter.END)
- def Draw():
- global R_Dic, R_BOX
- Dic = asksaveasfilename(title='选择渲染保存地址', filetypes=[("HTML", ".html")])
- if Dic == '': return False
- try:
- if Dic[-5:] != '.html': raise Exception
- except:
- Dic += '.html'
- webbrowser.open(ML.Draw_Page(get_ARGS(), Dic))
- Update_R_BOX()
- def Draw_One():
- global R_Dic, R_BOX
- Dic = asksaveasfilename(title='选择渲染保存地址', filetypes=[("HTML", ".html")])
- if Dic == '': return False
- try:
- if Dic[-5:] != '.html': raise Exception
- except:
- Dic += '.html'
- list(R_Dic.values())[R_BOX.curselection()[0]].render(Dic)
- webbrowser.open(Dic)
- Update_R_BOX()
- def to_OverLap():
- global ML, Over_Up, Over_Down
- if Over_Down != None and Over_Up != None:
- try:
- Render_ToHTML(ML.Overlap(Over_Down, Over_Up), f'合成图')
- except:
- raise
- Over_Down = None
- Over_Up = None
- Update_Over_Box()
- def Update_Over_Box():
- global Over_BOX, Over_Down, Over_Up
- Over_BOX.delete(0, tkinter.END)
- if Over_Down != None:
- Over_BOX.insert(tkinter.END, f'底图: {Over_Down}')
- if Over_Up != None:
- Over_BOX.insert(tkinter.END, f'顶图: {Over_Up}')
- def Over_Down_Add():
- global Over_Down
- Over_Down = list(R_Dic.keys())[R_BOX.curselection()[0]]
- Update_Over_Box()
- def Over_UP_Add():
- global Over_Up
- Over_Up = list(R_Dic.keys())[R_BOX.curselection()[0]]
- Update_Over_Box()
- def Del_R_BOX():
- global R_Dic, R_BOX, ML
- key = list(R_Dic.keys())[R_BOX.curselection()[0]]
- ML.Delete_RDic(key)
- Update_R_BOX()
- def Update_R_BOX():
- global R_Dic, R_BOX, ML
- R_Dic = ML.retunr_RDic()
- R_BOX.delete(0, tkinter.END)
- R_BOX.insert(tkinter.END, *R_Dic.keys())
- def Render_ToHTML(c, name):
- global R_Dic, Draw_asWell
- if bool(Draw_asWell.get()):
- c.render(f'{PATH}\\{name}.html')
- Update_R_BOX()
- def to_Geo():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_Geo(name, get_ARGS()), 'Geo地图')
- def to_Map():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_Map(name, get_ARGS()), 'Map地图')
- def to_ScatterGeo():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_ScatterGeo(name, get_ARGS()), 'Geo点地图')
- def to_TreeMap():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_TreeMap(name, get_ARGS()), '矩形树图')
- def to_Tree():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_Tree(name, get_ARGS()), '树状图')
- def to_Sankey():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_Sankey(name, get_ARGS()), '桑基图')
- def to_Sunburst():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_Sunburst(name, get_ARGS()), '旭日图')
- def to_ThemeRiver():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_ThemeRiver(name, get_ARGS()), '河流图')
- def to_Calendar():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_Calendar(name, get_ARGS()), '日历图')
- def to_Gauge():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_Gauge(name, get_ARGS()), '仪表图')
- def to_Liquid():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_Liquid(name, get_ARGS()), '水球图')
- def to_Line3D():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_Line3D(name, get_ARGS()), '3D折线图')
- def to_Scatter3D():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_Scatter3D(name, get_ARGS()), '3D散点图')
- def to_Bar3d():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_Bar3d(name, get_ARGS()), '3D柱状图')
- def to_WordCloud():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_WordCloud(name, get_ARGS()), '词云图')
- def to_Radar():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_Radar(name, get_ARGS()), '雷达图')
- def to_Polar():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_Polar(name, get_ARGS()), '极坐标图')
- def to_Pie():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_Pie(name, get_ARGS()), '饼图')
- def to_Parallel():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_Parallel(name, get_ARGS()), '多轴图')
- def to_XY_Graph():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_XY_Graph(name, get_ARGS()), '关系图')
- def to_Graph():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_Graph(name, get_ARGS()), '关系图')
- def to_Funnel():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_Funnel(name, get_ARGS()), '漏斗图')
- def to_HeatMap():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_HeatMap(name, get_ARGS()), '热力图')
- def to_Boxpolt():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_Boxpolt(name, get_ARGS()), '箱形图')
- def to_Pictorialbar():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_Pictorialbar(name, get_ARGS()), '象形柱状图')
- def to_Scatter():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_Scatter(name, get_ARGS()), '散点图')
- def to_Line():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_Line(name, get_ARGS()), '折线图')
- def to_Bar():
- global ML
- name = get_Name()
- Render_ToHTML(ML.to_Bar(name, get_ARGS()), '柱状图')
- def Show_Help():
- tkinter.messagebox.showinfo('帮助字典', Clean_Help)
- def Open_Python():
- global Done_Func
- Dic = askopenfilename(title='打开Python脚本', filetypes=[("Python", ".py"), ("TXT", ".txt")])
- with open(Dic) as f:
- get = f.read()
- Done_Func.delete('0.0', tkinter.END)
- Done_Func.insert('0.0', get)
- def get_InsertClean_Text():
- global Done_Func, Clean_Text
- Done_Func.delete('0.0', tkinter.END)
- Done_Func.insert('0.0', Clean_Text)
- def get_CleanEXP():
- global ML, Clean_List, Done_CleanBox, Done_Func
- name = Clean_List[Done_CleanBox.curselection()[0]]
- get = ML.Return_CleanExp(name)
- Done_Func.delete('0.0', tkinter.END)
- Done_Func.insert('0.0', get)
- def Tra_Clean():
- global ML
- ML.Tra_Clean()
- Updat_BOX()
- def Done_Clean():
- global ML
- name = get_Name()
- Data = ML.Done_CleanFunc(name)
- title = f'CoTan数据处理 表格:{name}.数据清洗'
- Creat_TextSheet(Data, title)
- Updat_BOX()
- def Del_Clean():
- global ML, Clean_List, Done_CleanBox
- name = Clean_List[Done_CleanBox.curselection()[0]]
- ML.Delete_CleanFunc(name)
- Update_Clean()
- def Update_Clean():
- global ML, Done_CleanBox, Clean_List
- Clean_List = ML.Return_CleanFunc()
- Done_CleanBox.delete(0, tkinter.END)
- Done_CleanBox.insert(tkinter.END, *Clean_List)
- def Add_Clean():
- global ML, Done_CleanBox, Done_Func
- Exp = Done_Func.get('0.0', tkinter.END)
- print(Exp)
- ML.Add_CleanFunc(Exp)
- Update_Clean()
- def Done_NaN():
- global Drop_Column
- name = get_Name()
- Data = ML.Dropna(name, True)
- title = f'CoTan数据处理 表格:{name}.NaN'
- Creat_TextSheet(Data, title)
- Updat_BOX()
- def is_Na():
- global Bool_E
- name = get_Name()
- Data = ML.is_Na(name)
- title = f'CoTan数据处理 表格:{name}.NaN'
- Creat_TextSheet(Data, title)
- Updat_BOX()
- def Make_BoolSheet():
- global Bool_E
- Bool_Exp = Bool_E.get()
- name = get_Name()
- Data = ML.Done_Bool(name, Bool_Exp, True)
- print(Data)
- title = f'CoTan数据处理 表格:{name} 布尔化'
- Creat_TextSheet(Data, title)
- Updat_BOX()
- def Del_Data():
- global Slice_new, Column_clist, Row_clist
- Column = Column_clist[0].get().replace(' ', '').split(',')
- Row = Row_clist[0].get().replace(' ', '').split(',')
- print(Column)
- new = bool(Slice_new.get())
- name = get_Name()
- try:
- Data = ML.Delete(name, Column, Row, new)
- except:
- Data = 'None 你的操作不被允许'
- title = f'CoTan数据处理 表格:{name}'
- Creat_TextSheet(Data, title)
- Updat_BOX()
- def __get_clist(n, t=str):
- a = []
- for i in n:
- b = i.get().replace(' ', '')
- if b == '':
- a.append(None)
- else:
- try:
- a.append(t(b))
- except:
- a.append(None)
- if a[0] != None and a[1] == None:
- a[1] = a[0] + 1
- a[2] = None
- return a
- def Slice_Data():
- global Slice_new, Column_Type, Row_Type, Column_clist, Row_clist
- CT = Column_Type.get()
- U = True
- if CT == 0: # 输入的列号
- Column = slice(*__get_clist(Column_clist, int))
- elif CT == 1:
- U = False
- Column = slice(*__get_clist(Column_clist, str))
- else:
- get = Column_clist[0].get().replace(' ', '').split(',')
- Column = []
- for i in get:
- try:
- Column.append(int(i))
- except:
- pass
- RT = Row_Type.get()
- if RT == 0: # 输入的列号
- Row = slice(*__get_clist(Row_clist, int))
- elif RT == 1:
- Row = slice(*__get_clist(Row_clist, str))
- else:
- get = Row_clist[0].get().replace(' ', '').split(',')
- Row = []
- for i in get:
- try:
- Row.append(int(i))
- except:
- pass
- new = bool(Slice_new.get())
- name = get_Name()
- try:
- Data = ML.get_Clice(name, Column, Row, U, new)
- except:
- Data = 'None 你的操作不被允许'
- title = f'CoTan数据处理 表格:{name}'
- Creat_TextSheet(Data, title)
- Updat_BOX()
- def Sample_Data():
- global ML,Ascending_New
- name = get_Name()
- new = bool(Ascending_New.get())
- Data = ML.Sample(name, new)
- title = f'CoTan数据处理 打乱表格:{name}'
- Creat_TextSheet(Data, title)
- Updat_BOX()
- def Stored_Value():
- global ML, Stored_List,Ascending_New
- name = get_Name()
- new = bool(Ascending_New.get())
- Data = ML.Stored_Valuse(name, Stored_List, new)
- title = f'CoTan数据处理 表格:{name}.Stored'
- Creat_TextSheet(Data, title)
- Updat_BOX()
- def Tra_Stored_Value():
- global Stored_List, Stored_BOX
- Stored_List = []
- Update_Stored()
- def Delete_Stored_Value():
- global Stored_List, Stored_BOX, Ascending_Type
- del Stored_List[Stored_BOX.curselection()[0]]
- Update_Stored()
- def add_Stored_Value(): # 按基准列排行
- global ML, Stored_List, Sort_By, Ascending_Type
- try:
- a = not bool(Ascending_Type.get())
- value = int(Sort_By.get())
- Stored_List.append((value, a))
- except:
- pass
- Update_Stored()
- def Update_Stored():
- global Stored_List, Stored_BOX
- re = []
- d = {True: '正序', False: '倒叙'}
- for i in Stored_List:
- re.append(f"列号:{i[0]}, 排序方式{d[i[1]]}")
- Stored_BOX.delete(0, tkinter.END)
- Stored_BOX.insert(tkinter.END, *re)
- def Stored_Column(): # 行
- global ML
- name = get_Name()
- a = not bool(Ascending_Type.get())
- new = bool(Ascending_New.get())
- Data = ML.Sorted(name, False, new, a)
- title = f'CoTan数据处理 表格:{name}.Stored by Column'
- Creat_TextSheet(Data, title)
- Updat_BOX()
- def Stored_Row(): # 行
- global ML
- name = get_Name()
- new = bool(Ascending_New.get())
- a = not bool(Ascending_Type.get())
- Data = ML.Sorted(name, True, new, a)
- title = f'CoTan数据处理 表格:{name}.Stored by Row'
- Creat_TextSheet(Data, title)
- Updat_BOX()
- def T():
- global ML
- name = get_Name()
- new = bool(Ascending_New.get())
- Data = ML.T(name, new)
- title = f'CoTan数据处理 表格:{name}.T'
- Creat_TextSheet(Data, title)
- Updat_BOX()
- def Show_Des():
- global PATH, top
- if not tkinter.messagebox.askokcancel('提示', f'是否统计数据,大量的数据需要耗费一定的时间(确定后,系统会在后台统计)'): return False
- Dic = f'{PATH}/$Show_Des_Sheet.html'
- try:
- name = get_Name()
- if name == None: raise Exception
- ML.to_Report(name, Dic)
- webbrowser.open(Dic)
- except:
- pass
- def Show_describe():
- global ML, Des_Bool
- Des = bool(Des_Bool.get())
- name = get_Name()
- title = f'CoTan数据处理 表格:{name}_describe'
- Data = str(ML.Describe(name, Des))
- Creat_TextSheet(Data, title)
- Updat_BOX()
- def Write_Sheet():
- global ML, top
- name = get_Name()
- title = f'CoTan数据处理 表格:{name}'
- Data = str(ML.get_Sheet(name))
- Creat_TextSheet(Data, title)
- def Creat_TextSheet(data, name):
- global bg, ft1
- new_top = tkinter.Toplevel(bg=bg)
- new_top.title(name)
- new_top.geometry('+10+10') # 设置所在位置
- text = ScrolledText(new_top, font=ft1, height=50)
- text.pack(fill=tkinter.BOTH)
- text.insert('0.0', data)
- text.config(state=tkinter.DISABLED)
- new_top.resizable(width=False, height=False)
- def get_Column(): # 列名(横行竖列,列名是上面的)
- global ML
- name = get_Name()
- Updat_IndexBOX(ML.get_Column(name))
- def get_Index(): # 行名(横行竖列,行名左)
- global ML
- name = get_Name()
- Updat_IndexBOX(ML.get_Index(name))
- def Updat_IndexBOX(get_Index):
- global top, Index_BOX
- Index_BOX.delete(0, tkinter.END)
- Index_BOX.insert(tkinter.END, *get_Index)
- def Show_One():
- global PATH, to_HTML_Type
- Dic = f'{PATH}/$Show_Sheet.html'
- try:
- name = get_Name()
- if name == None: raise Exception
- ML.to_Html_One(name, Dic)
- webbrowser.open(Dic)
- except:
- # pass
- raise
- def Show():
- global PATH, to_HTML_Type
- Dic = f'{PATH}/$Show_Sheet.html'
- try:
- name = get_Name()
- if name == None: raise Exception
- ML.to_Html(name, Dic, to_HTML_Type.get())
- webbrowser.open(Dic)
- except:
- pass
- def to_CSV():
- global top, Seq_Input, Code_Input, str_must, Index_must
- Dic = asksaveasfilename(title='选择保存的CSV', filetypes=[("CSV", ".csv")])
- Seq = Seq_Input.get()
- name = get_Name()
- ML.to_CSV(name,Dic,Seq)
- Updat_BOX()
- def Add_CSV():
- global top, Seq_Input, Code_Input, str_must, Index_must,name_Input
- Dic = askopenfilename(title='选择载入的CSV', filetypes=[("CSV", ".csv")])
- if Dic == '':return False
- Seq = Seq_Input.get()
- Codeing = Code_Input.get()
- str_ = bool(str_must.get())
- Index = bool(Index_must.get())
- name = name_Input.get().replace(' ','')
- if name == '':
- name = os.path.splitext(os.path.split(Dic)[1])[0]
- print(name)
- if Codeing == '':
- with open(Dic, 'rb') as f:
- Codeing = chardet.detect(f.read())['encoding']
- if Seq == '': Seq = ','
- ML.Add_CSV(Dic, name, Seq, Codeing, str_, Index)
- Updat_BOX()
- def Add_Python():
- global top, Seq_Input, Code_Input, str_must, Index_must
- Dic = askopenfilename(title='选择载入的py', filetypes=[("Python", ".py"), ("Txt", ".txt")])
- name = name_Input.get().replace(' ','')
- if name == '':
- name = os.path.splitext(os.path.split(Dic)[1])[0]
- with open(Dic, 'r') as f:
- ML.Add_Python(f.read(), name)
- Updat_BOX()
- def get_Name(): # 获得名字统一接口
- global Form_List
- try:
- return Form_List[Form_BOX.curselection()[0]]
- except:
- try:
- return Form_List[0]
- except:
- return None
- def Updat_BOX():
- global top, Form_BOX, Form_List
- Form_List = ML.get_FormList()
- Form_BOX.delete(0, tkinter.END)
- Form_BOX.insert(tkinter.END, *Form_List)
|