wx draw_idle

Paul Kienzle wrote:
> or if there are pending wx events. The scheme isn't perfect since wx
> doesn't see all the native events, but it seems to work well enough.

I'm confused here -- what events are missed, and why? What do you mean
by a "native" event?

Intermediate mouse positions, for example, seem to be consumed. Also,
it doesn't seem to recognize pending resize events.

Try an experiment such as resizing examples/pcolor_log.py, with N large
enough to make redraws slow to see what I mean (N=200 does it for me).

I tried changing the _onSize event handler to use draw_idle rather
than draw to improve the resize experience but I shut it off because
the drawing area turns black and I couldn't figure out how to set it
to the figure background colour. It helped slow graphs a little since
I could see what the resulting window would look like, but the black
was jarring for quick graphs.

Any thoughts on implementing preemptive plotting?

This would mean putting tests like the following inside potentially
expensive loops:

    if self.isabort(): break

where isabort is a method in class artist which delegates to the canvas:

    return self.figure.canvas.isabort() if self.figure else False

For the wx canvas, isabort() would be something like:

    wx.Yield() # Allow UI events to be processed
    return self._draw_idle_requested # abort drawing if UI triggered redraw

> 2) Don't draw bitmap on the screen if the graph isn't shown. Otherwise
> a plot inside of a wx aui notebook bleeds through even if the graph
> notebook is not on top.

hmmm odd -- this does sound right, but shouldn't wx only be re-drawing
in a Paint event anyway?

I haven't traced through the wx.aui code so I don't know what is going
on. I do know that I have problems if I don't check IsWindowShown
before blitting the bitmap onto the screen.

> 3) Don't regenerate entire plot for each PaintEvent. Instead, only
> draw the graph if this is the first time the window is exposed, otherwise
> work from the bitmap.

This is odd to me too -- I haven't dug into the wx back-end, but it
seems the Paint Event should only trigger a blit of the bitmap to the
screen anyway.

It should, but the bitmap may not be initialized when the paint event
occurs. This happens when the window is first created (since there is
no associated size event) and now when switching aui notebook windows
(since I don't render the bitmap if the window isn't shown).

  - Paul

ยทยทยท

On Tue, Dec 11, 2007 at 10:22:12AM -0800, Christopher Barker wrote: