[Twisted-Python] having trouble displaying Tkinter photo images with twisted, help?

Jp Calderone exarkun at intarweb.us
Fri Dec 5 11:48:13 EST 2003

On Thu, Dec 04, 2003 at 08:15:44PM -0800, John Benson wrote:
> The following toy program has no trouble displaying a GIF image:
> from twisted.internet import protocol, reactor, tksupport
> import Tkinter
> class FingerProtocol(protocol.Protocol):
>     pass
> class FingerFactory(protocol.ServerFactory):
>     protocol = FingerProtocol
> root = Tkinter.Tk()
> tksupport.install(root)
> iconimage = Tkinter.PhotoImage(master=root, file='buzzard.gif')
> Tkinter.Button(image=iconimage).pack()
> reactor.listenTCP(1079, FingerFactory())
> reactor.run()
> However, I have a larger program that gets a blank image when the
> iconimage = Tkinter.PhotoImage(master=root, file='buzzard.gif')
> Tkinter.Button(image=iconimage).pack()
> code runs. I've tried moving the code around and come up with the same
> result: no image, although a widget is created and displayed as a blank
> area.
> Has anyone run across this before, and is there a workaround?

  Just a guess - if the PhotoImage is garbage collected (No, the Button does
not hold a reference to it), the image data is freed and will
consequentially not be available for display.  Perhaps you need to stash a
reference to the PhotoImage somewhere?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20031205/496a74c8/attachment.pgp 

More information about the Twisted-Python mailing list