tkinter icons as bytestrings, not files?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Feb 24 05:33:11 EST 2009


En Tue, 24 Feb 2009 02:56:12 -0200, Peter Billam <peter at www.pjb.com.au>  
escribió:

> As a newbie, starting with Python3, I'm working my way through Mark
> Summerfield's tkinter examples.  In the toolbar, there's lines like:

>     image = os.path.join(os.path.dirname(__file__), image)
>     image = tkinter.PhotoImage(file=image)
>
> which are always failing because the icons are in the wrong place
> and I can't help but wonder if I can put all these little images
> in the application itself, either as b'whatever' or uuencoded or
> in svg etc, and then invoke some suitable variation of the
>     image = tkinter.PhotoImage(file=image)
> or of the
>     button = tkinter.Button(toolbar, image=image, command=command)
> command ?  (I did try help('tkinter.PhotoImage') but didn't spot a
> magic key (unless it's "data=something, format=something")) ...

Almost; see the best documentation source for tkinter:
http://effbot.org/tkinterbook/photoimage.htm

-- 
Gabriel Genellina




More information about the Python-list mailing list