Пример #1
0
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")
Пример #2
0
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")
Пример #3
0
 def enqueue_exception(mc):
   def raise_exception():
     raise Exception("This is an intentional exception")
   MessageLoop.add_message(raise_exception)
Пример #4
0
 def wait_forever(mc):
   MessageLoop.run_until(lambda: False)
   assert("Should never reach here.") # because MessageLoop will raise QuitException
Пример #5
0
def quit():
    if _running == False:
        raise Exception("UI not running")
    MessageLoop.quit()
Пример #6
0
 def on_ready(*args):
     log2("UI init: window shown, scheduling load in 200ms")
     MessageLoop.add_delayed_message(run_load_cb, 200)
Пример #7
0
        def enqueue_exception(mc):
            def raise_exception():
                raise Exception("This is an intentional exception")

            MessageLoop.add_message(raise_exception)
Пример #8
0
 def wait_forever(mc):
     MessageLoop.run_until(lambda: False)
     assert ("Should never reach here."
             )  # because MessageLoop will raise QuitException
Пример #9
0
def quit():
  if _running == False:
    raise Exception("UI not running")
  MessageLoop.quit()
Пример #10
0
 def on_ready(*args):
   log2("UI init: window shown, scheduling load in 200ms")
   MessageLoop.add_delayed_message(run_load_cb, 200)