Efficient wxOGL redraws
Ben
ruthenium at altavista.net
Fri Apr 12 06:09:48 EDT 2002
Hi all,
I hope one or other of the experts here can give me some advice...
In my wxPython (oh how I love it) app under Win32, I am wanting to use
little wxOGL wxShapes as slider bars, for defining start and stop
positions. The idea is very simple - the user clicks on the bar,
drags it to the required position, and releases it. The trick is that
the bar must have a fixed Y position. That is, when the user drags
the bar, it only moves horizontally.
Now I've managed to get it working after a fashion, but it's VERY
inefficient. My event handler includes the following:
def OnMovePre(self,dc,x,y,oldX,oldY,display):
if y == oldY:
return true
return false
def OnDragLeft(self,draw,x,y,keys, attachment):
shape = self.GetShape()
canvas = shape.GetCanvas()
dc = wxClientDC(canvas)
canvas.PrepareDC(dc)
self.GetShape().Erase(dc)
self.GetShape().SetX(x)
self.GetShape().SetY(18)
self.canvas.Redraw(dc)
Doing this causes horrid flicker, and steals lots of CPU cycles.
Can anyone think of a more elegant way of doing this using wxOGL? I
could probably use GDI primitives, but I don't fancy all the schlep of
doing hit testing etc.
Thanks & regards,
Ben
More information about the Python-list
mailing list