I'm new to Python and I really need help on this, I've been looking everywhere but i can't find an answer.
I created a script that compares data from 2 Excels files and write a report in a new file. It's a long script that includes a lot of functions and objects.
Now I want to make this script usefull to anyone in my workteam and create a GUI. I am using Tkinter. I have created 2 buttons to ask the user for the files directory and store it in a list. I'd like my original script to use the two inputs and run when a third button is clicked on.
How should I include my script in the tkinder app script?? Here is my app:
from Tkinter import *
import Tkinter, Tkconstants, tkFileDialog
listfile = []
class simpleapp_tk(Tkinter.Tk):
def __init__(self,parent):
Tkinter.Tk.__init__(self,parent)
self.parent = parent
self.initialize()
def initialize(self):
button = Tkinter.Button(self,text=u"data 1",command=self.OnButtonClick)
button2 = Tkinter.Button(self,text=u"data 2",command=self.OnButtonClick)
#here is the third button to run the script, the command isn't right
button3 = Tkinter.Button(self,text=u"Run script",command=self.OnButtonClick)
button.pack(side='bottom',padx=15,pady=15)
button2.pack(side='bottom',padx=15,pady=15)
button3.pack(side='bottom',padx=15,pady=15)
def OnButtonClick(self):
x = tkFileDialog.askopenfilename(title='Please select data directory')
listfile.append(x)
# def OnButtonClick2(self):
# Can I run my original script here?
# I read one should not include a function into a function
if __name__ == "__main__":
app = simpleapp_tk(None)
app.title('my application')
app.mainloop()