inputhookgtk.py 1017 B

1234567891011121314151617181920212223242526272829303132333435
  1. # encoding: utf-8
  2. """
  3. Enable pygtk to be used interacive by setting PyOS_InputHook.
  4. Authors: Brian Granger
  5. """
  6. #-----------------------------------------------------------------------------
  7. # Copyright (C) 2008-2011 The IPython Development Team
  8. #
  9. # Distributed under the terms of the BSD License. The full license is in
  10. # the file COPYING, distributed as part of this software.
  11. #-----------------------------------------------------------------------------
  12. #-----------------------------------------------------------------------------
  13. # Imports
  14. #-----------------------------------------------------------------------------
  15. import sys
  16. import gtk, gobject
  17. #-----------------------------------------------------------------------------
  18. # Code
  19. #-----------------------------------------------------------------------------
  20. def _main_quit(*args, **kwargs):
  21. gtk.main_quit()
  22. return False
  23. def inputhook_gtk():
  24. gobject.io_add_watch(sys.stdin, gobject.IO_IN, _main_quit)
  25. gtk.main()
  26. return 0