问题
I am using Jupyter in Windows. I mean to change coloring of the QT console.
How can I select one of the built in CSSs as the default, via configuration file?
I mean to avoid passing it as an argument as in jupyter qtconsole --style monokai
.
I would rather use a configuration file, e.g. file1 = %USERPROFILE%\.jupyter\jupyter_qtconsole_config.py
What I ultimately want to do is write monokai
in some configuration file, and have the QTconsole load the built-in monokai
.
What I tried so far:
As a test, execute
jupyter qtconsole --style monokai
. It actually brought monokai (white fgr on dark gray bgr). Moreover, it combined well with my selectedc.ConsoleWidget.font_size = 12
in file1.Then, trying to use my own css. I copied a
monokai.css
file inC:\Users\user1
(I have quite a few in my system, but I guess any one should work for the most basic stuff). In file1 I included one of the linesc.JupyterQtConsoleApp.stylesheet = u'C:/Users/user1/monokai.css' c.JupyterQtConsoleApp.stylesheet = 'C:/Users/user1/monokai.css' c.JupyterQtConsoleApp.stylesheet = 'C:\\Users\\user1\\monokai.css'
None worked.
If I made this work, I would still have to find how to replace the specification of a file as a location by a simple CSS name among the built-in.
PS: I know I could also set a Windows shortcut that launches jupyter qtconsole --style monokai
.
I also mean to avoid this.
回答1:
This is a solution, but I am not certain it is the only one, or if it is the most portable across systems. Note: there might be some issues, yet to be solved, in the way this configuration works, see https://github.com/jupyter/qtconsole/issues/334
Use
c.JupyterWidget.syntax_style = 'monokai'
in file %USERPROFILE%\.jupyter\jupyter_qtconsole_config.py
or ~\.jupyter\jupyter_qtconsole_config.py
.
Inspired by this.
来源:https://stackoverflow.com/questions/62728478/jupyter-qtconsole-select-one-of-the-built-in-csss-as-the-default-via-configurat