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类threads_init()的实例源码
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)
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()
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)
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)
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()
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
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()
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()
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()