From a9aedaff229d67abe6b8c622d2ab64b5927d84dd Mon Sep 17 00:00:00 2001 From: p7m86wfya <1808174627@qq.com> Date: Sat, 1 Jun 2024 21:54:31 +0800 Subject: [PATCH] ADD file via upload --- main.py | 671 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 671 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..b28aa58 --- /dev/null +++ b/main.py @@ -0,0 +1,671 @@ +from Matlib import * +from tkinter import * +from tkintertable import TableCanvas, TableModel +from tkinter import ttk + +#l=-180 +#r=360 +#a=2 +#den=30 +#dis=0 + +#PolylineG1(l,r,den,a,dis) +#x=[1,2,3,4,5] +#y=[2,-1,-4,3,1] +#BarG(x,y) +#Sine(l,r,50,dis) +#x=[1,2,3,4,5,6] +#y=['s','e','r','t','f','g'] +#data=pd.DataFrame(x,y) + + +#data.plot.bar(x=data.get(x),y=data.get(y),color='blue') +#plt.show() + +def Functionmain(): + def PolylineG1main(): + root1_1.destroy() + def G1Creat(): + PolylineG1(int(eXRangeL.get()),int(eXRangeR.get()),int(eDen.get()),int(eA.get()),int(eDis.get())) + + def back(): + root1_1_1.destroy() + Functionmain() + + root1_1_1 = Frame(root, width=960, height=540) + root1_1_1.pack() + FunNameLaber=Label(root1_1_1,text='',font=('Arial',30)) + FunNameLaber.place(x=200,y=50) + #函数公式部分 + yLaber=Label(root1_1_1,text='y = ',font=('Arial',30)) + yLaber.place(x=280,y=90) + eA=Entry(root1_1_1,width=7) + eA.place(x=340,y=110) + XLaber = Label(root1_1_1, text='x', font=('Arial', 30)) + XLaber.place(x=395,y=90) + opLaber=Label(root1_1_1, text=' + ', font=('Arial', 30)) + opLaber.place(x=420,y=95) + eDis=Entry(root1_1_1,width=7) + eDis.place(x=490,y=110) + + #样本数 + DenLaber=Label(root1_1_1,text='样本数',font=('Arial',30)) + DenLaber.place(x=280,y=180) + eDen=Entry(root1_1_1,width=7) + eDen.place(x=410,y=200) + + #取值范围 + XRangeLaber=Label(root1_1_1,text='取值范围',font=('Arial',30)) + XRangeLaber.place(x=280,y=270) + Xleft=Label(root1_1_1,text='left',font=('Arial',30)) + Xleft.place(x=460,y=270) + eXRangeL=Entry(root1_1_1,width=7) + eXRangeL.place(x=530,y=290) + XRigt=Label(root1_1_1,text='rigt',font=('Arial',30)) + XRigt.place(x=600,y=270) + eXRangeR = Entry(root1_1_1, width=7) + eXRangeR.place(x=670, y=290) + + #生成 + b_Creat=Button(root1_1_1,text='生成',command=G1Creat) + b_Creat.place(x=320,y=400,width=90, height=60) + + #返回 + b_back = Button(root1_1_1, text='返 回', command=back) + b_back.place(x=910, y=10, width=30, height=20) + + + def PolylineG2main(): + root1_1.destroy() + + def G2Creat(): + PolylineG2(int(eXRangeL.get()),int(eXRangeR.get()),int(eDen.get()),int(eA.get()),int(eB.get()),int(eDis.get())) + def back(): + root1_1_2.destroy() + Functionmain() + + root1_1_2 = Frame(root, width=960, height=540) + root1_1_2.pack() + FunNameLaber = Label(root1_1_2, text='', font=('Arial', 30)) + FunNameLaber.place(x=200, y=50) + # 函数公式部分 + yLaber = Label(root1_1_2, text='y = ', font=('Arial', 30)) + yLaber.place(x=280, y=90) + eA = Entry(root1_1_2, width=7) + eA.place(x=340, y=110) + XSLaber = Label(root1_1_2, text='x^2', font=('Arial', 30)) + XSLaber.place(x=395, y=90) + opLaber1 = Label(root1_1_2, text=' + ', font=('Arial', 30)) + opLaber1.place(x=460, y=95) + eB = Entry(root1_1_2, width=7) + eB.place(x=520, y=110) + XLaber2=Label(root1_1_2, text='x', font=('Arial', 30)) + XLaber2.place(x=575, y=90) + opLaber = Label(root1_1_2, text=' + ', font=('Arial', 30)) + opLaber.place(x=610, y=95) + eDis=Entry(root1_1_2, width=7) + eDis.place(x=680, y=110) + + # 样本数 + DenLaber = Label(root1_1_2, text='样本数', font=('Arial', 30)) + DenLaber.place(x=280, y=180) + eDen = Entry(root1_1_2, width=7) + eDen.place(x=410, y=200) + + # 取值范围 + XRangeLaber = Label(root1_1_2, text='取值范围', font=('Arial', 30)) + XRangeLaber.place(x=280, y=270) + Xleft = Label(root1_1_2, text='left', font=('Arial', 30)) + Xleft.place(x=460, y=270) + eXRangeL = Entry(root1_1_2, width=7) + eXRangeL.place(x=530, y=290) + XRigt = Label(root1_1_2, text='rigt', font=('Arial', 30)) + XRigt.place(x=600, y=270) + eXRangeR = Entry(root1_1_2, width=7) + eXRangeR.place(x=670, y=290) + + # 生成 + b_Creat = Button(root1_1_2, text='生成', command=G2Creat) + b_Creat.place(x=320, y=400, width=90, height=60) + + #返回 + b_back = Button(root1_1_2, text='返 回', command=back) + b_back.place(x=910, y=10, width=30, height=20) + + def PolylineG3main(): + root1_1.destroy() + def G3Creat(): + PolylineG3(int(eXRangeL.get()),int(eXRangeR.get()),int(eDen.get()),int(eA.get()),int(eB.get()),int(eD.get()),int(eDis.get())) + def back(): + root1_1_3.destroy() + Functionmain() + + root1_1_3 = Frame(root, width=960, height=540) + root1_1_3.pack() + FunNameLaber = Label(root1_1_3, text='', font=('Arial', 30)) + FunNameLaber.place(x=200, y=50) + # 函数公式部分 + yLaber = Label(root1_1_3, text='y = ', font=('Arial', 30)) + yLaber.place(x=280, y=90) + eA = Entry(root1_1_3, width=7) + eA.place(x=340, y=110) + XCLaber = Label(root1_1_3, text='x^3', font=('Arial', 30)) + XCLaber.place(x=395, y=90) + opLaber1 = Label(root1_1_3, text=' + ', font=('Arial', 30)) + opLaber1.place(x=460, y=95) + eB = Entry(root1_1_3, width=7) + eB.place(x=520, y=110) + XSLaber = Label(root1_1_3, text='x^2', font=('Arial', 30)) + XSLaber.place(x=575, y=90) + opLaber2 = Label(root1_1_3, text=' + ', font=('Arial', 30)) + opLaber2.place(x=640, y=95) + eD=Entry(root1_1_3, width=7) + eD.place(x=700, y=110) + XLaber2 = Label(root1_1_3, text='x', font=('Arial', 30)) + XLaber2.place(x=760, y=90) + opLaber3 = Label(root1_1_3, text=' + ', font=('Arial', 30)) + opLaber3.place(x=790, y=95) + eDis = Entry(root1_1_3, width=7) + eDis.place(x=840, y=110) + + # 样本数 + DenLaber = Label(root1_1_3, text='样本数', font=('Arial', 30)) + DenLaber.place(x=280, y=180) + eDen = Entry(root1_1_3, width=7) + eDen.place(x=410, y=200) + + # 取值范围 + XRangeLaber = Label(root1_1_3, text='取值范围', font=('Arial', 30)) + XRangeLaber.place(x=280, y=270) + Xleft = Label(root1_1_3, text='left', font=('Arial', 30)) + Xleft.place(x=460, y=270) + eXRangeL = Entry(root1_1_3, width=7) + eXRangeL.place(x=530, y=290) + XRigt = Label(root1_1_3, text='rigt', font=('Arial', 30)) + XRigt.place(x=600, y=270) + eXRangeR = Entry(root1_1_3, width=7) + eXRangeR.place(x=670, y=290) + + # 生成 + b_Creat = Button(root1_1_3, text='生成', command=G3Creat) + b_Creat.place(x=320, y=400, width=90, height=60) + + + b_back = Button(root1_1_3, text='返 回', command=back) + b_back.place(x=910, y=10, width=30, height=20) + + def Sinemain(): + root1_1.destroy() + def G4Creat(): + Sine(int(eXRangeL.get()),int(eXRangeR.get()),int(eDen.get()),int(eDis.get())) + + def back(): + root1_1_4.destroy() + Functionmain() + + root1_1_4 = Frame(root, width=960, height=540) + root1_1_4.pack() + FunNameLaber = Label(root1_1_4, text='', font=('Arial', 30)) + FunNameLaber.place(x=200, y=50) + # 函数公式部分 + yLaber = Label(root1_1_4, text='y = ', font=('Arial', 30)) + yLaber.place(x=280, y=90) + + XLaber = Label(root1_1_4, text='sin(', font=('Arial', 30)) + XLaber.place(x=350, y=90) + eDis = Entry(root1_1_4, width=7) + eDis.place(x=420, y=110) + opLaber1 = Label(root1_1_4, text='度', font=('Arial', 30)) + opLaber1.place(x=470, y=95) + opLaberc = Label(root1_1_4, text=' + ', font=('Arial', 30)) + opLaberc.place(x=520, y=95) + opLaber2 = Label(root1_1_4, text='x)', font=('Arial', 30)) + opLaber2.place(x=570, y=90) + + # 样本数 + DenLaber = Label(root1_1_4, text='样本数', font=('Arial', 30)) + DenLaber.place(x=280, y=180) + eDen = Entry(root1_1_4, width=7) + eDen.place(x=410, y=200) + + # 取值范围 + XRangeLaber = Label(root1_1_4, text='取值范围', font=('Arial', 30)) + XRangeLaber.place(x=280, y=270) + Xleft = Label(root1_1_4, text='left', font=('Arial', 30)) + Xleft.place(x=460, y=270) + eXRangeL = Entry(root1_1_4, width=7) + eXRangeL.place(x=530, y=290) + XRigt = Label(root1_1_4, text='rigt', font=('Arial', 30)) + XRigt.place(x=600, y=270) + eXRangeR = Entry(root1_1_4, width=7) + eXRangeR.place(x=670, y=290) + + # 生成 + b_Creat = Button(root1_1_4, text='生成', command=G4Creat) + b_Creat.place(x=320, y=400, width=90, height=60) + + #返回 + b_back = Button(root1_1_4, text='返 回', command=back) + b_back.place(x=910, y=10, width=30, height=20) + + def Cosinemain(): + root1_1.destroy() + def G5Creat(): + Cosine(int(eXRangeL.get()),int(eXRangeR.get()),int(eDen.get()),int(eDis.get())) + def back(): + root1_1_5.destroy() + Functionmain() + + root1_1_5 = Frame(root, width=960, height=540) + root1_1_5.pack() + FunNameLaber = Label(root1_1_5, text='', font=('Arial', 30)) + FunNameLaber.place(x=200, y=50) + # 函数公式部分 + yLaber = Label(root1_1_5, text='y = ', font=('Arial', 30)) + yLaber.place(x=280, y=90) + + XLaber = Label(root1_1_5, text='cos(', font=('Arial', 30)) + XLaber.place(x=350, y=90) + eDis = Entry(root1_1_5, width=7) + eDis.place(x=430, y=110) + opLaber1 = Label(root1_1_5, text='度', font=('Arial', 30)) + opLaber1.place(x=490, y=95) + opLaberc = Label(root1_1_5, text=' + ', font=('Arial', 30)) + opLaberc.place(x=540, y=95) + opLaber2 = Label(root1_1_5, text='x)', font=('Arial', 30)) + opLaber2.place(x=590, y=90) + + # 样本数 + DenLaber = Label(root1_1_5, text='样本数', font=('Arial', 30)) + DenLaber.place(x=280, y=180) + eDen = Entry(root1_1_5, width=7) + eDen.place(x=410, y=200) + + # 取值范围 + XRangeLaber = Label(root1_1_5, text='取值范围', font=('Arial', 30)) + XRangeLaber.place(x=280, y=270) + Xleft = Label(root1_1_5, text='left', font=('Arial', 30)) + Xleft.place(x=460, y=270) + eXRangeL = Entry(root1_1_5, width=7) + eXRangeL.place(x=530, y=290) + XRigt = Label(root1_1_5, text='rigt', font=('Arial', 30)) + XRigt.place(x=600, y=270) + eXRangeR = Entry(root1_1_5, width=7) + eXRangeR.place(x=670, y=290) + + # 生成 + b_Creat = Button(root1_1_5, text='生成', command=G5Creat) + b_Creat.place(x=320, y=400, width=90, height=60) + + # 返回 + b_back = Button(root1_1_5, text='返 回', command=back) + b_back.place(x=910, y=10, width=30, height=20) + + def back(): + root1_1.destroy() + ChooseDrawmain() + + root1_1 = Frame(root, width=960, height=540) + root1_1.pack() + b_back = Button(root1_1, text='返 回', command=back) + + b1_1 = Button(root1_1, text='一次函数', command=PolylineG1main) + + b1_2 = Button(root1_1, text='二次函数', command=PolylineG2main) + + b1_3 = Button(root1_1, text='三次函数', command=PolylineG3main) + + b1_4 = Button(root1_1, text='正弦函数', command=Sinemain) + + b1_5 = Button(root1_1, text='余弦函数', command=Cosinemain) + + b_back.place(x=910, y=10, width=30, height=20) + b1_1.place(x=320, y=10, width=320, height=90) + b1_2.place(x=320, y=110, width=320, height=90) + b1_3.place(x=320, y=220, width=320, height=90) + b1_4.place(x=320, y=330, width=320, height=90) + b1_5.place(x=320, y=440, width=320, height=90) + +def Chartmain(): + def BarGmain(): + root1_2.destroy() + + def Table(data): + + def add(): + for index in data.index: + if(data.loc[index,'name']=='nan'): + data.loc[index, 'name'] = str(eName_add.get()) + data.loc[index,'y']= float(e_add.get()) + break + print(data['name']) + + def detel(): + for index in data.index: + if(data.loc[index,'name']==eName_del.get()): + data.loc[index, 'name'] = str('nan') + data.loc[index,'y']= float(0) + break + print(data['name']) + + def C1Creat(): + + BarG(data['name'],data[str(eCreat.get())]) + + def flash(): + ary = {'1': {data.columns[0]: str(data.loc[1, 'name']), data.columns[1]: float(data.loc[1, 'y']), + data.columns[2]: float(data.loc[1, 'z']), data.columns[3]: float(data.loc[1, 'w'])}, + '2': {data.columns[0]: str(data.loc[2, 'name']), data.columns[1]: float(data.loc[2, 'y']), + data.columns[2]: float(data.loc[2, 'z']), data.columns[3]: float(data.loc[2, 'w'])}, + '3': {data.columns[0]: str(data.loc[3, 'name']), data.columns[1]: float(data.loc[3, 'y']), + data.columns[2]: float(data.loc[3, 'z']), data.columns[3]: float(data.loc[3, 'w'])}, + '4': {data.columns[0]: str(data.loc[4, 'name']), data.columns[1]: float(data.loc[4, 'y']), + data.columns[2]: float(data.loc[4, 'z']), data.columns[3]: float(data.loc[4, 'w'])}, + '5': {data.columns[0]: str(data.loc[5, 'name']), data.columns[1]: float(data.loc[5, 'y']), + data.columns[2]: float(data.loc[5, 'z']), data.columns[3]: float(data.loc[5, 'w'])}, + '6': {data.columns[0]: str(data.loc[6, 'name']), data.columns[1]: float(data.loc[6, 'y']), + data.columns[2]: float(data.loc[6, 'z']), data.columns[3]: float(data.loc[6, 'w'])}, + '7': {data.columns[0]: str(data.loc[7, 'name']), data.columns[1]: float(data.loc[7, 'y']), + data.columns[2]: float(data.loc[7, 'z']), data.columns[3]: float(data.loc[7, 'w'])}, + '8': {data.columns[0]: str(data.loc[8, 'name']), data.columns[1]: float(data.loc[8, 'y']), + data.columns[2]: float(data.loc[8, 'z']), data.columns[3]: float(data.loc[8, 'w'])}, + } + table = TableCanvas(tframe, data=ary, + cellwidth=60, cellbackgr='#e3f698', + thefont=('Arial', 12), rowheight=18, rowheaderwidth=30, + rowselectedcolor='yellow', editable=True) + table.show() + + rootTable=Tk() + rootTable.geometry('960x540') + tframe=Frame(rootTable) + tframe.pack() + + ary = {'1': {data.columns[0]: str(data.loc[1, 'name']), data.columns[1]: float(data.loc[1, 'y']), + data.columns[2]: float(data.loc[1, 'z']), data.columns[3]: float(data.loc[1, 'w'])}, + '2': {data.columns[0]: str(data.loc[1, 'name']), data.columns[1]: float(data.loc[2, 'y']), + data.columns[2]: float(data.loc[2, 'z']), data.columns[3]: float(data.loc[2, 'w'])}, + '3': {data.columns[0]: str(data.loc[1, 'name']), data.columns[1]: float(data.loc[3, 'y']), + data.columns[2]: float(data.loc[3, 'z']), data.columns[3]: float(data.loc[3, 'w'])}, + '4': {data.columns[0]: str(data.loc[1, 'name']), data.columns[1]: float(data.loc[4, 'y']), + data.columns[2]: float(data.loc[4, 'z']), data.columns[3]: float(data.loc[4, 'w'])}, + '5': {data.columns[0]: str(data.loc[1, 'name']), data.columns[1]: float(data.loc[5, 'y']), + data.columns[2]: float(data.loc[5, 'z']), data.columns[3]: float(data.loc[5, 'w'])}, + '6': {data.columns[0]: str(data.loc[1, 'name']), data.columns[1]: float(data.loc[6, 'y']), + data.columns[2]: float(data.loc[6, 'z']), data.columns[3]: float(data.loc[6, 'w'])}, + '7': {data.columns[0]: str(data.loc[1, 'name']), data.columns[1]: float(data.loc[7, 'y']), + data.columns[2]: float(data.loc[7, 'z']), data.columns[3]: float(data.loc[7, 'w'])}, + '8': {data.columns[0]: str(data.loc[1, 'name']), data.columns[1]: float(data.loc[8, 'y']), + data.columns[2]: float(data.loc[8, 'z']), data.columns[3]: float(data.loc[8, 'w'])}, + } + + model = TableModel() + table = TableCanvas(tframe,data=ary, + cellwidth=60, cellbackgr='#e3f698', + thefont=('Arial',12),rowheight=18, rowheaderwidth=30, + rowselectedcolor='yellow', editable=True) + + + table.width=800 + #table.place(x=1,y=20,width=800,height=300) + #table.width(600) + + + # 返回 + b_back = Button(rootTable, text='返 回', command=back) + b_back.place(x=910, y=510, width=30, height=20) + + #刷新 + b_flash = Button(rootTable, text='刷新', command=flash) + b_flash.place(x=110, y=330, width=50, height=30) + + #添加 + b_add=Button(rootTable,text='添加',command=add) + b_add.place(x=110, y=480, width=150, height=50) + AddNameLaber = Label(rootTable, text='样本名') + AddNameLaber.place(x=50, y=450) + eName_add = Entry(rootTable, width=7) + eName_add.place(x=90, y=450) + AddLaber = Label(rootTable, text='样本值') + AddLaber.place(x=140, y=450) + e_add = Entry(rootTable, width=7) + e_add.place(x=180, y=450) + + #删除 + b_del = Button(rootTable, text='删除', command=detel) + b_del.place(x=280, y=480, width=150, height=50) + DelNameLaber = Label(rootTable, text='样本名') + DelNameLaber.place(x=250, y=450) + eName_del = Entry(rootTable, width=7) + eName_del.place(x=290, y=450) + #DelLaber = Label(rootTable, text='样本值') + #DelLaber.place(x=340, y=450) + #e_del = Entry(rootTable, width=7) + #e_del.place(x=380, y=450) + + #生成 + CreatNameLaber = Label(rootTable, text='样本值名') + CreatNameLaber.place(x=500, y=450) + eCreat = Entry(rootTable, width=7) + eCreat.place(x=560, y=450) + b_creat = Button(rootTable, text='生成', command=C1Creat) + b_creat.place(x=490, y=480, width=150, height=50) + + table.show() + + + def back(): + root1_2_1.destroy() + Chartmain() + + root1_2_1 = Frame(root, width=960, height=540) + root1_2_1.pack() + + #表格 + + df={'name':['nan', 'nan', 'nan', 'nan', 'nan', 'nan', 'nan', 'nan'], + 'y':[0,0,0,0,0,0,0,0], + 'z':[0,0,0,0,0,0,0,0], + 'w':[0,0,0,0,0,0,0,0]} + data=pd.DataFrame(df,index=[1, 2, 3, 4, 5, 6, 7, 8]) + print(data) + + + Table(data) + + for index in data.index: + print(data.loc[index,'y']) + + # 返回 + b_back = Button(root1_2_1, text='返 回', command=back) + b_back.place(x=910, y=10, width=30, height=20) + + def Histogrammain(): + root1_2.destroy() + + def Table(data): + + def add(): + for index in data.index: + if (data.loc[index, 'name'] == 'nan'): + data.loc[index, 'name'] = str(eName_add.get()) + data.loc[index, 'y'] = float(e_add.get()) + break + print(data['name']) + + def detel(): + for index in data.index: + if (data.loc[index, 'name'] == eName_del.get()): + data.loc[index, 'name'] = str('nan') + data.loc[index, 'y'] = float(0) + break + print(data['name']) + + def C2Creat(): + DataHis =([0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0]) + for index in data.index: + if (data.loc[index, 'name'] != 'nan'): + DataHis[0][index] = data.loc[index,'y'] + DataHis[1][index] = data.loc[index, 'z'] + DataHis[2][index] = data.loc[index, 'w'] + + print(DataHis) + Histogram(cums,DataHis) + + def flash(): + ary = {'1': {data.columns[0]: str(data.loc[1, 'name']), data.columns[1]: float(data.loc[1, 'y']), + data.columns[2]: float(data.loc[1, 'z']), data.columns[3]: float(data.loc[1, 'w'])}, + '2': {data.columns[0]: str(data.loc[2, 'name']), data.columns[1]: float(data.loc[2, 'y']), + data.columns[2]: float(data.loc[2, 'z']), data.columns[3]: float(data.loc[2, 'w'])}, + '3': {data.columns[0]: str(data.loc[3, 'name']), data.columns[1]: float(data.loc[3, 'y']), + data.columns[2]: float(data.loc[3, 'z']), data.columns[3]: float(data.loc[3, 'w'])}, + '4': {data.columns[0]: str(data.loc[4, 'name']), data.columns[1]: float(data.loc[4, 'y']), + data.columns[2]: float(data.loc[4, 'z']), data.columns[3]: float(data.loc[4, 'w'])}, + '5': {data.columns[0]: str(data.loc[5, 'name']), data.columns[1]: float(data.loc[5, 'y']), + data.columns[2]: float(data.loc[5, 'z']), data.columns[3]: float(data.loc[5, 'w'])}, + '6': {data.columns[0]: str(data.loc[6, 'name']), data.columns[1]: float(data.loc[6, 'y']), + data.columns[2]: float(data.loc[6, 'z']), data.columns[3]: float(data.loc[6, 'w'])}, + '7': {data.columns[0]: str(data.loc[7, 'name']), data.columns[1]: float(data.loc[7, 'y']), + data.columns[2]: float(data.loc[7, 'z']), data.columns[3]: float(data.loc[7, 'w'])}, + '8': {data.columns[0]: str(data.loc[8, 'name']), data.columns[1]: float(data.loc[8, 'y']), + data.columns[2]: float(data.loc[8, 'z']), data.columns[3]: float(data.loc[8, 'w'])}, + } + table = TableCanvas(tframe, data=ary, + cellwidth=60, cellbackgr='#e3f698', + thefont=('Arial', 12), rowheight=18, rowheaderwidth=30, + rowselectedcolor='yellow', editable=True) + table.show() + for index in data.index: + if (data.loc[index, 'name'] != 'nan'): + cums=cums+1 + print(cums) + + rootTable = Tk() + rootTable.geometry('960x540') + tframe = Frame(rootTable) + tframe.pack() + + ary = {'1': {data.columns[0]: str(data.loc[1, 'name']), data.columns[1]: float(data.loc[1, 'y']), + data.columns[2]: float(data.loc[1, 'z']), data.columns[3]: float(data.loc[1, 'w'])}, + '2': {data.columns[0]: str(data.loc[1, 'name']), data.columns[1]: float(data.loc[2, 'y']), + data.columns[2]: float(data.loc[2, 'z']), data.columns[3]: float(data.loc[2, 'w'])}, + '3': {data.columns[0]: str(data.loc[1, 'name']), data.columns[1]: float(data.loc[3, 'y']), + data.columns[2]: float(data.loc[3, 'z']), data.columns[3]: float(data.loc[3, 'w'])}, + '4': {data.columns[0]: str(data.loc[1, 'name']), data.columns[1]: float(data.loc[4, 'y']), + data.columns[2]: float(data.loc[4, 'z']), data.columns[3]: float(data.loc[4, 'w'])}, + '5': {data.columns[0]: str(data.loc[1, 'name']), data.columns[1]: float(data.loc[5, 'y']), + data.columns[2]: float(data.loc[5, 'z']), data.columns[3]: float(data.loc[5, 'w'])}, + '6': {data.columns[0]: str(data.loc[1, 'name']), data.columns[1]: float(data.loc[6, 'y']), + data.columns[2]: float(data.loc[6, 'z']), data.columns[3]: float(data.loc[6, 'w'])}, + '7': {data.columns[0]: str(data.loc[1, 'name']), data.columns[1]: float(data.loc[7, 'y']), + data.columns[2]: float(data.loc[7, 'z']), data.columns[3]: float(data.loc[7, 'w'])}, + '8': {data.columns[0]: str(data.loc[1, 'name']), data.columns[1]: float(data.loc[8, 'y']), + data.columns[2]: float(data.loc[8, 'z']), data.columns[3]: float(data.loc[8, 'w'])}, + } + + model = TableModel() + table = TableCanvas(tframe, data=ary, + cellwidth=60, cellbackgr='#e3f698', + thefont=('Arial', 12), rowheight=18, rowheaderwidth=30, + rowselectedcolor='yellow', editable=True) + + table.width = 800 + + # 返回 + b_back = Button(rootTable, text='返 回', command=back) + b_back.place(x=910, y=510, width=30, height=20) + + # 刷新 + b_flash = Button(rootTable, text='刷新', command=flash) + b_flash.place(x=110, y=330, width=50, height=30) + + # 添加 + b_add = Button(rootTable, text='添加', command=add) + b_add.place(x=110, y=480, width=150, height=50) + AddNameLaber = Label(rootTable, text='样本名') + AddNameLaber.place(x=50, y=450) + eName_add = Entry(rootTable, width=7) + eName_add.place(x=90, y=450) + AddLaber = Label(rootTable, text='样本值') + AddLaber.place(x=140, y=450) + e_add = Entry(rootTable, width=7) + e_add.place(x=180, y=450) + + # 删除 + b_del = Button(rootTable, text='删除', command=detel) + b_del.place(x=280, y=480, width=150, height=50) + DelNameLaber = Label(rootTable, text='样本名') + DelNameLaber.place(x=250, y=450) + eName_del = Entry(rootTable, width=7) + eName_del.place(x=290, y=450) + + # 生成 + CreatNameLaber = Label(rootTable, text='样本值名') + CreatNameLaber.place(x=500, y=450) + eCreat = Entry(rootTable, width=7) + eCreat.place(x=560, y=450) + b_creat = Button(rootTable, text='生成', command=C2Creat) + b_creat.place(x=490, y=480, width=150, height=50) + + table.show() + + def back(): + root1_2_2.destroy() + Chartmain() + + root1_2_2 = Frame(root, width=960, height=540) + root1_2_2.pack() + + # 表格 + #样本数 + cums=0 + df = {'name': ['nan', 'nan', 'nan', 'nan', 'nan', 'nan', 'nan', 'nan'], + 'y': [0, 0, 0, 0, 0, 0, 0, 0], + 'z': [0, 0, 0, 0, 0, 0, 0, 0], + 'w': [0, 0, 0, 0, 0, 0, 0, 0]} + data = pd.DataFrame(df, index=[1, 2, 3, 4, 5, 6, 7, 8]) + print(data) + + Table(data) + + # 返回 + b_back = Button(root1_2_2, text='返 回', command=back) + b_back.place(x=910, y=10, width=30, height=20) + + def back(): + root1_2.destroy() + ChooseDrawmain() + + root1_2 = Frame(root, width=960, height=540) + root1_2.pack() + b_back=Button(root1_2, text='返 回', command=back) + b1_1 = Button(root1_2, text='条形图', command=BarGmain) + b1_2 = Button(root1_2, text='直方图', command=Histogrammain) + b_back.place(x=910,y=10,width=30,height=20) + b1_1.place(x=320, y=10, width=320, height=90) + b1_2.place(x=320, y=110, width=320, height=90) + +def ChooseDrawmain(): + + def Function(): + root1.destroy() + Functionmain() + + def Chart(): + root1.destroy() + Chartmain() + + root1 = Frame(root, width=960, height=540) # 在root窗口上建立虚拟容器root1,容纳登录界面的组件 + root1.pack() + b1 = Button(root1, text='函 数', command=Function) # 设置按钮,绑定触发的事件 + b2 = Button(root1, text='图 表', command=Chart) + b1.place(x=320,y=135,width=320,height=90) + b2.place(x=320,y=250,width=320,height=90) + +root = Tk() +root.title("数据可视化") +root.geometry('960x540') +ChooseDrawmain() +root.mainloop() \ No newline at end of file