Radek
Radek

Reputation: 3941

Continuously redraw wxPython element

I have a chat client that continuously polls a server and fetches new messages.

From my def __init__() I have:

wx.CallAfter(self.pollServer)

Which is defined:

def pollServer(self):
    t = self.updateMessages()
    time.sleep(5)
    self.pollServer()

Now printing the messages into the Terminal shows that it works but the GUI is 'frozen' instead of being continuously refreshed and I thought CallAfter takes care of that. Could you help?

Upvotes: 1

Views: 381

Answers (1)

YOU
YOU

Reputation: 123937

instead of

time.sleep(5)
self.pollServer()

try with

wx.CallLater(5,self.pollServer)

Upvotes: 2

Related Questions