Python 3 OpenCV函数和Tkinter

Python 3 OpenCV函数和Tkinter,opencv,python-3.x,tkinter,Opencv,Python 3.x,Tkinter,OpenCV的WaitKey()和destroyAllWindows()函数不能与tKinter正常工作。每一个都很好,然后删除另一个 def function(): #do some processes #show the result images with cv2.namedWindow, cv2.resizeWindow and then cv2.imshow cv2.waitKey(0) cv2.destroyAllWindows() root = t

OpenCV的WaitKey()和destroyAllWindows()函数不能与tKinter正常工作。每一个都很好,然后删除另一个

def function():
    #do some processes
    #show the result images with cv2.namedWindow, cv2.resizeWindow and then cv2.imshow
    cv2.waitKey(0)
    cv2.destroyAllWindows()

root = tk.Tk()
root.title("blabla")
root.geometry("200x200")
button = tk.Button(root, text = "Button", command = function)
button.pack()
root.mainloop()

你想做什么?WaitKey并销毁cv2 NamedWidow的所有窗口。为什么要使用tkinter?我的OpenCV函数显示图像。然后我创建了一个按钮,用tKinter运行该函数。当我点击按钮时,openCV函数工作并显示图像。然后我想用任意键关闭图像窗口(弹出窗口)。实际上有很多图片,我想一次关闭所有的图片