我有一个export按钮tkinter frame
,一旦我点击它导出一些数据到CSV文件。我logout在同一帧中也有一个按钮。我添加了一个功能它logout按钮带我主要frame
并杀死当前帧。
现在当我点击export按钮时,需要一分钟才能完成。在此之前,如果我点击logout按钮,它将带我到主要frame
。但出口过程落后并且不会被杀死。我还在收到一个csv文件。
一旦我点击logout按钮,我想杀死正在运行的导出function
。我怎么做?
我用过self.destroy()
但导出功能没有被杀死。下面的行是我的代码的一部分,主代码有超过400行。PageOne
是我有export和Logout按钮的框架。
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)
发布于 2019-03-29 09:11:25
https://stackoverflow.com/questions/-100008996
复制相似问题