Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Need help po for Photo Slider ng Python

Status
Not open for further replies.

God love us

Amateur
Advanced Member
Messages
134
Reaction score
0
Points
26
LODI,

Pahelp naman po di ko talaga makuha kong paano lagyan ng description bawat photo na lalabas.
ito po code ko

Code:
from tkinter import *
import PIL
from PIL import ImageTk
from PIL import Image
root = Tk()

root.title("Picture viewer")

#root.resizable(0,0)
img = ImageTk.PhotoImage(Image.open('1.jpg'))
img1 = ImageTk.PhotoImage(Image.open('2.jpg'))
img2 = ImageTk.PhotoImage(Image.open('3.jpg'))

image_list = [img, img1, img2]

def forward(image_number):
    global my_label
    global button_back
    global button_forward
    
    my_label.grid_forget()
    my_label = Label(image=image_list[image_number -1])
    button_forward =Button(root, font = ("Verdana", 10),text="Next Picture", command=lambda: forward(image_number +1))
    button_back =Button(root, font = ("Verdana", 10),text="Previous Picture", command=lambda: backward(image_number -1))

    if image_number == 3:
        button_forward = Button(root, font = ("Verdana", 10),text="Next Picture", state=DISABLED)
    
    my_label.grid(row=0, column=0, columnspan=3)
    button_back.grid(row=1, column=0)
    button_forward.grid(row=1, column=2)
    
def backward(image_number):
    global my_label
    global button_back
    global button_forward
    my_label.grid_forget()
    my_label = Label(image=image_list[image_number -1])
    button_forward =Button(root, font = ("Verdana", 10), text="Next Picture", command=lambda: forward(image_number +1))
    button_back =Button(root, font = ("Verdana", 10), text="Previous Picture", command=lambda: backward(image_number -1))
    
    if image_number == 1:
        button_back = Button(root, font = ("Verdana", 10),text="Previous Picture", state=DISABLED)

    my_label.grid(row=0, column=0, columnspan=3)
    button_back.grid(row=1, column=0)
    button_forward.grid(row=1, column=2)


my_label = Label(image=img)
button_back = Button(root,font = ("Verdana", 10),text="Previous Picture", command=backward, state=DISABLED)
button_forward = Button(root, font = ("Verdana", 10),text="Next Picture", command=lambda: forward(2))
button_exit = Button(root, font = ("Verdana", 10),text="Exit Application", command=root.destroy)

my_label.grid(row=0, column=0, columnspan=3)

button_back.grid(row=1, column=0)
button_exit.grid(row=1, column=1)
button_forward.grid(row=1, column=2)

root.mainloop()


ito po dapat merong description salamat in advance

View attachment 374159:pray:
 

Attachments

  • a.jpg
    a.jpg
    82 KB · Views: 6
Last edited:
Re: Need for Photo Slider ng Python

Paup lang ko need ko lang
 
Status
Not open for further replies.
Back
Top Bottom