當前位置: 首頁>>代碼示例>>Python>>正文


Python GLib.threads_init方法代碼示例

本文整理匯總了Python中gi.repository.GLib.threads_init方法的典型用法代碼示例。如果您正苦於以下問題:Python GLib.threads_init方法的具體用法?Python GLib.threads_init怎麽用?Python GLib.threads_init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gi.repository.GLib的用法示例。


在下文中一共展示了GLib.threads_init方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import threads_init [as 別名]
def __init__(self):
        GLib.threads_init()
        Gst.init(None)

        self.options = Options()

        year  = datetime.datetime.now().year
        month = datetime.datetime.now().month
        day   = datetime.datetime.now().day
        self.date = date(year, month, day)

        self._shrouk = None
        self._fajr = None
        self._zuhr = None
        self._asr = None
        self._maghrib = None
        self._isha = None
        self._nextprayer = ""
        self._tnprayer = 0
        self.dec = 0 
開發者ID:Jessewb786,項目名稱:Silaty,代碼行數:22,代碼來源:prayertime.py

示例2: _oldGiInit

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import threads_init [as 別名]
def _oldGiInit():
    """
    Make sure pygtk and gi aren't loaded at the same time, and import Glib if
    possible.
    """
    # We can't immediately prevent imports, because that confuses some buggy
    # code in gi:
    _glibbase.ensureNotImported(
        _PYGTK_MODULES,
        "Introspected and static glib/gtk bindings must not be mixed; can't "
        "import gireactor since pygtk2 module is already imported.")

    global GLib
    from gi.repository import GLib
    if getattr(GLib, "threads_init", None) is not None:
        GLib.threads_init()

    _glibbase.ensureNotImported([], "",
                                preventImports=_PYGTK_MODULES) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:21,代碼來源:gireactor.py

示例3: run_gui_thread

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import threads_init [as 別名]
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() 
開發者ID:DLR-RM,項目名稱:RAFCON,代碼行數:32,代碼來源:utils.py

示例4: run

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import threads_init [as 別名]
def run(self):
        logging.info('D-Bus process started')
        GLib.threads_init()  # allow threads in GLib
        GLib.idle_add(self._idleQueueSync)

        DBusGMainLoop(set_as_default=True)
        dbusService = SessionDBus(self.taskQueue, self.resultQueue)

        try:
            GLib.MainLoop().run()
        except KeyboardInterrupt:
            logging.debug("\nThe MainLoop will close...")
            GLib.MainLoop().quit()
        return 
開發者ID:kamwar,項目名稱:simLAB,代碼行數:16,代碼來源:dbus_ctrl.py

示例5: __init__

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import threads_init [as 別名]
def __init__(self):
        GLib.threads_init()
        Gdk.threads_init()

        p = optparse.OptionParser()
        p.add_option("-l", "--verbose", help="Enable verbose logging", action="store_true", default=False)
        p.add_option("-c", "--configure", help="Show the configuration window on startup", action="store_true", default=False)
        options, args = p.parse_args()

        try:
            # Create configuration directory
            if not os.path.exists(common.CONFIG_DIR):
                os.makedirs(common.CONFIG_DIR)
            # Create data directory (for log file)
            if not os.path.exists(common.DATA_DIR):
                os.makedirs(common.DATA_DIR)
            # Create run directory (for lock file)
            if not os.path.exists(common.RUN_DIR):
                os.makedirs(common.RUN_DIR)

            # Initialise logger
            rootLogger = logging.getLogger()

            if options.verbose:
                rootLogger.setLevel(logging.DEBUG)
                handler = logging.StreamHandler(sys.stdout)
            else:
                rootLogger.setLevel(logging.INFO)
                handler = logging.handlers.RotatingFileHandler(common.LOG_FILE,
                                        maxBytes=common.MAX_LOG_SIZE, backupCount=common.MAX_LOG_COUNT)

            handler.setFormatter(logging.Formatter(common.LOG_FORMAT))
            rootLogger.addHandler(handler)

            if self.__verifyNotRunning():
                self.__createLockFile()

            self.initialise(options.configure)

        except Exception as e:
            self.show_error_dialog(_("Fatal error starting AutoKey.\n") + str(e))
            logging.exception("Fatal error starting AutoKey: " + str(e))
            sys.exit(1) 
開發者ID:autokey,項目名稱:autokey,代碼行數:45,代碼來源:gtkapp.py

示例6: __init__

# 需要導入模塊: from gi.repository import GLib [as 別名]
# 或者: from gi.repository.GLib import threads_init [as 別名]
def __init__(self, parent):
        Gtk.Window.__init__(self)
        GLib.threads_init()
        Gst.init(None)

        # Set parent widget
        self.parent = parent
        self.lock_location_updates = False

        # Init dialog
        self.dialog = None

        # Tweak window
        self.set_decorated(True)
        self.set_icon_name('silaty')
        self.set_modal(True)
        self.set_resizable(False)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.connect('delete-event', self.hide_window)
        #self.set_default_size(429, 440)
        self.headerbar = Gtk.HeaderBar()

        # Set up mainbox
        self.mainbox = Gtk.Box()
        self.mainbox.set_orientation(Gtk.Orientation.HORIZONTAL)

        self.prayertimes = Prayertime()
        self.prayertimes.calculate()
        #self.prayertimes.notify('Title', 'This is a test.')

        # Set language
        set_language(self.prayertimes.options.language)
        if self.prayertimes.options.language == 'Arabic':
            #self.set_gravity(Gdk.Gravity.NORTH_EAST)
            #self.set_direction(Gtk.TextDirection.RTL)
            Gtk.Widget.set_default_direction(Gtk.TextDirection.RTL)

        # Set layout
        self.set_layout()

        if self.prayertimes.options.start_minimized == False:
            self.show_all()
            self.sidebar.emit("window-shown") 
開發者ID:Jessewb786,項目名稱:Silaty,代碼行數:45,代碼來源:silaty.py


注:本文中的gi.repository.GLib.threads_init方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。