我创造了两个按钮。第一个按钮允许我用agmplotcsv格式写1234。但是我无法在AgmFolder中看到新创建的csv文件-我必须重新运行程序才能看到新创建的Excel csv文件。你知道吗
def AGM():
Plot()
newDirRH = "C:/AgmPlots"
newfile = newDirRH + "/TabulatedStats.csv"
text_file = open(newfile, "w")
stringText = "1234"
x= stringText
text_file.write(x)
text_file.close()
print "Done"
def AGMFolder():
webbrowser.open(r'C:\AgmPlots')
def Plot():
py.plot(10,20)
py.show()
问题是由Plot()引起的。我不想把它拿走,但我怎样才能解决这个问题??你知道吗
if __name__ == '__main__': #start of program
master = Tk.Tk()
button = Tk.Button(text='AGM', command=AGM, fg="red")
button.config( height = 10, width = 40 )
button.pack() #pack is needed to display the button
button1 = Tk.Button(text='Open AGM Folder', command = AGMFolder, fg="red")
button1.config( height = 10, width = 40 )
button1.pack()
master.mainloop()
我假设
Plot()
中的py
是指matplotlib.pyplot
?你知道吗在这种情况下,对
py.show()
的调用将阻塞,直到绘图窗口关闭;将其更改为py.show(block=False)
,然后重新读取documentation。你知道吗相关问题 更多 >
编程相关推荐