def start(): global img, pre_pts #count = 1 while True: root = tk.Tk() root.withdraw() f_path = filedialog.askopenfilename() if f_path: img = cv.imread(f_path) break else: messagebox.showinfo("提示", "请选择文件!") 修改上述代码,使得打开本地文件夹不选文件或者关闭系统窗口后,使得槽函数能够被重新触发
时间: 2023-06-26 12:05:47 浏览: 77
新加坡南洋理工的Matlab的OFDM经典教材-南洋理工-Chapter_6_OFDM_Notes.pdf
def start():
global img, pre_pts
while True:
root = tk.Tk()
root.withdraw()
f_path = filedialog.askopenfilename()
root.destroy() # 关闭窗口
if f_path:
img = cv.imread(f_path)
break
else:
messagebox.showinfo("提示", "请选择文件!")
continue # 重新触发槽函数
阅读全文