- 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
ito po dapat merong description salamat in advance
View attachment 374159
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
Attachments
Last edited: