【发布时间】:2013-09-24 19:39:12
【问题描述】:
我目前正在为 Python 2.7 创建 Tkinter Gui,但无法使用进度条。我需要将较大的文件加载到我的程序中,这需要一些时间,所以我想获得一个进度条来向用户显示程序没有冻结加载文件。不幸的是,我的进度条在加载文件时似乎没有更新:(我尝试为进度条创建一个新线程但没有运气。所以我想知道我需要做什么才能让不确定的进度条在一个繁重的函数调用?
我的代码的相关部分如下所示:
import Tkinter as tk
import ttk as ttk
import pandas as pd
import tkFileDialog as tfgiag
self.pb = ttk.Progressbar(frame, orient=tk.VERTICAL, mode='indeterminate')
mynewdata = tfgiag.askopenfilenames(parent=root,title='Choose a file',filetypes=[('CSV files', '.csv')])
self.t = threading.Thread(target = self.pb.start)
self.t.start()
#read in each CSV file selected by the user
for myfile in root.tk.splitlist(mynewdata):
foo = pd.read_csv(myfile)
self.data.appendMainData(foo)
self.pb.stop()
【问题讨论】:
标签: python pandas tkinter progress-bar