[wxPython] Mandelbrot -- OnXyz magic methods fix.

Hi Les,

As you noticed, the Mandelbrot demo from a few months ago uses an OnPaint
magic method (support for these methods were recently removed from the
wxPython distribution), which means running the code gives you a blank black
screen, instead of the Mandelbrot fractal. A single line can be added to
the __init__ method of the canvas to make the demonstration functional:
  EVT_PAINT( self, self.OnPaint )
I've included a full copy of the demo with the added line for those who did
not receive the original.

If you want more information:
  http://wxwindows.org/pipermail/wxpython-users/2000-June/002358.html
Was the official "notice" to retool our projects to use the official
mechanism. In general, if a method is present in the list:
    OnChar
    OnSize
    OnEraseBackground
    OnSysColourChanged
    OnInitDialog
    OnPaint
    OnIdle
    OnActivate
    OnMenuHighlight
    OnCloseWindow
    OnScroll
You need to add a line of the form:
  OnXyz --> EVT_XYZ( self, self.OnXyz )
Where self.OnXyz can actually be any function you particularly desire.

Enjoy yourself,
Mike

PS: I copied the wxPython users list in case others are trying to run this
demo and finding it does nothing :0) .

mandelbrot3.py (8.12 KB)

Mike Fletcher said:

A single line can be added to the __init__ method of the canvas to
make the demonstration functional:
EVT_PAINT( self, self.OnPaint )

thanks... i figured it had to be something like that....

i've been using wxPython for 2 days, and it makes me happy to say i
figured this one out myself, because it means there is something
rational about the wx design which novices like me can grasp.

i have one question: where can i read about when paint events are
emitted? i went through a similar learning exercise recently with
Java, but i can not find anything in the wx docs that explains the
when.

also, what was the reason for removing the automatic binding of paint
events to OnPaint. in java the paint methods of panels (or whatever
they were) were automatically called. is there a reason to prefer
binding by hand in wxPythonLand? just curious (i.e. just learning)

les schaffer