title: Python Tkinter, how to update table with live data?
body: <p>I am trying to update my Tkinter table with live data. So Far I've managed to create the GUI and set values from the API in the table's labels. However I can't seem to update it once the window's main loop is running. Here is a sample of my code so far:</p>
  
  <pre><code>from __future__ import print_function
  from tkinter import *
  from tkinter import Label,Frame,Tk, Scale, StringVar
  from tkinter.ttk import Notebook, Entry
  def getValue(value):
      print(value)
  
  window = Tk()
  window.title("Table GUI")
  window.configure(bg="pink")
  window.geometry("300x305")
  
  
  
  varas1=StringVar()
  varas2=StringVar()
  varas3=StringVar()
  
  
  vara1=StringVar()
  vara2=StringVar()
  vara3=StringVar()
  
  
  varp1=StringVar()
  varp2=StringVar()
  varp3=StringVar()
  
  varb1=StringVar()
  varb2=StringVar()
  varb3=StringVar()
  
  
  
  
  frame2=Frame(window)
  frame2.pack(fill="both")
  
  tablayout=Notebook(frame2)
  
  tab1=Frame(tablayout)
  
  for row in range(11):
      for column in range (3):
  
      if row==0 and column==0:
          label= Label(tab1,text="Headline1", bg="green", fg="blue", padx=3, pady=3)
          label.config(font=('Arial',16))
          label.grid(row=row,column=column,sticky="nsew", padx=1, pady=1)
          tab1.grid_columnconfigure(column, weight=1)
  
      if row==1 and column==2:
          label = Label(tab1,textvar=vara1,bg="pink", fg="Red", padx=3, pady=3) #Entry or Label with colours
          label.grid(row=row,column=column,sticky="nsew", padx=1, pady=1)
          tab1.grid_columnconfigure(column, weight=1)
  
      if row==2 and column==2:
          label = Label(tab1,textvar=vara2,bg="pink", fg="Red", padx=3, pady=3) #Entry or Label with colours
          label.grid(row=row,column=column,sticky="nsew", padx=1, pady=1)
          tab1.grid_columnconfigure(column, weight=1)
  
      if row==3 and column==2:
          label = Label(tab1,textvar=vara3,bg="pink", fg="Red", padx=3, pady=3) #Entry or Label with colours
          label.grid(row=row,column=column,sticky="nsew", padx=1, pady=1)
          tab1.grid_columnconfigure(column, weight=1)
  
  tablayout.pack(fill="both")
  </code></pre>
  
  <p>Then I put a function that queries a websocket in a while true loop</p>
  
  <pre><code>While true:
      Retrievedatafromwsusingaconnector()
      vara=apiresult['dataA']
      VarA[(vara[0]),
           (vara[1]),
           (vara[2])]    
  </code></pre>
  
  <p>And finally, I link the variables received from the websocket to the ones I defined earlier on:</p>
  
  <pre><code>varas3.set(VarA[0]) 
  varas2.set(VarA[1]) 
  varas1.set(VarA[2])
  </code></pre>
  
  <p>Then run the window's mainloop:</p>
  
  <pre><code>window.mainloop()
  </code></pre>
  
  <p>I read in another similar post (<a href="https://stackoverflow.com/questions/56275043/python-tkinter-display-live-data">Python Tkinter, Display Live Data</a>) that I could use the windows.update() function but I can't seem to see how I can run separately the ws queries from the windows.mainloop() while updating the table's labels at the same time. Perhaps I could do it in an asynchronous manner from the same code? Or do I have to create a database that get's updated and simply have the Tkinter read it? Thanks</p>