0

I want to make a single GUI with button, and displaying the video inside the same window when i click this button. In my code bellow, there is a window of tkinter appeared with the button, and when I click that button, it display a video capture in (another window), I want this captured video appeared in the same window that contains the button. can anyone please help me to edit this code with all my thanks.

import cv2
import tkinter as tk

def cap_vid():

    vid = cv2.VideoCapture(0)
    while (True):

        ret, frame = vid.read()

        cv2.imshow('frame', frame)

        if cv2.waitKey(1) & 0xFF == ord('q'):
            break


root = tk.Tk()

video_label = tk.Label()
video_label.pack(expand=True, fill="both")


my_button = tk.Button(text="Click Me", command=cap_vid)
my_button.pack()

root.mainloop()
hh tt
  • 395
  • 5
  • 22
  • There are examples on this subject can be found if you search the internet or StackOverflow. – acw1668 Dec 13 '21 at 01:10
  • I searched about examples, but I can't found anything do what I want, all examples like my above code where the captured video window separated from the stkinter window that contain buttons. Can you please help me with example? – hh tt Dec 13 '21 at 05:30
  • I can find this [question](https://stackoverflow.com/questions/37358293/python-3-x-tkinter-integrating-frames-from-opencv-cv2-into-tkinter-window) and this [question](https://stackoverflow.com/questions/28670461/read-an-image-with-opencv-and-display-it-with-tkinter). – acw1668 Dec 13 '21 at 11:46

0 Answers0