无法查看新创建的csv fi

2024-10-02 18:15:54 发布

您现在位置:Python中文网/ 问答频道 /正文

我创造了两个按钮。第一个按钮允许我用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()

Tags: 文件csvtextplotdefbutton按钮pack
1条回答
网友
1楼 · 发布于 2024-10-02 18:15:54

我假设Plot()中的py是指matplotlib.pyplot?你知道吗

在这种情况下,对py.show()的调用将阻塞,直到绘图窗口关闭;将其更改为py.show(block=False),然后重新读取documentation。你知道吗

相关问题 更多 >