Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #105680
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Problem With Embedded Icon and Python 3.4 |
| Date | 2016-03-25 01:30 -0400 |
| Message-ID | <mailman.129.1458883826.2244.python-list@python.org> (permalink) |
| References | <Ju-dnWKBjbD8VWnLnZ2dnUU7-amdnZ2d@giganews.com> |
On 3/25/2016 1:10 AM, Wildman via Python-list wrote:
> 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 = """\
To make this literal a bytes literal, prepend 'b'.
encoded_icon = b'''\
> 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
bytes do have the buffer interface, so I expect that using bytes instead
of str will work.
--
Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Problem With Embedded Icon and Python 3.4 Wildman <best_lay@yahoo.com> - 2016-03-25 00:10 -0500
Re: Problem With Embedded Icon and Python 3.4 Terry Reedy <tjreedy@udel.edu> - 2016-03-25 01:30 -0400
Re: Problem With Embedded Icon and Python 3.4 Wildman <best_lay@yahoo.com> - 2016-03-25 09:41 -0500
Re: Problem With Embedded Icon and Python 3.4 Zachary Ware <zachary.ware+pylist@gmail.com> - 2016-03-25 00:34 -0500
Re: Problem With Embedded Icon and Python 3.4 Wildman <best_lay@yahoo.com> - 2016-03-25 09:42 -0500
Re: Problem With Embedded Icon and Python 3.4 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-26 01:42 +0000
Re: Problem With Embedded Icon and Python 3.4 Wildman <best_lay@yahoo.com> - 2016-03-25 21:37 -0500
Re: Problem With Embedded Icon and Python 3.4 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-03-28 10:36 +0100
Re: Problem With Embedded Icon and Python 3.4 Wildman <best_lay@yahoo.com> - 2016-03-28 09:31 -0500
csiph-web