From: Chuck Esterbrook [mailto:ChuckEsterbrook@yahoo.com]
Let's say the user of a wxPython-based app is traversing a
list control,
grid or what-have-you with DOWN ARROW, and the keyboard
repeat rate is
faster than the background work associated with each change in
position. In my case, the background work is displaying a
preview of a
large image.I think what I want to do is peek at the future events list
and if I see
additional movement events (arrow keys, for example), skip the
background work (e.g., the image preview). In this way, the
user could
traverse as quickly as their keyboard repeat rate is set.Has anyone done anything like this? Is there a recommended approach?
None of the documented wxEvtHandler methods looked useful for this
purpose.
I don't know about peeking at future events, but I solved exactly the same
problem (in a tree control) using a timer. It worked really well for me. The
code looked something like this:
# 500 = 1/2 second. Change to suit.
DisplayDelay = 500
def __init__(...):
# ...
EVT_TREE_SEL_CHANGED(self,self.GetId(),self.OnItemSelect)
self.selectionTimer = wxTimer(self,timerId)
EVT_TIMER(self,timerId,self.OnSelectionTimer)
# ...
def OnItemSelect(self, event):
# ...
# Start()ing a running timer restarts it
self.selectionTimer.Start(DisplayDelay ,wxTIMER_ONE_SHOT)
def OnSelectionTimer(self,event):
# Do the display