Jupyter Notebook中设置Cell主题

1. 获取本机Jupyter的配置目录

C:\Users\Administrator>jupyter --data-dir
C:\Users\Administrator\AppData\Roaming\jupyter

2. 进入获取的目录,创建指定路径

C:\Users\Administrator>cd C:\Users\Administrator\AppData\Roaming\jupyter
C:\Users\Administrator\AppData\Roaming\jupyter>mkdir nbextensions\jupyter_themes

3. 下载主题JS文件到创建的目录中

theme_selector.js

/*** @author    Gabriel de Maeztu <gabriel.maeztu@gmail.com>* @version   2.0.1* @license   MIT license* @see       http://github.com/merqurio/jupyter_themes* @copyright 2015-2016-2017-2018, Gabriel de Maeztu, http://merqur.io**/define(['require','jquery','base/js/namespace'], function(require, $, Jupyter) {'use strict';var themes = {"Default": null,"3024-day": "/static/components/codemirror/theme/3024-day.css","3024-night": "/static/components/codemirror/theme/3024-night.css","ambiance-mobile": "/static/components/codemirror/theme/ambiance-mobile.css","ambiance": "/static/components/codemirror/theme/ambiance.css","base16-dark": "/static/components/codemirror/theme/base16-dark.css","base16-light": "/static/components/codemirror/theme/base16-light.css","blackboard": "/static/components/codemirror/theme/blackboard.css","cobalt": "/static/components/codemirror/theme/cobalt.css","colorforth": "/static/components/codemirror/theme/colorforth.css","dracula": "/static/components/codemirror/theme/dracula.css","eclipse": "/static/components/codemirror/theme/eclipse.css","elegant": "/static/components/codemirror/theme/elegant.css","erlang-dark": "/static/components/codemirror/theme/erlang-dark.css","icecoder": "/static/components/codemirror/theme/icecoder.css","lesser-dark": "/static/components/codemirror/theme/lesser-dark.css","liquibyte": "/static/components/codemirror/theme/liquibyte.css","material": "/static/components/codemirror/theme/material.css","mbo": "/static/components/codemirror/theme/mbo.css","mdn-like": "/static/components/codemirror/theme/mdn-like.css","midnight": "/static/components/codemirror/theme/midnight.css","monokai": "/static/components/codemirror/theme/monokai.css","neat": "/static/components/codemirror/theme/neat.css","neo": "/static/components/codemirror/theme/neo.css","night": "/static/components/codemirror/theme/night.css","paraiso-dark": "/static/components/codemirror/theme/paraiso-dark.css","paraiso-light": "/static/components/codemirror/theme/paraiso-light.css","pastel-on-dark": "/static/components/codemirror/theme/pastel-on-dark.css","rubyblue": "/static/components/codemirror/theme/rubyblue.css","seti": "/static/components/codemirror/theme/seti.css","solarized": "/static/components/codemirror/theme/solarized.css","the-matrix": "/static/components/codemirror/theme/the-matrix.css","tomorrow-night-bright": "/static/components/codemirror/theme/tomorrow-night-bright.css","tomorrow-night-eighties": "/static/components/codemirror/theme/tomorrow-night-eighties.css","ttcn": "/static/components/codemirror/theme/ttcn.css","twilight": "/static/components/codemirror/theme/twilight.css","vibrant-ink": "/static/components/codemirror/theme/vibrant-ink.css","xq-dark": "/static/components/codemirror/theme/xq-dark.css","xq-light": "/static/components/codemirror/theme/xq-light.css","yeti": "/static/components/codemirror/theme/yeti.css","zenburn": "/static/components/codemirror/theme/zenburn.css"};var fonts = {"Default": {"css": "monospace","url": null},"Hack": {"css": "Hack","url": "//cdn.jsdelivr.net/font-hack/2.019/css/hack-extended.min.css"},"Inconsolata": {"css": "Inconsolata","url": "//fonts.googleapis.com/css?family=Inconsolata"},"Source Code Pro": {"css": "Source Code Pro","url": "//fonts.googleapis.com/css?family=Source+Code+Pro"},"Roboto Mono": {"css": "Roboto Mono","url": "//fonts.googleapis.com/css?family=Roboto+Mono"},"Droid Sans Mono": {"css": "Droid Sans Mono","url": "//fonts.googleapis.com/css?family=Droid+Sans+Mono"},"Ubuntu Mono": {"css": "Ubuntu Mono","url": "//fonts.googleapis.com/css?family=Ubuntu+Mono"},"PT Mono": {"css": "PT Mono","url": "//fonts.googleapis.com/css?family=PT+Mono"},"Fira Mono":{"css": "Fira Mono","url": "//fonts.googleapis.com/css?family=Fira+Mono"}};var CELLS, CODE_CELL;function add_to_toolbar(current_theme) {var cell_menu = $('#cell_menu'),divider = $('<li/>').addClass('divider'),theme_btn = $('<li/>').addClass('dropdown-submenu'),theme_txt = $('<a/>').text('Code Syntax Theme').attr('href', '#'),theme_list = $('<ul/>').addClass('dropdown-menu').attr('id', 'theme_select'),font_btn = $('<li/>').addClass('dropdown-submenu'),font_txt = $('<a/>').text('Code Font').attr('href', '#'),font_list = $('<ul/>').addClass('dropdown-menu').attr('id', 'font_select'),line_btn = $('<li/>'),line_txt = $('<a/>').text('Code Line Numbers').attr('href', '#');// Add label to the toolbarcell_menu.append(divider).append(theme_btn.append(theme_txt).append(theme_list)).append(font_btn.append(font_txt).append(font_list)).append(line_btn.append(line_txt));// Add themes to the selectorfor (var key in themes){theme_list.append($('<li/>').append($('<a/>').text(key).attr('href', '#').attr('data-value', key)));}theme_list.click(function(e){e.preventDefault;if (e.target.tagName === "A"){theme_toggle($(e.target).data("value"));}});// Add fonts to the selectorfor (var key in fonts){font_list.append($('<li/>').append($('<a/>').text(key).attr('href', '#').attr('data-key', key).attr('data-css', fonts[key].css).attr('data-url', fonts[key].url)));}font_list.click(function(e){e.preventDefault;if (e.target.tagName === "A"){font_toggle($(e.target).data("key"),$(e.target).data("css"),$(e.target).data("url"));}});// Toggle line numbersline_txt.click(function(e){e.preventDefault;var opt = CODE_CELL.config.data.CodeCell.cm_config.lineNumbers;var config = CODE_CELL.config;var patch = {CodeCell:{cm_config:{lineNumbers: !opt}}}config.update(patch);for (var i = 0; i < CELLS.length; i++){if(CELLS[i].cell_type == "code"){CELLS[i].code_mirror.setOption('lineNumbers', !opt);}}});}function load_css(theme) {// Create a link element to attach the stylesvar link = document.createElement("link");link.type = "text/css";link.rel = "stylesheet";link.href = window.location.origin + require.toUrl(themes[theme]);link.id = theme + "-css";document.getElementsByTagName("head")[0].appendChild(link);}function load_font(href) {// Create a link element to attach the fontvar link = document.createElement("link");link.type = "text/css";link.rel = "stylesheet";link.href = href;document.getElementsByTagName("head")[0].appendChild(link);}function css_toggle(font) {var style = document.getElementById("font-css");if (!style){// Create a style elementvar style = document.createElement("style");style.type = "text/css";style.id = "font-css"document.head.appendChild(style);}style.innerText = ".CodeMirror {font-family: z;}".replace("z", font);}function theme_toggle(new_theme) {new_theme = (new_theme === "Default")? "ipython" : new_theme;if(new_theme !== "ipython") load_css(new_theme);var config = CODE_CELL.config;var patch = {CodeCell:{cm_config:{theme: new_theme}}}config.update(patch);for (var i = 0; i < CELLS.length; i++){if(CELLS[i].cell_type == "code"){CELLS[i].code_mirror.setOption('theme', new_theme);}}}function font_toggle(key, css, url) {var config = CODE_CELL.config;var patch = {CodeCell:{cm_config:{font_family: key}}}config.update(patch);if (key !== "default") {load_font(url);}css_toggle(css);}function load_cells() {for (var i = 0; i < CELLS.length; i++){if(CELLS[i].cell_type == "code"){CODE_CELL = CELLS[i];break;}}try {var theme = CODE_CELL.config.data.CodeCell.cm_config.theme;var key = CODE_CELL.config.data.CodeCell.cm_config.font_family;load_css(theme);if (key !== "default") {load_font(fonts[key].url);css_toggle(fonts[key].css);}}catch(error) {console.log(error);}add_to_toolbar();}function load_ipython_extension() {CELLS = Jupyter.notebook.get_cells();if (CELLS.length < 1) {setTimeout(function(){load_ipython_extension();},250);}else {load_cells()}}return { load_ipython_extension: load_ipython_extension };});

4. 执行以下命令激活主题

C:\Users\Administrator\AppData\Roaming\jupyter> jupyter nbextension enable jupyter_themes/theme_selector
Enabling notebook extension jupyter_themes/theme_selector...- Validating: problems found:- require?  X jupyter_themes/theme_selector

5. 切换主题

在这里插入图片描述在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/198456.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

TikTok新闻视角:短视频如何改变信息传递方式?

随着数字时代的不断发展&#xff0c;信息传递的方式也在不断演变。近年来&#xff0c;短视频平台TikTok崭露头角&#xff0c;通过其独特的15秒短视频形式&#xff0c;逐渐在新闻传播领域占据一席之地。本文将深入探讨TikTok在新闻视角下是如何改变信息传递方式的&#xff0c;以…

计算机毕设:基于机器学习的生物医学语音检测识别 附完整代码数据可直接运行

项目视频讲解: 基于机器学习的生物医学语音检测识别 完整代码数据可直接运行_哔哩哔哩_bilibili 运行效果图: 数据展示: 完整代码: #导入python的 numpy matplotlib pandas库 import pandas as pd import numpy as np import matplotlib.pyplot as plt #绘图 import se…

jupyter notebook中添加内核kernel

step1 检查环境中是否有kernel python -m ipykernel --versionstep2 若没有kernel&#xff0c;则需要安装 kernel conda install ipykernel -i https://pypi.tuna.tsinghua.edu.cn/simplestep3 查看已添加的内核 jupyter kernelspec liststep4 添加内核 python -m ipykerne…

学习php中使用composer下载安装firebase/php-jwt 以及调用方法

学习php中使用composer下载安装firebase/php-jwt 以及调用方法 1、安装firebase/php-jwt2、封装jwt类 1、安装firebase/php-jwt composer require firebase/php-jwt安装好以后出现以下文件: 2、封装jwt类 根据所使用的php框架&#xff0c;在指定目录创建 Token.php <?ph…

外贸建站要国外服务器吗?海外服务器推荐?

外贸建站如何选国外服务器&#xff1f;海洋建站用什么服务器好&#xff1f; 外贸建站已经成为企业拓展国际市场的一项重要举措。然而&#xff0c;一个关键问题摆在许多企业面前&#xff1a;外贸建站是否需要选择国外服务器呢&#xff1f;这个问题涉及到多方面的考虑因素&#…

智能优化算法应用:基于吉萨金字塔建造算法无线传感器网络(WSN)覆盖优化 - 附代码

智能优化算法应用&#xff1a;基于吉萨金字塔建造算法无线传感器网络(WSN)覆盖优化 - 附代码 文章目录 智能优化算法应用&#xff1a;基于吉萨金字塔建造算法无线传感器网络(WSN)覆盖优化 - 附代码1.无线传感网络节点模型2.覆盖数学模型及分析3.吉萨金字塔建造算法4.实验参数设…

航空复合材料行业分析:预计2028年全球市场规模将达3725.28亿元

航空复合材料是由多种材料层面组合而成的&#xff0c;在冷热不均的环境中&#xff0c;各个组成材料之间的温度承受度不同很容易引起部件损坏等情况的发生&#xff0c;因此随着复合材料在通用航空中应用的增加&#xff0c;航空复合材料维修市场已形成一定规模。目前&#xff0c;…

Node.js入门指南(完结)

目录 接口 介绍 RESTful json-server 接口测试工具 会话控制 介绍 cookie session token 上一篇文章我们介绍了MongoDB&#xff0c;这一篇文章是Node.js入门指南的最后一篇啦&#xff01;主要介绍接口以及会话控制。 接口 介绍 接口是前后端通信的桥梁 &#xff0…

【Unity动画】Unity 动画播放的流程

本文以2D为案例&#xff0c;讲解Unity 播放动画的流程 准备和导入2D动画资源 外部导入序列帧生成的 Unity内部制作的 外部导入的3D动画 2.创建动画过程 打开时间轴Ctrl6 选中场景中的一个未来需要播放动画的物体 回到时间轴点击Create一个新动画片段 拖动2D动画资源放入…

【数据结构和算法】到达首都的最少油耗

其他系列文章导航 Java基础合集数据结构与算法合集 设计模式合集 多线程合集 分布式合集 ES合集 文章目录 其他系列文章导航 文章目录 前言 一、题目描述 二、题解 三、代码 四、复杂度分析 前言 这是力扣的2477题&#xff0c;难度为中等&#xff0c;解题方案有很多种&…

Interpretable Multimodal Misinformation Detection with Logic Reasoning

原文链接 Hui Liu, Wenya Wang, and Haoliang Li. 2023. Interpretable Multimodal Misinformation Detection with Logic Reasoning. In Findings of the Association for Computational Linguistics: ACL 2023, pages 9781–9796, Toronto, Canada. Association for Computa…

前后端验证码分析(字母计算)

样式&#xff1a; 前端&#xff1a; login.vue <template> <view class"normal-login-container"> <view class"login-form-content"> <view class"input-item flex align-center"> <view class"iconfont ic…

【Android】解决安卓中并不存在ActivityMainBinding

安卓中并不存在ActivityMainBinding这个类&#xff0c;这个类是在XML布局的最外层加入就会自动生成。但是你在最后绑定主布局时会报错获取不到根节点getRoot(). 最好的办法就是&#xff0c;删除原来的最外层节点&#xff0c;再重新添加&#xff0c;感觉是因为复制时并没有让系…

基于阿里云服务网格流量泳道的全链路流量管理(一):严格模式流量泳道

作者&#xff1a;尹航 概述 灰度发布是一种常见的对新版本应用服务的发布手段&#xff0c;其特点在于能够将流量在服务的稳定版本和灰度版本之间时刻切换&#xff0c;以帮助我们用更加可靠的方式实现服务的升级。在流量比例切换的过程中&#xff0c;我们可以逐步验证新版本服…

人工智能时代AIGC绘画实战

系列文章目录 送书第一期 《用户画像&#xff1a;平台构建与业务实践》 送书活动之抽奖工具的打造 《获取博客评论用户抽取幸运中奖者》 送书第二期 《Spring Cloud Alibaba核心技术与实战案例》 送书第三期 《深入浅出Java虚拟机》 送书第四期 《AI时代项目经理成长之道》 …

编译WSL内核,用于操作usb读卡器

wsl2默认不能操作usb读卡器&#xff0c;但是对于嵌入式linux开发来说&#xff0c;需要经常对tf卡进行操作&#xff0c;随时都会使用到usb读卡器的访问。下面讲述如何开启wsl2的usb读卡器的访问&#xff0c;主要涉及到以下2个步骤&#xff1a; wsl2本质是一个虚拟机&#xff0c…

C++作业5

完成沙发床的多继承&#xff08;有指针成员&#xff09; 代码&#xff1a; #include <iostream>using namespace std;class Bed { private:double *money; public:Bed(){cout << "Bed::无参构造函数" << endl;}Bed(double money):money(new doub…

【Latex笔记】标题页

整体结构 模板结构如下&#xff1a; \documentclass{book} % 导言区&#xff0c;加载宏包和各项设置&#xff0c;包括参考文献、索引等 \usepackage{makeidx} % 调用makeidx 宏包&#xff0c;用来处理索引 \makeindex % 开启索引的收集 \bibliographystyle{plain} % 指定参考…

010 数据结构_红黑树

前言 本文将会向你介绍红黑树的概念、性质&#xff0c;以及如何手撕红黑树 1 文章重点 文本首先引入红黑树的概念和性质&#xff0c;性质非常重要对于后面的插入操作来说&#xff0c;文章的核心放在了插入部分&#xff0c;另外看插入部分之前记得看声名和节点的定义哦~ 2 引…

嵌入式门槛高吗?

今日话题&#xff0c;嵌入式门槛高吗&#xff1f;在嵌入式领域&#xff0c;门槛因公司和职位的不同而异。普通的嵌入式岗位门槛相对较低&#xff0c;通常要求掌握一些C语言编程和单片机相关知识&#xff0c;可以制作简单的电子产品&#xff0c;但相应的工资较低。然而&#xff…