New submission from Martin Panter: 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)) ---------- assignee: docs@python components: Documentation, Tkinter messages: 219133 nosy: docs@python, vadmium priority: normal severity: normal status: open title: PhotoImage(data=...) apparently has to be UTF-8 or Base-64 encoded versions: Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue21580> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com