Barry Tolnas wrote:
If anyone knows the reasons behind this particular case (need
for wxEmptyBitmap() ) I'm interested in hearing it just for my own
understanding of this type of problem. I'll hunt back for some of
Robin's prior posts on the topic.
The reason is the same as for a lot of wxPython functions: Python does
not support function overloading the way C++ does. I dopn't know much
C++, but I'm pretty sure the way wxImage, for instance, works is that it
has a set of constuctors, each taking different parameters. The compiler
knows which one you want by the type of the parameters. Python, on teh
other hand, has dynamic typing, so it's not possible to automatically
call the correct constructor byt he types of the arguments it's called
with. You can simulate that by having one function that first checks the
types of the inputs, and then calls the correct constuctor, but that
requires a bunch of handwork and type checking in the wrappers, and
Robin has only done that in a few cases. It's easier to just make
constructors with different names for each of the different C++
constructors: thus here is the wxPython note for wxImage:
wxPython note: Constructors supported by wxPython are:
wxImage(name, flag)
Loads an image from a file
wxNullImage()
Create a null image (has no size or image data)
wxEmptyImage(width, height)
Creates an empty image of the given size
wxImageFromMime(name, mimetype
Creates an image from the given file of the given mimetype
wxImageFromBitmap(bitmap)
Creates an image from a platform-dependent bitmap
You'll now know to look for those wxPython notes...particularly for
classes with multiple constructors. I'd also look in teh name space for
names that might work if you are having a problem like that:
from wxPython import wx
for n in dir(wx):
... if "Image" in n: print n
...
wxBitmapFromImage
wxCursorFromImage
wxDragImage
wxDragImagePtr
wxEmptyImage
wxImage
wxImageFromBitmap
wxImageFromData
wxImageFromMime
wxImageFromStream
wxImageFromStreamMime
wxImageHandler
wxImageHandlerPtr
wxImageList
wxImageListPtr
wxImagePtr
wxImage_AddHandler
wxImage_CanRead
wxImage_CanReadStream
wxImage_GetImageCount
wxImage_InsertHandler
wxImage_RemoveHandler
wxInitAllImageHandlers
wxNullImage
-Chris
···
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov