I binded the paint event with the paint method. When I refresh the panel (which is supposed to call the event handler), it waits until the code after the refresh is done and only then calls it. Does someone why and how I could solve this problem? The Output is
def paint(self, event):
print("here first")
try:
dc = wx.BufferedPaintDC(self)
dc.DrawBitmap(self.bmp, 0, 0)
print("time here2", time.time())
except:
pass
def NextFrame(self):
self.Refresh()
time.sleep(5)
print("hey")
output:
hey
here first
time here2 1615033876.9332623
As you can see, it first prints the hey (which is supposed to happen after the "here first" and "time here2 ....."
self.Update()instead ofself.Refresh()Refresh, updates during the next event loop iteration. However, there is a caveat: Use Refresh first if you want to immediately redraw the window unconditionally as Update doesn't do anything, if nothing requires redrawing. I Hope that's clear. (If in doubt try both)