简体   繁体   English

如何使用按钮单击访问 jupyter Notebook 单元格?

[英]How To Access a jupyter Notebook cell using a button click?

Can I access Jupyter Notebook Cell using tkinter desktop application ?我可以使用 tkinter 桌面应用程序访问 Jupyter Notebook Cell 吗? OR Can I past code in a cell on a button click ?或者我可以通过单击按钮在单元格中粘贴代码吗?

There is a module called subprocess which you can use to open jupyter notebook along with tkinter.有一个模块调用subprocess ,你可以用它来打开jupyter笔记本Tkinter的一起。 Look at this code -看看这段代码——

import tkinter as tk
import subprocess

root = tk.Tk()

root.title('Jupyter Notebook')

def open_jup():
    p = subprocess.Popen(["start", "cmd", "/k", "jupyter notebook"], shell = True)


button = tk.Button(root,text='OPEN Jupyter Notebook',command=open_jup)
button.pack(fill='both')


root.mainloop()

Subprocess.Popen will open the cmd and run the jupyter notebook and then, this will open the jupyter notebook in the browser This worked for me ! Subprocess.Popen将打开 cmd 并运行jupyter notebook ,然后,这将在浏览器中打开 jupyter notebook 这对我有用! It can take some time the first time you run this.第一次运行它可能需要一些时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用笔记本服务器 rest api 或 python 代码创建新的 jupyter 笔记本单元并更新单元? - How to create a new jupyter notebook cell and update the cell using notebook server rest api's or python code? 在 jupyter notebook 的单元格中使用 sudo - using sudo inside jupyter notebook's cell 如何使用 Jupyter Notebook 访问远程 smb 驱动器上的文件? - How to access a file on a remote smb drive using Jupyter Notebook? 如何在 jupyter notebook 中指定单元格执行 - how to specify cell execution in jupyter notebook 如何在Jupyter Notebook中禁用单元格截断? - How to disable cell truncation in Jupyter Notebook? 如何在 VSCode Jupyter Notebook 中拆分单元格? - How to split cell in VSCode Jupyter Notebook? 如何在Python Jupyter Notebook / Cell中打开URL? - How to Open a URL in Python Jupyter Notebook/Cell? 如何在 Jupyter Notebook 单元格中刷新 Python 导入? - How to refresh a Python import in a Jupyter Notebook cell? 如何在jupyter笔记本中的同一单元格中使用2“urlopen”? - How to use 2 “urlopen” in the same cell in jupyter notebook? 如何在没有 nbextensions 的 python jupyter notebook 中添加按钮以隐藏单元格输入 - How to add button to hide cell inputs in python jupyter notebook without nbextensions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM