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.
Parameters: custom_banner – Custom welcome message to be printed at the top of the console.
-
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.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 thisqt.QDockWidget
- available_vars – Dictionary of variables to be pushed to the
console’s interactive namespace: