IPython: Configuring Canopy's IPython pane (QtConsole)

Canopy’s Python pane is simply an embedded IPython QtConsole and, therefore, can be customized in the same manner that you would use to configure standalone IPython QtConsoles or terminal sessions.

For more details about IPython’s configuration system, please see the official documentation at ipython.org.

As described in the documentation linked above, under the section “Configuration file location”, you should locate your IPython configuration directory, typically found in $HOME/.config/ipython on Linux, or $HOME/.ipython on other systems. To locate these files from the command-line, use the command ipython locate.

Within this directory, you should find a profile_default directory with one or more .py config files.

Changing IPython's QtConsole Buffer Length

As an example, we’ll be editing ipython_qtconsole_config.py to extend the length of the console buffer, or in other words, the number of lines that the IPython command window will allow the user to scroll back through. This is useful in lengthy coding sessions for searching through previous inputs and outputs, or if you expect that the output from a particular command will not fit within the current buffer. If you do not see profile_default or the qtconsole config file, you can create a default profile with configuration files (as usable templates) using the command ipython profile create as described here.

In ipython_qtconsole_config.py, search for “c.IPythonWidget.buffer_size” and you should find a commented line with some default value already specified. Uncomment this line and set a desired value, such as c.IPythonWidget.buffer_size = 2000 or whatever you choose. After saving this file and restarting Canopy, the Python pane should reflect these changes.

Changing the IPython Prompt

In ipython_qtconsole_config.py, make the following changes:

c.IPythonWidget.out_prompt = 'OutYYY[<span class="out-prompt-number">%i</span>]: '
c.IPythonWidget.in_prompt = 'InYYY [<span class="in-prompt-number">%i</span>]: '

Also note that this is HTML, not ANSI prompt config specifications. Again, save this file and restart Canopy.

Have more questions? Submit a request

Comments

Powered by Zendesk