import tkinter as tk from io import BytesIO import zipfile import random import sys import webp from PIL import Image, ImageTk from PIL import ImageSequence import winsound import pygame root = tk.Tk() root.attributes("-toolwindow", 1) root.attributes("-topmost", True) root.overrideredirect(True) root.geometry("+0+0") zf = zipfile.ZipFile("gifs.zip", "r") gif_files = zf.namelist() def show_random_gif(): global gif_files, label if gif_files: gif_file = random.choice(gif_files) while not gif_file.endswith('.gif'): gif_file = random.choice(gif_files) gif_bytes = zf.read(gif_file) gif = Image.open(BytesIO(gif_bytes)) width, height = gif.width, gif.height screen_width = root.winfo_screenwidth() screen_height = root.winfo_screenheight() root.geometry("+{}+{}".format(screen_width - width, screen_height - height)) gif_frames = [ImageTk.PhotoImage(gif.copy().convert("RGBA")) for i, frame in enumerate(ImageSequence.Iterator(gif))] label.config(image=gif_frames[0]) label.image = gif_frames root.attributes("-alpha", 1) label.after(10000, clear_gif) label.play = play_gif(0) root.attributes("-topmost", True) mp3_file = gif_file.replace(".gif", ".mp3") if mp3_file in gif_files: mp3_bytes = zf.read(mp3_file) pygame.mixer.init() pygame.mixer.music.load(BytesIO(mp3_bytes)) pygame.mixer.music.play() else: label.config(image=None) root.attributes("-alpha", 1) root.after(10000, clear_gif) root.attributes("-topmost", True) def clear_gif(): label.config(image=None) label.image = None root.attributes("-alpha", 0) root.after(60000, show_random_gif) root.attributes("-topmost", True) def play_gif(index): if label.image is not None: label.config(image=label.image[index % len(label.image)]) label.after(100, lambda: play_gif(index + 1)) root.attributes("-topmost", True) label = tk.Label(root, bg='white') label.pack(expand=True) root.wm_attributes('-transparentcolor','white') root.after(0, show_random_gif) root.mainloop()