python tkinter 无法自动关闭
tkinter root.withdraw()之后中间做了其他事情,下面重新要用tkinter 显示processbar, 用了root.wm_deiconify
点击start 完成4 个file 合并之后, 不能自动退出。
后面的程序也被打断不能执行到底。
root = tkinter.Tk() root.title('Step 1 of 4')
root.geometry('300x280+600+300')
root.withdraw()
************************中间做了其他事情下面重新要用tkinter 显示processbar。
root.wm_deiconify()
pb = ttk.Progressbar(root, length =200, maximum = 100)
pb.pack(padx=10,pady=20)#pb.grid(row = 0, column = 1)
def start():
global mergeSingleV,mergeStableV,mergeSingleM,mergeSingleMStep,mergeStableM,mergeOther
mergeSingleV = mergeStableV = mergeSingleM = mergeSingleMStep = mergeStableM = mergeOther = EE.create_df_type()
# mergeSingleV = EE.create_df_type()
# mergeStableV = EE.create_df_type()
# mergeSingleM = EE.create_df_type()
# mergeSingleMStep = EE.create_df_type()
# mergeStableM = EE.create_df_type()
# mergeOther = EE.create_df_type()
mergeSingleV = mergeStableV = mergeSingleM = mergeSingleMStep = mergeStableM = mergeOther = EE.create_df_type()
for i in range(0,len(files)):
print(files[i])
tracepath = os.path.join(tracedir,files[i])
data = pd.read_csv(tracepath,index_col= False)
data['Filename'] = files[i]
data = data.merge(configP[['Par','AnalyClass']],on ='Par', how='left')
data = data.merge(configS[['Par','Step','AnalyClass']], on=['Par','Step'],how='left') # AnalyClass_x, AnalyClass_y
data['Class'] = np.where(data['AnalyClass_x'].notnull(), data['AnalyClass_x'], data['AnalyClass_y'])# Bug here AnalyClass_y failed
singleV = data[data['Class']==1].drop(['AnalyClass_x','AnalyClass_y'],axis=1) # only ok4 file# na 'Parameter'
stableV = data[data['Class']==2].drop(['AnalyClass_x','AnalyClass_y'],axis=1) # dplyr::filter(data, class==2)[,1:5]
singleM = data[data['Class']==3].drop(['AnalyClass_x','AnalyClass_y'],axis=1) #,'Parameter'
singleMStep = data[data['Class']==4].drop(['AnalyClass_x','AnalyClass_y'],axis=1) #?? 空
stableM = data[data['Class']==5].drop(['AnalyClass_x','AnalyClass_y'],axis=1)
other = data[data['Class'].isnull()].drop(['AnalyClass_x','AnalyClass_y'],axis=1)
mergeSingleV = mergeSingleV.append(singleV) # <- rbind(mergeSingleV,singleV)# cbind() 把矩阵横向合并成一个大矩阵(列方式),而rbind()是纵向合并(行方式)。
mergeSingleV[['Step','Interval']] = mergeSingleV[['Step','Interval']].astype(float)
mergeStableV = mergeStableV.append(stableV) #keep data width and data columns the same for appending
mergeSingleM = mergeSingleM.append(singleM) #Filename
mergeSingleMStep = mergeSingleMStep.append(singleMStep)# Last column:Filename not Class
mergeStableM = mergeStableM.append(stableM)
mergeOther = mergeOther.append(other)
pb['value'] += 100/len(files)
print(pb['value'])
pb.update() # 更新画面
bnt = ttk.Button(root, text = 'start',command= start)#bnt2 = ttk.Button(root, text="Quit", command=quit)
bnt.pack(pady=10) #bnt.grid(row = 0, column = 0)#bnt2.grid(row = 1, column = 1)
draw_button = ttk.Button(root, text="Quit", command = EE.close_window)
draw_button.pack(pady=20)
root.mainloop() #启动应用程序,启动消息循环
以上是 python tkinter 无法自动关闭 的全部内容, 来源链接: utcz.com/p/938224.html