This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients docs@python, martin.panter
Date 2014-05-26.05:52:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1401083544.46.0.470654104454.issue21580@psf.upfronthosting.co.za>
In-reply-to
Content
At the bottom of the “tkinter” doc page it mentions the “data” option is available. However I was unable to get it to work well when passing a plain bytes() string in. It seems the bytes() string gets interpreted as UTF-8 somewhere along the line, although the underlying TCL library apparenly handles byte strings fine itself. Passing binary GIF and PNG data in Python would usually produce strange exceptions, crashes, and blank images for me.

I found this message with a simple patch which might be useful, though I’m not familiar with the code involved to understand the implications:
https://mail.python.org/pipermail/tkinter-discuss/2012-April/003108.html

Even if that fix is not appropriate, can I suggest adding to the documentation to say the data should be encoded with one of these options that seem to work? The Base-64 one is probably better.

PhotoImage(data=data.decode("latin-1).encode("utf-8"))
PhotoImage(data=base64.encodebytes(data))
History
Date User Action Args
2014-05-26 05:52:24martin.pantersetrecipients: + martin.panter, docs@python
2014-05-26 05:52:24martin.pantersetmessageid: <1401083544.46.0.470654104454.issue21580@psf.upfronthosting.co.za>
2014-05-26 05:52:24martin.panterlinkissue21580 messages
2014-05-26 05:52:23martin.pantercreate