Inheritance diagram for IPython.lib.inputhook:
Inputhook management for GUI event loop integration.
Bases: object
Manage PyOS_InputHook for different GUI toolkits.
This class installs various hooks under PyOSInputHook to handle GUI event loop integration.
Clear IPython’s internal reference to an application instance.
Whenever we create an app for a user on qt4 or wx, we hold a reference to the app. This is needed because in some cases bad things can happen if a user doesn’t hold a reference themselves. This method is provided to clear the references we are holding.
| Parameters: | gui : None or str
|
|---|
Set PyOS_InputHook to NULL and return the previous one.
| Parameters: | app : optional, ignored
|
|---|
Disable event loop integration with PyGTK.
This merely sets PyOS_InputHook to NULL.
Disable event loop integration with PyQt4.
This merely sets PyOS_InputHook to NULL.
Disable event loop integration with Tkinter.
This merely sets PyOS_InputHook to NULL.
Disable event loop integration with wxPython.
This merely sets PyOS_InputHook to NULL.
Enable event loop integration with PyGTK.
| Parameters: | app : bool
|
|---|
Notes
This methods sets the PyOS_InputHook for PyGTK, which allows the PyGTK to integrate with terminal based applications like IPython.
Enable event loop integration with PyQt4.
| Parameters: | app : bool
|
|---|
Notes
This methods sets the PyOS_InputHook for PyQt4, which allows the PyQt4 to integrate with terminal based applications like IPython.
If app is True, we create an QApplication as follows:
from PyQt4 import QtCore
app = QtGui.QApplication(sys.argv)
But, we first check to see if an application has already been created. If so, we simply return that instance.
Enable event loop integration with Tk.
| Parameters: | app : bool
|
|---|
Notes
Currently this is a no-op as creating a Tkinter.Tk object sets PyOS_InputHook.
Enable event loop integration with wxPython.
| Parameters: | app : bool
|
|---|
Notes
This methods sets the PyOS_InputHook for wxPython, which allows the wxPython to integrate with terminal based applications like IPython.
If app is True, we create an wx.App as follows:
import wx
app = wx.App(redirect=False, clearSigInt=False)
Both options this constructor are important for things to work properly in an interactive context.
But, we first check to see if an application has already been created. If so, we simply return that instance.
Process pending events in the current gui.
This method is just provided for IPython to use internally if needed for things like testing. Third party projects should not call this method, but instead should call the underlying GUI toolkit methods that we are calling.
Start the gtk event loop in a way that plays with IPython.
When a gtk app is run interactively in IPython, the event loop should not be started. This function checks to see if IPython’s gtk integration is activated and if so, it passes. If not, it will call gtk.main(). Unlike the other appstart implementations, this does not take an app argument.
This function should be used by users who want their gtk scripts to work both at the command line and in IPython. These users should put the following logic at the bottom on their script:
Start the qt4 event loop in a way that plays with IPython.
When a qt4 app is run interactively in IPython, the event loop should not be started. This function checks to see if IPython’s qt4 integration is activated and if so, it passes. If not, it will call the exec_() method of the main qt4 app.
This function should be used by users who want their qt4 scripts to work both at the command line and in IPython. These users should put the following logic at the bottom on their script, after they create a QApplication instance (called app here):
Start the tk event loop in a way that plays with IPython.
When a tk app is run interactively in IPython, the event loop should not be started. This function checks to see if IPython’s tk integration is activated and if so, it passes. If not, it will call the mainloop() method of the tk object passed to this method.
This function should be used by users who want their tk scripts to work both at the command line and in IPython. These users should put the following logic at the bottom on their script, after they create a Tk instance (called app here):
Start the wx event loop in a way that plays with IPython.
When a wx app is run interactively in IPython, the event loop should not be started. This function checks to see if IPython’s wx integration is activated and if so, it passes. If not, it will call the MainLoop() method of the main qt4 app.
This function should be used by users who want their wx scripts to work both at the command line and in IPython. These users should put the following logic at the bottom on their script, after they create a App instance (called app here):
Switch amongst GUI input hooks by name.
This is just a utility wrapper around the methods of the InputHookManager object.
| Parameters: | gui : optional, string or None
app : optional, bool
|
|---|---|
| Returns: | The output of the underlying gui switch routine, typically the actual : PyOS_InputHook wrapper object or the GUI toolkit app created, if there was : one. : |