title: Change tkinter Label in other class?
body: <p>Can somebody help me please, I'm making an exercise about class and running task on other thread then tkinter. I want to change the label in another class. Can't get my script to work.</p>
  
  <p>I tried different things but I'm having some troubles with understanding the inheriting from classes and the threads, so this is just an example to learn more about it.</p>
  
  <pre><code>from tkinter import *
  import tkinter as tk
  from tkinter import ttk
  import threading
  
  #Gloabl for stopping the run task
  running = True
  
  #class 1 with window
  class App():
  
       def __init__(self):
            #making the window
            self.root = tk.Tk()
            self.root.geometry("400x400+300+300")
            self.root.protocol("WM_DELETE_WINDOW", self.callback)
            self.widgets()
            self.root.mainloop()
  
       # stop task and close window
       def callback(self):
            global running
            running = False
            self.root.destroy()
  
       # all the widgets of the window
       def widgets(self):
            global labelvar
            #startbutton
            self.start_button = tk.Button(self.root, text="Start",     command=lambda:App2())
            self.start_button.pack()
  
            #stopbutton
            self.stop_button = tk.Button(self.root, text="Stop", command=lambda:self.stop())
            self.stop_button.pack()
  
            #Defining variable for text for label
            labelvar = "Press start to start running"
            self.label = tk.Label(self.root, text=labelvar)
            self.label.pack()
  
       #stop the task
       def stop(self):
            global running
            running = False
  
  
  #class 2 with task in other thread
  class App2(threading.Thread):
  
       def __init__(self):
            global running
            #check if task can be run
            running = True
            threading.Thread.__init__(self)
            self.start()
  
       def run(self):
                 #starting random work
                 for i in range(10000):
                      print(i)
                      labelvar = "running"
                      App.label.pack()
                      #checking if task can still be running else stop task
                      if running == False:
                           break
                           labelvar = "stopped"
                           App.label.pack()
  
  #initiate main app
  app = App()
  </code></pre>