How to create wx.Bitmap from "xpm data"?
Grant Edwards
grante at visi.com
Wed May 2 14:38:04 PDT 2007
On 2007-05-02, Grant Edwards <grante at visi.com> wrote:
> According to the page at http://www.wxwidgets.org/manuals/2.6/wx_wxbitmap.html#wxbitmapctor,
> one can create a wx.Bitmap from "XPM data". However, I can't
> find even a hint as to what wxPython expects "XPM data" to be.
>
> The obvious answer would be it's what's in an .xpm file, but
> that doesn't work. I've tried manipulating the contents of the
> .xpm file a half-dozen different ways, but no matter what I
> try, wx.Bitmap() always returns a bitmap with a size of -1,-1
> instead of 24,24.
>
> What's the expected format of "XPM data" for wx.Bitmap()?
I figured it out...
You can't use wx.Bitmap() to create a bitmap from XPM data. You
use wx.BitmapFromXPMData() which allows you to "Construct a
Bitmap from a list of strings formatted as XPM data."
It still took a bit of trian-and-error to figure out what
"formatted as XPM data" meant: You can't just pass it a list of
the strings from an .xpm file -- you've got to strip out the
"C" stuff. Maybe that's obvious to everybody else, but it took
me a few guesses...
--
Grant Edwards grante Yow! MY income is ALL
at disposable!
visi.com
More information about the wxpython-users
mailing list