Reputation: 1885
I have a wx.Frame
from wxPython and want to do intermediate and final updates on resize.
Because I didn't find an end-of-resizing event, my approach is to do the intermediate update on wx.EVT_SIZE
and the final update in a timer I start on wx.EVT_SIZE
. It works most of the time, but sometimes it hangs at threading.Timer.start
(meaning Before
is printed at last [see code]). Do you know why?
This is the code for the resize handler and the timer method:
def _on_resize(self, event):
self.Layout()
self._resize_lock.acquire()
print 'resize event'
#Intermediate update is done here
self._resize_lock.release()
if self._resize_timer != None:
self._resize_timer.cancel()
self._resize_timer = threading.Timer(0.75,
self._resize_timer_method)
print 'Before'
self._resize_timer.start()
print 'After'
def _resize_timer_method(self):
self._resize_lock.acquire()
print 'resize timer'
#Final update is done here
self._resize_lock.release()
PS: If you know how to get an end-of-resizing event, please tell me instead.
Upvotes: 0
Views: 202
Reputation: 33101
Why does it have to update during sizing? Regardless, I think you would be better off using a wx.Timer(). I suspect that you're doing something that's not threadsafe and that's making things unpredictable.
Upvotes: 1