Python gobject 模块,threads_init() 实例源码

我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用gobject.threads_init()

项目:Web-Stalker    作者:Dylan-halls    | 项目源码 | 文件源码
def __init__(self):
      super(PyApp, self).__init__()
      self.set_title("Web Stalker Browser")
      self.set_size_request(1000,600)
      self.set_position(gtk.WIN_POS_CENTER)
      vbox = gtk.VBox(False, 5)
      scw = gtk.ScrolledWindow(None, None)
      web = webkit.WebView()

      url = sys.argv[1]
      web.open(url)
      scw.add(web)
      vbox.add(scw)

      gobject.threads_init()
      self.add(vbox)
      self.connect("destroy", gtk.main_quit)
      self.show_all()
项目:python-bluezero    作者:ukBaz    | 项目源码 | 文件源码
def __init__(self, device_id=None):
        """Default initialiser.

        1. Initialises the program loop using ``GObject``.
        2. Registers the Application on the D-Bus.
        3. Initialises the list of services offered by the application.

        """
        # Initialise the loop that the application runs in
        GObject.threads_init()
        dbus.mainloop.glib.threads_init()
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        self.mainloop = GObject.MainLoop()

        # Initialise the D-Bus path and register it
        self.bus = dbus.SystemBus()
        self.path = '/ukBaz/bluezero/application{}'.format(id(self))
        self.bus_name = dbus.service.BusName('ukBaz.bluezero', self.bus)
        dbus.service.Object.__init__(self, self.bus_name, self.path)

        # Initialise services within the application
        self.services = []

        self.dongle = adapter.Adapter(device_id)
项目:ECoG-ClusterFlow    作者:sugeerth    | 项目源码 | 文件源码
def __init__(self, *args, **kwds):

        self.filename = None
        self.parser = None
        self.thread = None

        if not display.DISPLAY_ENABLED:
            self.consensus_procedure(*args, **kwds)

        else:
            gtk.gdk.threads_init()
            gobject.threads_init()

            self.load_display(*args, **kwds)

            self.mpi_wait_for_start()
项目:phony    作者:littlecraft    | 项目源码 | 文件源码
def __init__(self, layout):
    ClassLogger.__init__(self)

    # IO event callbacks occur in another thread, dbus/gdk need
    # to be made aware of this.
    gobject.threads_init()

    GPIO.setmode(GPIO.BCM)

    self._layout = layout
    for name, config in layout.iteritems():
      for point in ['pin', 'pull_up_down']:
        Inputs._raise_if_not_in(point, config)

      config = copy.deepcopy(config)
      config['name'] = name

      self._inputs_by_channel[config['pin']] = config
      self._configure_input(name, config)
项目:phony    作者:littlecraft    | 项目源码 | 文件源码
def __init__(self, layout):
    ClassLogger.__init__(self)

    # IO event callbacks occur in another thread, dbus/gdk need
    # to be made aware of this.
    gobject.threads_init()

    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BCM)

    self._layout = layout
    for name, config in layout.iteritems():
      for point in ['pin', 'default']:
        Outputs._raise_if_not_in(point, config)

      self._conigure_output(name, config)
项目:projet_IA    作者:dogmotion    | 项目源码 | 文件源码
def lienInAmelia():

     import gtk  
     import webkit  
     import gobject

     gobject.threads_init()  
     window = gtk.Window()
     window.set_default_size(1100, 680)
     window.connect("destroy", lambda a: gtk.main_quit()) 
     browser = webkit.WebView()  
     browser.open("http://alfred-ia.org/essaye-moi/")  
     window.add(browser)  
     window.show_all()  
     gtk.main()
项目:gui-o-matic    作者:mailpile    | 项目源码 | 文件源码
def __init__(self, config):
        BaseGUI.__init__(self, config)
        if pynotify:
            pynotify.init(config.get('app_name', 'gui-o-matic'))
        gobject.threads_init()
        self.splash = None
项目:rebus    作者:airbus-seclab    | 项目源码 | 文件源码
def run(cls, store, master_options):
        gobject.threads_init()
        dbus.glib.init_threads()
        DBusGMainLoop(set_as_default=True)

        bus = dbus.SessionBus()
        name = dbus.service.BusName("com.airbus.rebus.bus", bus)
        svc = cls(bus, "/bus", store)

        svc.mainloop = gobject.MainLoop()
        log.info("Entering main loop.")
        try:
            svc.mainloop.run()
        except (KeyboardInterrupt, SystemExit):
            if len(svc.clients) > 0:
                log.info("Trying to stop all agents properly. Press Ctrl-C "
                         "again to stop.")
                # stop scheduler
                svc.sched.shutdown()
                # ask slave agents to shutdown nicely & save internal state
                log.info("Expecting %u more agents to exit (ex. %s)",
                         len(svc.clients), svc.clients.keys()[0])
                svc.bus_exit(store.STORES_INTSTATE)
                store.store_state()
                try:
                    svc.mainloop.run()
                except (KeyboardInterrupt, SystemExit):
                    if len(svc.clients) > 0:
                        log.info(
                            "Not all agents have stopped, exiting nonetheless")
        log.info("Stopping storage...")
        store.store_state()
项目:rebus    作者:airbus-seclab    | 项目源码 | 文件源码
def __init__(self, options):
        gobject.threads_init()
        dbus.mainloop.glib.threads_init()
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        Bus.__init__(self)
        busaddr = options.busaddr
        self.bus = dbus.SessionBus() if busaddr == DEFAULT_BUS else \
            dbus.bus.BusConnection(busaddr)
        counter = 20
        while not (counter == 0):
            try:
                self.rebus = self.bus.get_object("com.airbus.rebus.bus",
                                                 "/bus")
                counter = 0
            except dbus.exceptions.DBusException as e:
                log.warning("Cannot get bus object's because : " + str(e) +
                            " : wait 5s and retry")
                counter = counter - 1
                time.sleep(5)

        signal.signal(signal.SIGTERM, self.sigterm_handler)
        #: Contains agent instance. This Bus implementation accepts only one
        #: agent. Agent must be run using separate DBus() (bus slave)
        #: instances.
        self.agent = None
        self.loop = None
        self.main_thread_id = thread.get_ident()
项目:linux-pentest-util    作者:fikr4n    | 项目源码 | 文件源码
def __init__(self, args):
        self._classpath = args.classpath
        self._cache_filename = args.save_cache
        self._max_depth = args.max_depth
        gobject.threads_init()
        self.parser = None
        self._launch_loading()
        gtk.main()