我想使用tkinter进行绘图。但我只是想点击一个按钮并读取文件的位置,但我无法点击文件,我根本不知道问题出在哪里?这是我的代码:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Button
import tkinter as tk
from tkinter.filedialog import askopenfilename
figure, ax1 = plt.subplots()
class Index(object):
def next(self,event):
root = tk.Tk()
root.withdraw()
file_name = askopenfilename()
print(file_name)
callback = Index()
axnext = plt.axes([0.11,0.9,0.1,0.075])
bnext = Button(axnext, 'Open')
bnext.on_clicked(callback.next)
plt.show()
我不明白当我点击打开时我无法选择文件,就像点击被禁用一样。