from tkinter import *
from PIL import ImageTk, Image
root = Tk()
root.title("experiment")
my_img1 = ImageTk.PhotoImage(file="C:/Users/csneb/Desktop/Background/de_files/imagine.png")
my_img2 = ImageTk.PhotoImage(file="C:/Users/csneb/Desktop/Background/de_files/img2.png")
my_img3 = ImageTk.PhotoImage(file="C:/Users/csneb/Desktop/Background/de_files/img3.jpg")
my_img4 = ImageTk.PhotoImage(file="C:/Users/csneb/Desktop/Background/de_files/img4.jpg")
my_img5 = ImageTk.PhotoImage(file="C:/Users/csneb/Desktop/Background/de_files/img5.jpg")
image_list = [my_img1, my_img2, my_img3, my_img4, my_img5]
#.configure(image=image_list[number])
my_label = Label(image=my_img1)
my_label.grid(row=0, column = 0, columnspan = 3)
def forward(image_number):
global my_label
global button_forward
global button_back
my_label.grid_forget()
my_label = Label(image_list[image_number-1])
button_forward = Button (root, text=">>", command=lambda: forward(image_number+1))
button_back = Button(root, text="<<", command = lambda: back(image_number-1))
my_label.grid(row=0, column = 0, columnspan = 3)
button_forward.grid(row=1, column=2)
button_back.grid(row=1, column=0)
def back():
global my_label
global button_forward
global button_back
button_back = Button(root, text="<<", command = back)
button_exit = Button(root, text="exit", command = root.quit)
button_forward = Button(root, text=">>", command = lambda: forward(2))
button_back.grid(row=1, column=0)
button_exit.grid(row =1, column = 1)
button_forward.grid(row=1, column=2)
root.mainloop()
What I have tried:
It's shows me this:
https://ibb.co/kXRtnFm
But when i press >> shows me this:
https://ibb.co/b7SRCkj
Instead of another image.
I saw this guy's tutorial, i tried to do what he does, but my program don't show me the next image:
https://www.youtube.com/watch?v=zg4c92pNFeo[
^]
CAN YOU HELP ME PLEASE? THANK YOU VERY MUCH!!!!!