opencv and tkinter received an x window system error

asked 2016-08-03 09:54:02 -0500

I first developped with eclipse under windows seven and i had no trouble. I then tried to test the code with geany under raspbian jessie of the rasperry pi with the trouble : the program frame received an x window system error

here is the code :

import cv2 as ocv
import tkinter
import pygubu

class app_root:
    def __init__(self, master):
        self.builder = builder = pygubu.Builder()
        builder.add_from_file("curgent.ui")
        self.Frame_1 = builder.get_object('Frame_1', master)
        builder.connect_callbacks(self)
    def bt_testCam1_click(self):
        global button
        button = 1
        root.quit()
        root.destroy()

if __name__ == "__main__":
     global button
     button = 0

     while True:
        root = tkinter.Tk()
        app = app_root(root)     
        root.mainloop()
        if button == 1 :
            cap = ocv.VideoCapture(0)
            if(cap.isOpened()):
                while(cap.isOpened()):
                    ret, the_frame = cap.read()
                    if ret==True:
                        ocv.imshow('frame',the_frame)

                    if (ocv.waitKey(5) != -1):
                        cap.release()
                        ocv.destroyWindow('frame')
                        break
            else:
                print("No free Camera")
            button = 0

Version : - Python 3 - OpenCV 3.0.0 - pygubu: 0.9.7.8

i tested different way without success. Thanks for help or idea

edit retag flag offensive close merge delete