Integrating tkinter event loop in ipython notebook

Viewed 263

With a simple tkinter gui like this:

import tkinter as tk       

class Application(tk.Frame):              
    def __init__(self, master=None):
        tk.Frame.__init__(self, master)   
        self.grid()                       
        self.createWidgets()

    def printHello(self):
        print("Hello")

    def createWidgets(self):
        self.quitButton = tk.Button(self, text='Quit',
            command=self.quit)            
        self.quitButton.grid(row=1,column=0)    
        self.printButton = tk.Button(self, text='Print',command=lambda: self.printHello())         
        self.printButton.grid(row=1,column=1) 
app = Application()                        
app.master.title('Sample application')     
app.mainloop()

I am trying to follow this documentation to connect the event loop with the ipython notebook's kernel: https://ipython.org/ipython-doc/3/config/eventloops.html

But I can't quite seem to grasp how it works especially: @register_integration('tk')

How can I exactly connect the event loops? And if I do, what can I do with a connected event loop?

0 Answers
Related