def run(settings, load_cb=None): global _running _running = True # actual init of the UI is done via this callback, # which is posted to the MessageLoop at the end of this function def do_init(): # create them... resources = Resources(settings, ndbg.get_basedir()) global _mc mw = MainWindow(settings, resources) def run_load_cb(): log2("UI init: running on_load callback") if load_cb: load_cb(_mc) return False # ensure the timeout is a one-time thing def on_ready(*args): log2("UI init: window shown, scheduling load in 200ms") MessageLoop.add_delayed_message(run_load_cb, 200) if load_cb: mw.connect('show', on_ready) settings.set_delayed_save(True) _mc = MainControl(settings, mw) # Go! :) MessageLoop.add_message(do_init) MessageLoop.run() # cleanup _running = False if _mc: _mc.destroy() log2("ui.run done")
def enqueue_exception(mc): def raise_exception(): raise Exception("This is an intentional exception") MessageLoop.add_message(raise_exception)