X Window System error while using Tkinter and OpenCv

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")

def main(frame):
	btn = tk.Button(frame,text="click",command=show)

if __name__ == "__main__":
	root = tk.Tk()

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. !!!

We don’t have experience about tkinter. Would need other users to share suggestion.

hello Dane,

It does not have to be tkinter, it could be other frameworks that i could use with python and opencv. Do you guys have any experience with any other frameworks ?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.