Last active
December 10, 2015 01:19
-
-
Save reusee/4357590 to your computer and use it in GitHub Desktop.
glib main loop in py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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