Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #105680
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!newsfeed0.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Terry Reedy <tjreedy@udel.edu> |
| Newsgroups | comp.lang.python |
| Subject | Re: Problem With Embedded Icon and Python 3.4 |
| Date | Fri, 25 Mar 2016 01:30:17 -0400 |
| Lines | 62 |
| Message-ID | <mailman.129.1458883826.2244.python-list@python.org> (permalink) |
| References | <Ju-dnWKBjbD8VWnLnZ2dnUU7-amdnZ2d@giganews.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de LMnUozhVaZI6ocnpzB9WQQteLXvo1sad50nKXeUkpLRQ== |
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'root': 0.04; 'subject:Python': 0.05; 'encoded': 0.05; 'error:': 0.05; 'rewrite': 0.07; 'base64': 0.09; 'icon': 0.09; 'literal': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'skip:b 70': 0.09; 'skip:f 70': 0.09; 'skip:t 70': 0.09; 'typeerror:': 0.09; 'python': 0.10; 'jan': 0.11; '2.7': 0.13; '"""\\': 0.16; '16x16': 0.16; 'least.': 0.16; 'literal,': 0.16; 'png': 0.16; 'prepend': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'reedy': 0.16; 'skip:/ 70': 0.16; 'skip:g 70': 0.16; 'skip:w 70': 0.16; 'subject:Problem': 0.16; 'tk()': 0.16; 'wrote:': 0.16; 'app': 0.16; 'bytes': 0.18; 'skip:" 30': 0.20; 'skip:c 70': 0.22; 'skip:s 70': 0.22; 'trying': 0.22; 'am,': 0.23; '(most': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'linux': 0.26; 'interface': 0.29; 'skip:d 70': 0.29; 'str': 0.29; 'code:': 0.29; 'work.': 0.30; 'code': 0.30; 'skip:a 70': 0.30; 'anyone': 0.32; 'skip:_ 10': 0.32; 'embedded': 0.32; 'skip:d 40': 0.32; 'run': 0.33; 'displayed': 0.33; 'interface,': 0.33; 'traceback': 0.33; 'utility': 0.33; 'file': 0.34; 'except': 0.34; 'instead': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'expect': 0.37; 'say': 0.37; 'received:org': 0.37; 'thank': 0.38; 'data': 0.39; 'does': 0.39; 'to:addr:python.org': 0.40; 'called': 0.40; 'received:96': 0.63; 'complete': 0.63; 'python-list': 0.66; '2.7.': 0.84; 'pain': 0.84; 'received:fios.verizon.net': 0.91; 'subject:With': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| X-Gmane-NNTP-Posting-Host | pool-96-227-207-81.phlapa.fios.verizon.net |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 |
| In-Reply-To | <Ju-dnWKBjbD8VWnLnZ2dnUU7-amdnZ2d@giganews.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:105680 |
Show key headers only | View raw
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