I have an export button in tkinter frame
, once I click that it exports some data to CSV file. I also have a logout button in the same frame. I have added a function it the logout button to take me main frame
and kill the current frame.
Now when I click the export button it will take a minute to complete. Before that if I click the logout button, it takes me to main frame
. But the export process is running behind and does not get killed. I'm still getting a csv file.
Once I click logout button, I would like to kill the running export function
as well. How do I do that?
I used self.destroy()
but the export function is not getting killed.
Below lines are part of my code, the main code has over 400 lines. PageOne
is the frame in which I have the export and Logout buttons.
class PageOne(ttk.Frame):
def __init__(self, master):
ttk.Frame.__init__(self, master, height=800, width=1400)
self.logOut_btn = ttk.Button(self, text="Logout", command=self.logOut)
self.logOut_btn.place(x=1280, y=15)
self.export = ttk.Button(self, text="Export", command=self.export_cubeData)
self.export.place(x=620, y=y1+50)
self.exportPath = ttk.Label(self, text="Export Path", font='Helvetica 12 bold')
self.exportPath.place(x=430, y=y1+100)
self.entry_exportPath = ttk.Entry(self)
self.entry_exportPath.place(x=540, y=y1+100, width=450)
final_df = pd.Dataframe()
def logOut(self):
self.destroy()
self.master.switch_frame(StartPage)
with TM1Service(**config['TM1']) as tm1:
tm1.logout()
def setFlag(self):
self.flag = 1
def export_cubeData(self):
exportPath = self.entry_exportPath.get()
for i in range(10):
self.update()
final_df.to_csv(exportPath)