我正在使用Tkinter开发GUI,并且到目前为止已经成功。我想更新一个带有在函数中创建的列表的画布(在类中)。我有以下内容:
class GC_data_tk(Tkinter.Tk):
def __init__(self,parent):
Tkinter.Tk.__init__(self,parent)
self.parent = parent
self.initialize()
self.grid()
def initialize(self):
self.canvas = Tkinter.Canvas(self, width = 600, height = 400, bg = 'white').grid(column = 5, row = 1)
我想使用以下创建的self.Result列表:
def result(self):
self.Result = []
filepath = self.folder
filepath1 = self.folder +"\*.csv"
print filepath
comps = float(self.no_comps.get())
no_comps = comps +2
files = glob.glob(filepath1)
dataframes = [pd.DataFrame.from_csv(f, index_col=None, header=None) for f in files]
new_dfb = pd.DataFrame()
for i, df in enumerate(dataframes):
colname = 'Run {}'.format(i+1)
selected_data = df[3].ix[0:no_comps]
new_dfb[colname] = selected_data
self.Result.append(new_dfb)
folder = filepath + "\summary.csv"
new_dfb.to_csv(folder)
print self.Result
打印到画布。即使结果存储在函数中,是否可以这样做?
功能"结果(自我)"调用以下内容:
self.button2 = Tkinter.Button(self, text = "Run", font = ("Helvetica, 12"), command = self.combine_funcs(self.tx0_to_csv,self.csv_to_csv,self.result)).grid(column = 0, row = 7, columnspan = 1, rowspan =1, padx = 5, pady=5)
当前结果输出到cmd为: