import cv2
import numpy as np
import tkinter as tk
from tkinter import messagebox
def show():
img = np.random.randint(low=0,high=255,size=(300,300))
img = np.array(img,np.uint8)
messagebox.showinfo("Random_Image","Click , Then press enter to accept image")
cv2.imshow("asda",img)
cv2.waitKey(0)
cv2.destroyAllWindows()
def main(frame):
btn = tk.Button(frame,text="click",command=show)
btn.pack()
if __name__ == "__main__":
root = tk.Tk()
main(root)
root.mainloop()
I am trying to create a GUI using tkinter and opencv, however i keep recveing the following error:
The program 'asda' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadWindow (invalid Window parameter)'.
(Details: serial 846 error_code 3 request_code 15 minor_code 0)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the --sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
I am running this on a ngc container which i extended to be able to use tkinter.
Initially the error was failed to to load canberra gtk module, which i then “fixed” using
sudo apt-get install libcanberra-gtk-module
as mentioned here: 12.04 - Failed to load module "canberra-gtk-module" - Ask Ubuntu
however i still keep getting error.
Error occurs when trying to bypass waitkey() by pressing enter key
Any help is much appreciated. !!!