-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloading.py
More file actions
27 lines (22 loc) · 984 Bytes
/
loading.py
File metadata and controls
27 lines (22 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import cv2
from PIL import Image, ImageTk
def show_loading_video(root, loading_label, callback):
video_path = "loading.mp4" # Replace with the path to your video file
cap = cv2.VideoCapture(video_path)
def update_frame():
ret, frame = cap.read()
if ret:
# Resize frame to fit application window
frame = cv2.resize(frame, (root.winfo_width(), root.winfo_height()))
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
frame_pil = Image.fromarray(frame)
frame_imgtk = ImageTk.PhotoImage(frame_pil)
loading_label.imgtk = frame_imgtk
loading_label.configure(image=frame_imgtk)
# Repeat every 30 ms for a smooth frame update
loading_label.after(30, update_frame)
else:
cap.release() # Release the video file when done
callback() # Start main application when video ends
# Start displaying frames
update_frame()