inputhookgtk3.py 1012 B

12345678910111213141516171819202122232425262728293031323334
  1. # encoding: utf-8
  2. """
  3. Enable Gtk3 to be used interacive by IPython.
  4. Authors: Thomi Richards
  5. """
  6. #-----------------------------------------------------------------------------
  7. # Copyright (c) 2012, the IPython Development Team.
  8. #
  9. # Distributed under the terms of the Modified BSD License.
  10. #
  11. # The full license is in the file COPYING.txt, distributed with this software.
  12. #-----------------------------------------------------------------------------
  13. #-----------------------------------------------------------------------------
  14. # Imports
  15. #-----------------------------------------------------------------------------
  16. import sys
  17. from gi.repository import Gtk, GLib
  18. #-----------------------------------------------------------------------------
  19. # Code
  20. #-----------------------------------------------------------------------------
  21. def _main_quit(*args, **kwargs):
  22. Gtk.main_quit()
  23. return False
  24. def inputhook_gtk3():
  25. GLib.io_add_watch(sys.stdin, GLib.IO_IN, _main_quit)
  26. Gtk.main()
  27. return 0