Change Jupyter QtConsole settings
Question:
It is possible to make persistent changes to settings for default settings on Windows 7?
I would like to change font-size and shell size.
Answers:
Did you change the config files? http://ipython.org/ipython-doc/stable/api/generated/IPython.config.loader.html#IPython.config.loader.Config
Step by step, one would do like this:
In bash under Windows 7 (MingW), I would get help straight from IPython with
/c/Python27/Scripts/IPython.exe qtconsole --help-all | grep font2.
Then you just have to edit ipython_config.py (which is located in your .ipython home directory. In Windows 7: /c/Users/< your_user >/.ipython/profile_default/ipython_config.py
c.IPythonWidget.font_size = 11
c.IPythonWidget.font_family = 'Calibri'
For the window size, look at this issue. You may need to install a recent version.
The QtConsole has configurable via the ConsoleWidget. Start with:
> ipython qtconsole --ConsoleWidget.font_size=11
Instructions on configuring the ipython command line application are here on IPython’s web site. Step-by-step instructions for configuring the font size in particular:
First, create the IPython profile. Simply running IPython or IPython’s QtConsole should do this for you, but if you have to do it by hand, run
ipython profile create
Second, create an IPython config file:
- Windows –
%USERPROFILE%.ipythonprofile_defaultipython_config.py
- Linux or OS X –
~/.ipython/profile_default/ipython_config.py
Sample IPython contents:
c = get_config()
c.IPythonWidget.font_size = 11
c.IPythonWidget.font_family = 'Consolas'
There’s a more detailed sample config file at ipython.org.
you can right click on the ipython windows and select “Default”. you can set your default configuration from there.
Works for linux:
Use https://bitbucket.org/joon/color-schemes-for-ipython-qt-console
pip install jupyter_qtconsole_colorschemes
In ~/.jupyter/jupyter_qtconsole_config.py
,
you can further configure other settings mentioned here(https://jupyter.org/qtconsole/stable/config_options.html):
Example:
color_theme = 'monokai' # specify color theme
import pkg_resources
c.JupyterQtConsoleApp.stylesheet = pkg_resources.resource_filename(
"jupyter_qtconsole_colorschemes", "{}.css".format(color_theme))
c.JupyterWidget.syntax_style = color_theme
c.ConsoleWidget.font_size=15
With the most recent versions of IPython/Jupyter:
-
The relevant config file is now ~/.jupyter/jupyter_qtconsole_config.py
At the top of the file we do c = get_config()
-
The relevant command for font size is c.ConsoleWidget.font_size = 12
-
-
Another setting is c.JupyterWidget.syntax_style = "trac"
(for example), which is a colour-scheme setting. List of schemes. It is possible to create a custom scheme: the easiest way seems to be to put a your_name_here.py
into the $PYTHON/Lib/site-packages/pygments/styles
directory, of a similar format to the other files there. (Configuring things this way sounds a bit fragile, but the other suggested way, of registering the custom scheme, seems similarly fragile.) More styles may be specified using CSS. In the config file as above:
c.JupyterQtConsoleApp.stylesheet = '/path/to/your_name_here.css'
An example “LightBG” stylesheet is given here. (There are only a few CSS classes. Some of the default highlighting still stays as default, with no way to change them using either the CSS or the Pygments style file. For example, the highlighting of a SyntaxError
message stays at the default. This might have been fixed in the most recent version — see the discussion here.)
Here’s a bonus. A shortcut for changing IPython qtconsole settings using one function call.
Put the following code into a file named IPYTHON_PROFILE_DIR/startup/startup.ipy
. (For some reason this is still under ~/.ipython
, not ~/.jupyter
.) It can be named something other than “startup.ipy
“, but the extension must be .ipy
, not .py
.
def edit_config():
profile_path = !ipython locate profile
!{'gvim "%s/ipython_config.py"' % profile_path[0]}
(Replace “gvim
” with your preferred editor.)
Now, whenever you need to tweak your Jupyter Qtconsole configuration, you’ll be able to bring it up using:
In [1]: edit_config()
It is possible to make persistent changes to settings for default settings on Windows 7?
I would like to change font-size and shell size.
Did you change the config files? http://ipython.org/ipython-doc/stable/api/generated/IPython.config.loader.html#IPython.config.loader.Config
Step by step, one would do like this:
In bash under Windows 7 (MingW), I would get help straight from IPython with
/c/Python27/Scripts/IPython.exe qtconsole --help-all | grep font2.
Then you just have to edit ipython_config.py (which is located in your .ipython home directory. In Windows 7: /c/Users/< your_user >/.ipython/profile_default/ipython_config.py
c.IPythonWidget.font_size = 11
c.IPythonWidget.font_family = 'Calibri'
For the window size, look at this issue. You may need to install a recent version.
The QtConsole has configurable via the ConsoleWidget. Start with:
> ipython qtconsole --ConsoleWidget.font_size=11
Instructions on configuring the ipython command line application are here on IPython’s web site. Step-by-step instructions for configuring the font size in particular:
First, create the IPython profile. Simply running IPython or IPython’s QtConsole should do this for you, but if you have to do it by hand, run
ipython profile create
Second, create an IPython config file:
- Windows –
%USERPROFILE%.ipythonprofile_defaultipython_config.py
- Linux or OS X –
~/.ipython/profile_default/ipython_config.py
Sample IPython contents:
c = get_config()
c.IPythonWidget.font_size = 11
c.IPythonWidget.font_family = 'Consolas'
There’s a more detailed sample config file at ipython.org.
you can right click on the ipython windows and select “Default”. you can set your default configuration from there.
Works for linux:
Use https://bitbucket.org/joon/color-schemes-for-ipython-qt-console
pip install jupyter_qtconsole_colorschemes
In ~/.jupyter/jupyter_qtconsole_config.py
,
you can further configure other settings mentioned here(https://jupyter.org/qtconsole/stable/config_options.html):
Example:
color_theme = 'monokai' # specify color theme
import pkg_resources
c.JupyterQtConsoleApp.stylesheet = pkg_resources.resource_filename(
"jupyter_qtconsole_colorschemes", "{}.css".format(color_theme))
c.JupyterWidget.syntax_style = color_theme
c.ConsoleWidget.font_size=15
With the most recent versions of IPython/Jupyter:
-
The relevant config file is now
~/.jupyter/jupyter_qtconsole_config.py
At the top of the file we do
c = get_config()
-
The relevant command for font size is
c.ConsoleWidget.font_size = 12
-
Another setting is
c.JupyterWidget.syntax_style = "trac"
(for example), which is a colour-scheme setting. List of schemes. It is possible to create a custom scheme: the easiest way seems to be to put ayour_name_here.py
into the$PYTHON/Lib/site-packages/pygments/styles
directory, of a similar format to the other files there. (Configuring things this way sounds a bit fragile, but the other suggested way, of registering the custom scheme, seems similarly fragile.) More styles may be specified using CSS. In the config file as above:c.JupyterQtConsoleApp.stylesheet = '/path/to/your_name_here.css'
An example “LightBG” stylesheet is given here. (There are only a few CSS classes. Some of the default highlighting still stays as default, with no way to change them using either the CSS or the Pygments style file. For example, the highlighting of a
SyntaxError
message stays at the default. This might have been fixed in the most recent version — see the discussion here.)
Here’s a bonus. A shortcut for changing IPython qtconsole settings using one function call.
Put the following code into a file named IPYTHON_PROFILE_DIR/startup/startup.ipy
. (For some reason this is still under ~/.ipython
, not ~/.jupyter
.) It can be named something other than “startup.ipy
“, but the extension must be .ipy
, not .py
.
def edit_config():
profile_path = !ipython locate profile
!{'gvim "%s/ipython_config.py"' % profile_path[0]}
(Replace “gvim
” with your preferred editor.)
Now, whenever you need to tweak your Jupyter Qtconsole configuration, you’ll be able to bring it up using:
In [1]: edit_config()