console: IPython console widgets

This module provides an IPython console widget.

You can push variables - any python object - to the console’s interactive namespace. This provides users with an advanced way of interacting with your program. For instance, if your program has a PlotWidget or a PlotWindow, you can push a reference to these widgets to allow your users to add curves, save data to files… by using the widgets’ methods from the console.

Note

This module has a dependency on IPython and qtconsole (or ipython.qt for older versions of IPython). An ImportError will be raised if it is imported while the dependencies are not satisfied.

Basic usage example:

from silx.gui import qt
from silx.gui.console import IPythonWidget

app = qt.QApplication([])

hello_button = qt.QPushButton("Hello World!", None)
hello_button.show()

console = IPythonWidget()
console.show()
console.pushVariables({"the_button": hello_button})

app.exec_()

This program will display a console widget and a push button in two separate windows. You will be able to interact with the button from the console, for example change its text:

>>> the_button.setText("Spam spam")

An IPython interactive console is a powerful tool that enables you to work with data and plot it. See this tutorial for more information on some of the rich features of IPython.

class silx.gui.console.IPythonWidget(parent=None, custom_banner=None, *args, **kwargs)[source]

Live IPython console widget.

../../_images/IPythonWidget.png
Parameters:custom_banner – Custom welcome message to be printed at the top of the console.
pushVariables(variable_dict)[source]

Given a dictionary containing name / value pairs, push those variables to the IPython console widget.

Parameters:variable_dict – Dictionary of variables to be pushed to the console’s interactive namespace (`{variable_name: object, …}`)
class silx.gui.console.IPythonDockWidget(parent=None, available_vars=None, custom_banner=None, title='Console')[source]

Dock Widget including a IPythonWidget inside a vertical layout.

../../_images/IPythonDockWidget.png
Parameters:
  • available_vars – Dictionary of variables to be pushed to the console’s interactive namespace: {"variable_name": object, …}
  • custom_banner – Custom welcome message to be printed at the top of the console
  • title – Dock widget title
  • parent – Parent qt.QMainWindow containing this qt.QDockWidget
showEvent(event)[source]

Make sure this widget is raised when it is shown (when it is first created as a tab in PlotWindow or when it is shown again after hiding).