Python jupyter实验室启动器:更改启动器图标的软顺序
在Jupyter实验室启动器中,我想控制启动器图标的排序顺序。基本上,我希望最新版本的Python首先显示在左边 现在,我看不出是什么决定了排序顺序。查看/usr/local/share/jupyter/kernels/和~/.local/share/jupyter/中的kernel.json规范,排序顺序似乎不是基于显示名称、语言或kernel.json创建时间戳显示的。排序顺序看起来有点随意,但可能我没有看到它使用的模式 Jupyter实验室启动器似乎是使用React应用程序()生成的,但我不确定它从何处获取启动器列表(我对React不是非常熟悉)Python jupyter实验室启动器:更改启动器图标的软顺序,python,jupyter,jupyter-lab,jupyterhub,jupyter-kernel,Python,Jupyter,Jupyter Lab,Jupyterhub,Jupyter Kernel,在Jupyter实验室启动器中,我想控制启动器图标的排序顺序。基本上,我希望最新版本的Python首先显示在左边 现在,我看不出是什么决定了排序顺序。查看/usr/local/share/jupyter/kernels/和~/.local/share/jupyter/中的kernel.json规范,排序顺序似乎不是基于显示名称、语言或kernel.json创建时间戳显示的。排序顺序看起来有点随意,但可能我没有看到它使用的模式 Jupyter实验室启动器似乎是使用React应用程序()生成的,但我
有人知道如何更改启动器上图标的排序顺序吗?我想你是在问启动器中笔记本内核的顺序 排序顺序看起来有点随意,但可能我没有看到它使用的模式 首先是“默认”(或“本机”)内核,然后是根据其
display\u名称排序的其他内核
有人知道如何更改启动器上图标的排序顺序吗
据我所见,控制内核顺序的唯一方法是为内核指定display\u name
s,这样它们的顺序根据String.localeCompare()
匹配您想要的(如果不是您首先要看到的内核,则排除“default”/“native”内核)
解释
图标的顺序首先由列组控制,然后由标签上的localeCompare()
控制。在启动程序扩展名的index.tsx文件中,排序发生在这里:
// Within each category sort by rank
for (const cat in categories) {
categories[cat] = categories[cat].sort(
(a: ILauncher.IItemOptions, b: ILauncher.IItemOptions) => {
return Private.sortCmp(a, b, this._cwd, this._commands);
}
);
}
()
排序功能:
/**
* A sort comparison function for a launcher item.
*/
export function sortCmp(
a: ILauncher.IItemOptions,
b: ILauncher.IItemOptions,
cwd: string,
commands: CommandRegistry
): number {
// First, compare by rank.
const r1 = a.rank;
const r2 = b.rank;
if (r1 !== r2 && r1 !== undefined && r2 !== undefined) {
return r1 < r2 ? -1 : 1; // Infinity safe
}
// Finally, compare by display name.
const aLabel = commands.label(a.command, { ...a.args, cwd });
const bLabel = commands.label(b.command, { ...b.args, cwd });
return aLabel.localeCompare(bLabel);
}
}
()
如果您试图如上控制订单,您可能需要考虑排除默认内核(如<代码> Python 3 <代码>或类似),因为它总是首先出现:
class KernelSpecManager(LoggingConfigurable):
[...]
ensure_native_kernel = Bool(True, config=True,
help="""If there is no Python kernelspec registered and the IPython
kernel is available, ensure it is added to the spec list.
"""
)
()我想你是在特别询问启动程序中笔记本内核的顺序
排序顺序看起来有点随意,但可能我没有看到它使用的模式
首先是“默认”(或“本机”)内核,然后是根据其display\u名称排序的其他内核
有人知道如何更改启动器上图标的排序顺序吗
据我所见,控制内核顺序的唯一方法是为内核指定display\u name
s,这样它们的顺序根据String.localeCompare()
匹配您想要的(如果不是您首先要看到的内核,则排除“default”/“native”内核)
解释
图标的顺序首先由列组控制,然后由标签上的localeCompare()
控制。在启动程序扩展名的index.tsx文件中,排序发生在这里:
// Within each category sort by rank
for (const cat in categories) {
categories[cat] = categories[cat].sort(
(a: ILauncher.IItemOptions, b: ILauncher.IItemOptions) => {
return Private.sortCmp(a, b, this._cwd, this._commands);
}
);
}
()
排序功能:
/**
* A sort comparison function for a launcher item.
*/
export function sortCmp(
a: ILauncher.IItemOptions,
b: ILauncher.IItemOptions,
cwd: string,
commands: CommandRegistry
): number {
// First, compare by rank.
const r1 = a.rank;
const r2 = b.rank;
if (r1 !== r2 && r1 !== undefined && r2 !== undefined) {
return r1 < r2 ? -1 : 1; // Infinity safe
}
// Finally, compare by display name.
const aLabel = commands.label(a.command, { ...a.args, cwd });
const bLabel = commands.label(b.command, { ...b.args, cwd });
return aLabel.localeCompare(bLabel);
}
}
()
如果您试图如上控制订单,您可能需要考虑排除默认内核(如<代码> Python 3 <代码>或类似),因为它总是首先出现:
class KernelSpecManager(LoggingConfigurable):
[...]
ensure_native_kernel = Bool(True, config=True,
help="""If there is no Python kernelspec registered and the IPython
kernel is available, ensure it is added to the spec list.
"""
)
()