hii

I am trying to develop a simple image browser.this is wat i have done so far

from Tkinter import *
top=Tk()

def search():
    global pic
    global photo
   
    pic=PhotoImage(file='images\\pic.gif')
    photo=w.create_image(250,200,image=pic)

w=Canvas(top,height=500,width=500,bg="white")
entry=Entry(top,bg="white")
nxt=Button(top,text="next",activebackground="blue",command=next)
prev=Button(top,text="prev",activebackground="blue")
b=Button(top,text="search",activebackground="blue",command=search)


b.pack()
entry.pack()

nxt.pack(side=RIGHT)
prev.pack(side=LEFT)
w.pack()
top.mainloop()

as u can see it will display a static image,however i want to browse through the images
when i press the next button.Can anybody help.

P.S:I am a starter so please dont get mad at me!!!

well think about what you would need to do; you'd need to either have a list of the images or be in a specified directory to browse through the images in that; some useful tools might be:

tkFileDialog, askopenfilename

PIL,Image, ImageTk (ImageTk.PhotoImage)

os

You can just use "command=search" for the next button, and add a get-a-file-name routine to the top of the function.

tanx for replying..

well my intention is to display the images on the canvas whenever i press the next button.

You have a static image because in line 8, you pointed at just one picture in your directory.
What if you load all the image files in that directory in a form of array and then when the next button is clicked, it moves to the next record which should be the next image.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.