Non-blocking function calls prevent tkintker GUI from starting Non-blocking function calls prevent tkintker GUI from starting tkinter tkinter

Non-blocking function calls prevent tkintker GUI from starting


I generally use this approach to use the built-in tkinter event loop (using the after command), which will avoid blocking:

import tkinterfrom tkinter import *class Visual(Frame):    def __init__(self, root):        self.root = root        self.root.title("Am I connected?")        self.net_color = "red"        self.connected = False        self.timer = 0        monitor = Frame(self.root)        monitor.grid(row=0, column=0)        monitor_label = Label(monitor, bd=2, relief=SUNKEN,                                 text="Net",                                 fg="white",                                 bg=self.net_color,                                 padx=3,                                 font=('courier', 16, 'bold'))        monitor_label.grid()        self.getInfos()    def getInfos(self):        print("Got the info")        self.root.after(1000, self.getInfos)if __name__ == '__main__':    root = Tk()    v = Visual(root)    root.mainloop()