[Image-SIG] Image in Text

William Baxter bbaxter at wadsworth.org
Fri Nov 19 20:53:35 CET 2004


Hello,

How come my image displays in this Text box,

from Tkinter import *
root = Tk()

text = Text(root)
text.insert(END, "here's my photo")
photo=PhotoImage(file='lumber.gif')
text.image_create(END, image=photo)
text.pack()

root.mainloop()

==========================

but not in this one (inside a function, or a class)?

from Tkinter import *
root = Tk()
def sub(root):
    text = Text(root)
    text.insert(END, "here's my photo")
    photo=PhotoImage(file='lumber.gif')
    text.image_create(END, image=photo)
    text.pack()

sub(root)
root.mainloop()

-- 
Thanks,
Bill B.

----
William T. Baxter, Ph.D.
Wadsworth Center
Empire State Plaza, PO Box 509
Albany, NY 12201-0509
-------------- next part --------------
from Tkinter import *

root = Tk()

text = Text(root)
text.insert(END, "here's my photo")
photo=PhotoImage(file='lumber.gif')
text.image_create(END, image=photo)
text.pack()

root.mainloop()

-------------- next part --------------
from Tkinter import *

root = Tk()

def sub(root):

    text = Text(root)
    text.insert(END, "here's my photo")
    photo=PhotoImage(file='lumber.gif')
    text.image_create(END, image=photo)
    text.pack()

sub(root)

root.mainloop()



More information about the Image-SIG mailing list