Generating PNG image data

Thanks. I assumed this was a well known problem that someone had
solved, but I couldn't find the solution.

Josh

···

On 8/14/07, Mike Driscoll <mdriscoll@co.marshall.ia.us> wrote:

Hi Josh,

> -----Original Message-----
> From: Josh English [mailto:joshua.r.english@gmail.com]
> Sent: Tuesday, August 14, 2007 12:55 PM
> To: wxPython-users@lists.wxwidgets.org
> Subject: Generating PNG image data
>
> In the sample file I sent regarding the PyCollapsiblePane, I
> had to include two small png images for the arrows. I created
> these images using the Gimp, which I'm not familiar with at
> all. (All of my old Photoshop skills seem irrelevant.) In a
> lot of demo files I see the hexadecimal code for the png
> files included in a string.
> How do you make these strings? I've tried reading the PNG
> file with the 'rb' tag and dumping the data into a text
> representation. The code has obvious comments left behind
> from the GIMP and no matter how I format it, I can't get the
> string to work. Python complains that it doesn't have a
> proper image file. Any suggestions to get this to work or to
> read the png data file and convert it into a readable string?
>
> --
> Josh English
> Joshua.R.English@gmail.com
> http://joshenglish.livejournal.com
>

Pictures in Python are a little complicated. You need to use "img2py.py",
which is a script included with wxPython. I found it in the tools
sub-sub-sub folded in the wxPython install:
C:\Python24\Lib\site-packages\wx-2.8-msw-ansi\wx\tools

See also wxPython API Documentation — wxPython Phoenix 4.2.2 documentation

It's pretty slick. Hope that helps!

Mike

--
Josh English
Joshua.R.English@gmail.com