Skip to content

Instantly share code, notes, and snippets.

@reusee
Last active December 10, 2015 01:19
Show Gist options
  • Select an option

  • Save reusee/4357590 to your computer and use it in GitHub Desktop.

Select an option

Save reusee/4357590 to your computer and use it in GitHub Desktop.
glib main loop in py
from gi.repository import GLib
main_loop = GLib.MainLoop()
class Counter:
def __init__(self):
self.c = 0
def count(self):
print self.c
self.c += 1
return True
def main():
counter = Counter()
GLib.idle_add(counter.count)
GLib.timeout_add(1000, lambda: main_loop.quit())
if __name__ == '__main__':
main()
main_loop.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment