Message219133
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)) |
|
Date |
User |
Action |
Args |
2014-05-26 05:52:24 | martin.panter | set | recipients:
+ martin.panter, docs@python |
2014-05-26 05:52:24 | martin.panter | set | messageid: <1401083544.46.0.470654104454.issue21580@psf.upfronthosting.co.za> |
2014-05-26 05:52:24 | martin.panter | link | issue21580 messages |
2014-05-26 05:52:23 | martin.panter | create | |
|