Displaying a picture with tkinter

Bill Walker bwalker at earth1.net
Thu May 17 03:49:14 CEST 2001


Try this: (I didn't send the gif along, it is a pix of the Alpha Space
Station)

import Tkinter
tk=Tkinter
root=tk.Tk()
root.title("Alpha Space Station")


myCanvas = tk.Canvas(root, width=500, height=500)
photo = tk.PhotoImage(file="Alpha.gif")
myCanvas.create_image(250,250, image=photo)
myCanvas.pack()

root.mainloop()



"Arthur Perlo" <perlo at mail.csb.yale.edu> wrote in message
news:3B019604.7F6DA095 at mail.csb.yale.edu...
> Hi,
>
> My program generates an image (picture), consisting of an
> NxM array of 8- or 16-bit pixels. I want to display it in
> my python application. I gather that I need the Image or
> PhotoImage widget, but the only documentation I can find is
> for loading the image from a file. My image is generated by
> my program.
>
> Can anyone point me to documentation or (preferably) sample
> code that will show me how to do this?
>
> (Unfortunately, I am not only new to python, but am ignorant
> of Tk. I couldn't find understandable (by me) documentation
> of this for Tk, either).
>
> -- Art
> +-------------------------------------------------+
> |  Arthur Perlo             phone: (203) 432-5614 |
> |  Yale University   email: arthur.perlo at yale.edu |
> +-------------------------------------------------+





More information about the Python-list mailing list