Hamza Khalid
Hamza Khalid

Reputation: 21

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 ?

Upvotes: 2

Views: 824

Answers (1)

PCM
PCM

Reputation: 3011

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.

Upvotes: 1

Related Questions