i cant figure out how to do play gifs in the window and my stupid ass cant use google properly
this works perfectly for images but doesnt work for gifs it just shows the first frame but doesnt play the gif
import random
from time import sleep
from tkinter import *
import PIL
from PIL import Image
picture = "dinmor.png"
img = PIL.Image.open(picture)
x = random.randint(-20,20)
y = random.randint(-20,20)
wid, hgt = img.size
class Window(Tk):
def __init__(self):
Tk.__init__(self)
self.width = wid
self.height = hgt
self.velx = x
self.vely = y
self.pos = (250,250)
self.geometry(f"{self.width}x{self.height}+{self.pos[0]}+{self.pos[1]}")
self.iconbitmap(r".\_7OPSB.ico")
self.title('_7OPS GNOMED!!')
self.resizable(False, False)
self.image = PhotoImage(file=picture)
Label(self, image=self.image).pack()
def moveWin(self):
x = self.pos[0] + self.velx
y = self.pos[1] + self.vely
downx, downy = x+self.width, y+self.height
sWidth = self.winfo_screenwidth() # gives 1366
sHeight = self.winfo_screenheight() # gives 1080
if x <= 0 or downx >= sWidth:
self.velx = -self.velx
if y <= 0 or downy >= sHeight:
self.vely = -self.vely
self.pos = (x,y)
self.geometry(f"+{x}+{y}")
return [x, y, downx, downy]
root = Window()
def move():
root.moveWin()
root.after(10, move)
move()
root.mainloop()