I have a program that I have been trying to rewrite so it will run on Python 2.7 and 3.4. It has been a pain to say the least. Thank $DIETY for aliases. Anyway, I got it all working except for one thing. The program has an embedded icon. It is displayed in the window's titlebar. The icon is a 16x16 png that has been base64 encoded using a Linux utility called memencoder. The code below works perfectly with Python 2.7. The icon data is complete for anyone that wants to try to run this code:
encoded_icon = """\ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAACBj SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAACAVBMVEUAAAAmAAAJ AAD/AAAOAAACAAAAAAABAAAVAAArAAANAAAPAACMAADqV1dYAAAVAAArAACmKiw2AABcAACM CguXBgcYAACrAgKdGRuZKCuPCAk9AAAAAACDAAAFAAABAADQAAAhAAARAAACAAABAAD/AADO AABaAAAfAABFAAD/AAANAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAHAAD/AAAYAAAL AAADAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAtAAAAAAABAABXAACnAAC7AABoAABsAACdAABy AAATAAAIAAB8AACeCwvDW1vboaHZmJi+Tk6mJSXFcHDNg4O8VlaeEhGEAACVAgLCZmbSkpTM fX3LiImXERJUAAATAAChGhvLZmmlREdnAAATAACgHyCzQUW7WlybRkpXAACLBgepZWqZZWt+ ExSoFRataW+vq7WqucSdc3t3EhMjAABLAACNAgKMICJ3GRtTAAAAAACiAACiEhScHR9vAAAk AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAABAAAAAAAAAAAAAAAAAAAAAAAAAAD36+v+ /v785+j539/+8/P27+/gwcPz///1urz+WFnTjI3/cXH5dXfn+f3Z6fDQyM7W/v/bs7vfYGbi c3jfkJbI9v++5vO2w82vusT///+h6spZAAAAkXRSTlMAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAEAAQAADEdRFwAdVEQKAAEABFtjUDAENFJ9WAIABDUoGwEIFRIf AgJRyunZVjSw2MZsCzrm3NH5egMAjv/YGwGcxL/eIVHu40crvPn+9IoHBUaPjUAEFk5dTREC AQAAAAEBAAABAAEAAAIAmCbO4wAAAAFiS0dEqr4GV74AAAAJcEhZcwAACxMAAAsTAQCanBgA AAAHdElNRQfgAxUUFToQYVhVAAAA5klEQVQY02NQZUAGjEwMagzMDCysbGAuO4O6BoMmgxaH to6unr6BoZExp4kpAxeDmbmFpZW1ja2dvYOjEzdQIY+zi6ubO6+Hp5e3D1inr59/QGBQcEho WHgEH5DPHxk1cdLk6JgpU6fFxsUDBRISp8+YOStp9py58+YnpwAFUtMWLFy0OD1jydJlyzOz gAIC2TkrVubm5RcUFhWXlIIMLSuvqKyqFqypratvEAIJCIs0NomKMYtLSEpJg62VkZWTZ2Bo bnFSUFRSVmFobWuHeqzDiYGhs4uhu6cXKuAEFOjrZ0AFThMAxbo5a0L7F4cAAAAldEVYdGRh dGU6Y3JlYXRlADIwMTYtMDMtMjFUMTU6MjA6MzMtMDU6MDBXJmdFAAAAJXRFWHRkYXRlOm1v ZGlmeQAyMDE2LTAzLTIxVDE1OjE5OjI3LTA1OjAwe2m2vwAAAABJRU5ErkJggg==""" root = Tk() decoded_icon=base64.decodestring(encoded_icon) image_icon = Image.open(io.BytesIO(decoded_icon)) icon = ImageTk.PhotoImage(image_icon) root.call('wm', 'iconphoto', root._w, icon) app = Window(root) root.mainloop() When I run the program with Python 3.4, I get this error: Traceback (most recent call last): File "/usr/lib/python3.4/base64.py", line 519, in _input_type_check m = memoryview(s) TypeError: memoryview: str object does not have the buffer interface The above exception was the direct cause of the following exception: Traceback (most recent call last): File "./myprogram.py", line 276, in <module> decoded_icon=base64.decodestring(encoded_icon) File "/usr/lib/python3.4/base64.py", line 561, in decodestring return decodebytes(s) File "/usr/lib/python3.4/base64.py", line 553, in decodebytes _input_type_check(s) File "/usr/lib/python3.4/base64.py", line 522, in _input_type_check raise TypeError(msg) from err TypeError: expected bytes-like object, not str I tried converting the icon string to a byte variable like this: encoded_icon = bytes("""\ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAACBj (...) ZGlmeQAyMDE2LTAzLTIxVDE1OjE5OjI3LTA1OjAwe2m2vwAAAABJRU5ErkJggg==""") That give me a different error: Traceback (most recent call last): File "./myprogram.py", line 269, in <module> ZGlmeQAyMDE2LTAzLTIxVDE1OjE5OjI3LTA1OjAwe2m2vwAAAABJRU5ErkJggg==""") TypeError: string argument without an encoding I'm not sure what that means. I looks like it wants the string to be encoded but it already is. And why the reference to only the last line of the string? I am at a loss here. Any help would be greatly appreciated. -- <Wildman> GNU/Linux user #557453 Old enough to know better... too young to resist. -- https://mail.python.org/mailman/listinfo/python-list