Beispiel #1
0
def run_gui_thread(gui_config=None, runtime_config=None):
    from gi.repository import GLib
    from gi.repository import Gdk
    from rafcon.core.start import reactor_required
    from rafcon.gui.start import start_gtk, install_reactor
    from rafcon.utils.i18n import setup_l10n
    global gui_ready
    # see https://stackoverflow.com/questions/35700140/pygtk-run-gtk-main-loop-in-a-seperate-thread
    # not needed any more:
    # https://pygobject.readthedocs.io/en/latest/guide/threading.html?highlight=threads_init#threads-faq
    # GLib.threads_init()
    if reactor_required():
        install_reactor()
    setup_l10n()
    from rafcon.gui.controllers.main_window import MainWindowController
    from rafcon.gui.views.main_window import MainWindowView

    initialize_environment_gui(gui_config, runtime_config)
    main_window_view = MainWindowView()
    main_window_view.get_top_widget().set_gravity(Gdk.Gravity.STATIC)
    MainWindowController(rafcon.gui.singleton.state_machine_manager_model, main_window_view)

    print("run_gui thread: ", currentThread(), currentThread().ident, "gui.singleton thread ident:", \
        rafcon.gui.singleton.thread_identifier)

    # Wait for GUI to initialize
    wait_for_gui()
    # Set an event when the gtk loop is running
    GLib.idle_add(gui_ready.set)
    start_gtk()
Beispiel #2
0
def run_gui_thread(gui_config=None, runtime_config=None):
    import gobject
    import gtk
    from rafcon.core.start import reactor_required
    from rafcon.gui.start import start_gtk, install_reactor
    from rafcon.utils.i18n import setup_l10n
    global gui_ready
    # see https://stackoverflow.com/questions/35700140/pygtk-run-gtk-main-loop-in-a-seperate-thread
    gobject.threads_init()
    if reactor_required():
        install_reactor()
    setup_l10n()
    from rafcon.gui.controllers.main_window import MainWindowController
    from rafcon.gui.views.main_window import MainWindowView

    initialize_environment_gui(gui_config, runtime_config)
    main_window_view = MainWindowView()
    main_window_view.get_top_widget().set_gravity(gtk.gdk.GRAVITY_STATIC)
    MainWindowController(rafcon.gui.singleton.state_machine_manager_model,
                         main_window_view)

    print "run_gui thread: ", currentThread(), currentThread().ident, "gui.singleton thread ident:", \
        rafcon.gui.singleton.thread_identifier

    # Wait for GUI to initialize
    wait_for_gui()
    # Set an event when the gtk loop is running
    gobject.idle_add(gui_ready.set)
    start_gtk()