How to create a slideshow with .jpg .mpg in python

Hi
I’m just starting out with Python, but can already see the possibilities. I’ve previously worked in HP Basic(in 70’s) and more recently in PHP developing websites with backend databases.

Now I wish to move to Python. Compared to PHP, you need to write so much less code. But I’ve found it takes a lot of research to get the correct parameters/options to do what I want to do.

So I’m trying to create a slideshow - already have the majority of the program done. Lists the pics within the folder etc.

But I seem to be stuck with the image display part. What I want to do is:

read .jpg images
make sure they are orientated correctly
resize them to fit the screen
display within a frame so I can manipulate where they go

then also
do the same with videos - .mpg files

Can anyone help?

I have tried doing this by importing :
tkinter, CV2, Pillow,

but can’t seem to get it all to hang together.

Anyone got any ideas about how easiest to do this and a willingness to help?

All the best from Scotland

Brian

Welcome to the forum Brian.

What I suggest is to build your project piece by piece. Write down the steps you need to take in order to get the project together. Turn each step into code and before you know it you will have a complete application.
For example,
Step 1. Display an JPG image in tkinter.
Step 2. Create buttons with left and right arrows.
Step 3. Create a function to swap the photos when the button is clicked.

Hi Brandon

That’s good thinking. I’ve kinda been doing that. But got stuck with getting the image into the tkinter frame/label. Can’t seem to do that when I also want to resize using cv2.

Thanks for the tip.

Cheers

Brian

Start with something like this then add a left and right button to it.
The left and right buttons have to be connected to functions.

from tkinter import *
from PIL import ImageTk, Image 

window = Tk() 

window.geometry("800x1000") 

image1 = ImageTk.PhotoImage(Image.open("flower.jpg")) 
  
label = Label(image=image1) 
label.grid(row=1, column=0, columnspan=3) 

window.mainloop()