0

I have three separate GUIs that I wrote using wxpython.

def __init__(self, app):
    self.gui1= Gui1(None)
    self.gui1.Show()
    self.gui2= Gui2(None)
    self.gui2.Show()
    self.run_game()

def run_game(self):
    for i in range(0, 100):
        time.sleep(0.5)
        self.gui1.method1()
        self.gui2.method1()

if __name__ == '__main__':
    app = wx.App(False)
    controller = Controller(app)
    app.MainLoop()

However, when I run this code, the GUIs don't display and appear to "freeze." Could someone please help with this?

Marjoram
  • 413
  • 1
  • 7
  • 15
  • Without seeing what method1 I would say it is due to that loop of 100 x 0.5 seconds, during that time the UI will not be updated. – Werner Apr 24 '15 at 08:47

1 Answers1

0

Don't use time.sleep. It blocks the main loop. Instead, use a wx.Timer(). They run in their own event loop that is non-blocking. You can read the documentation here or check out the following tutorial:

Mike Driscoll
  • 32,629
  • 8
  • 45
  • 88