Displaying a picture with tkinter

Arthur Perlo perlo at mail.csb.yale.edu
Thu May 17 09:34:50 EDT 2001


Thanks, that is a helpful example. But it doesn't solve my problem
My picture is not in a file. It consists of byte- or integer- pixels
that have been generated internally in my program. Is there a way I can
create an image without referring to a file, and download pixel data to it?
-- Art

Bill Walker wrote:
> 
> 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