##// END OF EJS Templates
Gtk3 integration with ipython works.
Thomi Richards -
Show More
@@ -21,6 +21,7 b' from IPython.lib.inputhook import ('
21 enable_tk, disable_tk,
21 enable_tk, disable_tk,
22 enable_glut, disable_glut,
22 enable_glut, disable_glut,
23 enable_pyglet, disable_pyglet,
23 enable_pyglet, disable_pyglet,
24 enable_gtk3, disable_gtk3,
24 set_inputhook, clear_inputhook,
25 set_inputhook, clear_inputhook,
25 current_gui
26 current_gui
26 )
27 )
@@ -36,6 +36,7 b" GUI_TK = 'tk'"
36 GUI_OSX = 'osx'
36 GUI_OSX = 'osx'
37 GUI_GLUT = 'glut'
37 GUI_GLUT = 'glut'
38 GUI_PYGLET = 'pyglet'
38 GUI_PYGLET = 'pyglet'
39 GUI_GTK3 = 'gtk3'
39 GUI_NONE = 'none' # i.e. disable
40 GUI_NONE = 'none' # i.e. disable
40
41
41 #-----------------------------------------------------------------------------
42 #-----------------------------------------------------------------------------
@@ -100,7 +101,7 b' class InputHookManager(object):'
100 This class installs various hooks under ``PyOSInputHook`` to handle
101 This class installs various hooks under ``PyOSInputHook`` to handle
101 GUI event loop integration.
102 GUI event loop integration.
102 """
103 """
103
104
104 def __init__(self):
105 def __init__(self):
105 if ctypes is None:
106 if ctypes is None:
106 warn("IPython GUI event loop requires ctypes, %gui will not be available\n")
107 warn("IPython GUI event loop requires ctypes, %gui will not be available\n")
@@ -222,7 +223,7 b' class InputHookManager(object):'
222
223
223 def enable_qt4(self, app=None):
224 def enable_qt4(self, app=None):
224 """Enable event loop integration with PyQt4.
225 """Enable event loop integration with PyQt4.
225
226
226 Parameters
227 Parameters
227 ----------
228 ----------
228 app : Qt Application, optional.
229 app : Qt Application, optional.
@@ -288,7 +289,7 b' class InputHookManager(object):'
288
289
289 def disable_gtk(self):
290 def disable_gtk(self):
290 """Disable event loop integration with PyGTK.
291 """Disable event loop integration with PyGTK.
291
292
292 This merely sets PyOS_InputHook to NULL.
293 This merely sets PyOS_InputHook to NULL.
293 """
294 """
294 self.clear_inputhook()
295 self.clear_inputhook()
@@ -319,7 +320,7 b' class InputHookManager(object):'
319
320
320 def disable_tk(self):
321 def disable_tk(self):
321 """Disable event loop integration with Tkinter.
322 """Disable event loop integration with Tkinter.
322
323
323 This merely sets PyOS_InputHook to NULL.
324 This merely sets PyOS_InputHook to NULL.
324 """
325 """
325 self.clear_inputhook()
326 self.clear_inputhook()
@@ -345,7 +346,7 b' class InputHookManager(object):'
345 without first creating a window. You should thus not create another
346 without first creating a window. You should thus not create another
346 window but use instead the created one. See 'gui-glut.py' in the
347 window but use instead the created one. See 'gui-glut.py' in the
347 docs/examples/lib directory.
348 docs/examples/lib directory.
348
349
349 The default screen mode is set to:
350 The default screen mode is set to:
350 glut.GLUT_DOUBLE | glut.GLUT_RGBA | glut.GLUT_DEPTH
351 glut.GLUT_DOUBLE | glut.GLUT_RGBA | glut.GLUT_DEPTH
351 """
352 """
@@ -379,7 +380,7 b' class InputHookManager(object):'
379
380
380 def disable_glut(self):
381 def disable_glut(self):
381 """Disable event loop integration with glut.
382 """Disable event loop integration with glut.
382
383
383 This sets PyOS_InputHook to NULL and set the display function to a
384 This sets PyOS_InputHook to NULL and set the display function to a
384 dummy one and set the timer to a dummy timer that will be triggered
385 dummy one and set the timer to a dummy timer that will be triggered
385 very far in the future.
386 very far in the future.
@@ -421,6 +422,33 b' class InputHookManager(object):'
421 """
422 """
422 self.clear_inputhook()
423 self.clear_inputhook()
423
424
425 def enable_gtk3(self, app=None):
426 """Enable event loop integration with Gtk3 (gir bindings).
427
428 Parameters
429 ----------
430 app : ignored
431 Ignored, it's only a placeholder to keep the call signature of all
432 gui activation methods consistent, which simplifies the logic of
433 supporting magics.
434
435 Notes
436 -----
437 This methods sets the PyOS_InputHook for Gtk3, which allows
438 the Gtk3 to integrate with terminal based applications like
439 IPython.
440 """
441 from IPython.lib.inputhookgtk3 import inputhook_gtk3
442 self.set_inputhook(inputhook_gtk3)
443 self._current_gui = GUI_GTK
444
445 def disable_gtk3(self):
446 """Disable event loop integration with PyGTK.
447
448 This merely sets PyOS_InputHook to NULL.
449 """
450 self.clear_inputhook()
451
424 def current_gui(self):
452 def current_gui(self):
425 """Return a string indicating the currently active GUI or None."""
453 """Return a string indicating the currently active GUI or None."""
426 return self._current_gui
454 return self._current_gui
@@ -439,6 +467,8 b' enable_glut = inputhook_manager.enable_glut'
439 disable_glut = inputhook_manager.disable_glut
467 disable_glut = inputhook_manager.disable_glut
440 enable_pyglet = inputhook_manager.enable_pyglet
468 enable_pyglet = inputhook_manager.enable_pyglet
441 disable_pyglet = inputhook_manager.disable_pyglet
469 disable_pyglet = inputhook_manager.disable_pyglet
470 enable_gtk3 = inputhook_manager.enable_gtk3
471 disable_gtk3 = inputhook_manager.disable_gtk3
442 clear_inputhook = inputhook_manager.clear_inputhook
472 clear_inputhook = inputhook_manager.clear_inputhook
443 set_inputhook = inputhook_manager.set_inputhook
473 set_inputhook = inputhook_manager.set_inputhook
444 current_gui = inputhook_manager.current_gui
474 current_gui = inputhook_manager.current_gui
@@ -480,6 +510,7 b' def enable_gui(gui=None, app=None):'
480 GUI_QT4: enable_qt4,
510 GUI_QT4: enable_qt4,
481 GUI_GLUT: enable_glut,
511 GUI_GLUT: enable_glut,
482 GUI_PYGLET: enable_pyglet,
512 GUI_PYGLET: enable_pyglet,
513 GUI_GTK3: enable_gtk3,
483 }
514 }
484 try:
515 try:
485 gui_hook = guis[gui]
516 gui_hook = guis[gui]
General Comments 0
You need to be logged in to leave comments. Login now