简体   繁体   中英

How To Access a jupyter Notebook cell using a button click?

Can I access Jupyter Notebook Cell using tkinter desktop application ? 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. 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 ! It can take some time the first time you run this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM