Jupyter QtConsole: select one of the built in CSSs as the default via configuration

吃可爱长大的小学妹 提交于 2020-07-23 06:34:05

问题


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:

  1. As a test, execute jupyter qtconsole --style monokai. It actually brought monokai (white fgr on dark gray bgr). Moreover, it combined well with my selected c.ConsoleWidget.font_size = 12 in file1.

  2. Then, trying to use my own css. I copied a monokai.css file in C:\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 lines

    c.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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!