Python GUI进行处理

时间:2018-11-14 10:16:33

标签: python pandas user-interface tkinter etl

我已经创建了一个用于选择多个文件的GUI,文件路径应该能够传递给我的进程(单独创建),但是我一直在坚持如何将文件路径传递给我的进程。这个想法是在选择了所有文件之后,用户单击“确定”,文件路径将传递给我的处理代码。

#########LATEST GUI############

import sys
from tkinter import filedialog
from tkinter import *

class root():
    def __init__(self):
        root = Tk()
        root.geometry('650x300+500+500')
        root.title('AdEx Combine File')
        label1 = Label(root,text = 'Welcome Please Select Your File',font = 'calibri 12 bold')
        label1.pack()
        label2 = Label(root,text = 'File A',font = 'calibri 10 bold')
        label2.place(x=20,y=42)
        label3 = Label(root,text = 'File B',font = 'calibri 10 bold')
        label3.place(x=20,y=92)
        label4 = Label(root,text = 'File C',font = 'calibri 10 bold')
        label4.place(x=20,y=142)
        label5 = Label(root,text = 'File D',font = 'calibri 10 bold')
        label5.place(x=20,y=192)
        #Browse Bar
        def browsefunc():
            filename1 = filedialog.askopenfilename(filetypes=[("excel","xlsx")])
            path1 = pathlabel1.config(text=filename1)

        def browsefunc2():
            filename2 = filedialog.askopenfilename()
            path2 = pathlabel2.config(text=filename2)
        def browsefunc3():
            filename3 = filedialog.askopenfilename()
            path3 = pathlabel3.config(text=filename3)
        def browsefunc4():
            filename4 = filedialog.askopenfilename()
            path4 = pathlabel4.config(text=filename4)


        browsebutton1 = Button(root, text="Browse", command=browsefunc)
        browsebutton1.place(x=160,y=40)
        pathlabel1 = Label(root)
        path1 = pathlabel1.place(x=20,y=70)

        browsebutton2 = Button(root, text="Browse", command=browsefunc2)
        browsebutton2.place(x=160,y=90)
        pathlabel2 = Label(root)
        path2 = pathlabel2.place(x=20,y=120)
        browsebutton3 = Button(root, text="Browse", command=browsefunc3)
        browsebutton3.place(x=160,y=140)
        pathlabel3 = Label(root)
        path3 = pathlabel3.place(x=20,y=170)
        browsebutton4 = Button(root, text="Browse", command=browsefunc4)
        browsebutton4.place(x=160,y=190)
        pathlabel4 = Label(root)
        path4 = pathlabel4.place(x=20,y=220)
        browsebutton5 = Button(root, text="OK",command=path4)
        browsebutton5.place(x=330,y=250)
        print(filename1)

    if __name__ =='__main__':
        root = root()
        root.mainloop()

我的流程代码如下所示(其他转换仅基于文件):

allftv =pd.read_excel('FILE A',skiprows=9,usecols = range(10))
allothers =pd.read_excel('FILE B',skiprows=8,usecols = range(20))
date = pd.read_excel('FILE C',skiprows=6,usecols = range(3))
uniondata = pd.read_excel('FILE D',skiprows=6,usecols = range(3))

0 个答案:

没有答案