Mar-21-2021, 12:00 AM
Hello.I have a main window using tkinter.I call a function that has:
Doyou have any idea what is going on and how can I fix it?
Don't run this code ,because I have icons for the button.
Thanks.
root.after(1 , camera_status , ....) and other thingsSo,in camera_status which is inside in another file has:
from tkinter import * #from GUI_camera import video_stream import cv2 , PIL from PIL import Image,ImageTk cap = cv2.VideoCapture(0) def camera_status(root , FOREGROUND_COLOR , ACTIVE_FOREGROUND_COLOR , BACKGROUND_COLOR , ACTIVE_BACKGROUND_COLOR , mode): # control camera camera_frame = LabelFrame(root , width = 663 , height = 528) camera_frame.place(x = 844 , y = 300) if(mode): ret , frame = cap.read() if(ret): frame = cv2.flip(frame , 1) cv2image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGBA) img = PIL.Image.fromarray(cv2image) imgtk = ImageTk.PhotoImage(image = img) camera_frame.imgtk = imgtk camera_frame.configure(image = imgtk) enable_camera_logo = Image.open("logo/enable_camera.png") else: enable_camera_logo = Image.open("logo/disable_camera.png") enable_camera_logo = enable_camera_logo.resize( (75 , 30) , resample = 0) enable_camera_image = ImageTk.PhotoImage(enable_camera_logo) camera_button = Button(root , highlightbackground = "black" , bd = 0 , image = enable_camera_image , activeforeground = "black", activebackground = "black" , bg = "black" , relief = SUNKEN) camera_button.config(command = lambda: camera_status(root , FOREGROUND_COLOR , ACTIVE_FOREGROUND_COLOR , BACKGROUND_COLOR , ACTIVE_BACKGROUND_COLOR , mode)) camera_button.image = enable_camera_image camera_button.place(x = 840 , y = 250) mode = not modeI just want to push a button and inside my frame(camera_frame) to enable camera.So,when I push the button ,the light from my camera (laptop) is enable ,but it doesn't show anything isnide frame.
Doyou have any idea what is going on and how can I fix it?
Don't run this code ,because I have icons for the button.
Thanks.