Python tkinter change variable label state and statusbar
<p>I do have a little problem here. It's about the exchange of variables of a label in TKinter. My program won't refresh the value's.</p>

<pre><code>class Application(Frame):
    def __init__(self,parent,**kw):
         Frame.__init__(self,parent,**kw)
         self.x = None
         self.directory = None
         self.autostate = None
         self.state = "closed"
         self.GUI2()

     def state(self):
         #change states
         self.stateVar="open"
         self.statusbar = "Status: Opening gate..."

         #update tkinter
         self.group.update_idletasks()
         self.w.update_idletasks()

     def GUI2(self):

         self.statusbar = "Status:..."

         # menu left
         self.menu_left = tk.Frame(root, width=150, bg="red", bd=1, relief=RIDGE)
         self.menu_left_upper = tk.Frame(self.menu_left, width=300, height=900, bg="#C0C0C0")
         self.menu_left_lower = tk.Frame(self.menu_left, width=300, bd=1, relief=GROOVE)

         self.label1 = tk.Label(self.menu_left_lower, relief=FLAT, bg="blue" )
         self.button1 = Button(self.menu_left_lower, text="RUN")
         self.test = tk.Label(self.menu_left_upper, text="info", bg="#C0C0C0")


         self.menu_left_upper.pack(side="top", fill="both", expand=TRUE)
         self.menu_left_lower.pack(side="top", fill="both", expand=FALSE)

         # right area
         self.some_title_frame = tk.Frame(root, bg="#dfdfdf", bd=1, relief=RIDGE)
         self.some_title = tk.Label(self.some_title_frame, text="some title", bg="#dfdfdf")
         self.text_area = Listbox(root, width=50, height=10, background="#ffffff", relief=GROOVE)

         #Label and Button
         self.group = LabelFrame(self.menu_left_upper, text="info", height=70)
         self.group.pack(side="top", fill="both", expand=TRUE)
         Button(self.menu_left_lower, text='Press', command=self.state).pack(side="bottom")
         self.w = Label(self.group, text='State='+self.stateVar)    #text printed!
         self.w.pack(expand=TRUE)

         # status bar
         self.status_frame = tk.Frame(root)
         self.status = tk.Label(self.status_frame, text=self.statusbar, bd=1, relief=SUNKEN)    #statusbar printed here
         self.status.pack(fill="both", expand=True)
         self.menu_left.grid(row=0, column=0, rowspan=2, sticky="nsew")
         self.status_frame.grid(row=2, column=0, columnspan=2, sticky="ew")
         root.grid_rowconfigure(1, weight=1)
         root.grid_columnconfigure(1, weight=1)

 #Starts the main loop and causes the class to interact with the init function
 if __name__ == '__main__':
    root = Tk()
    root.title("simulation")
    app = Application(root)
    app.grid()
    root.mainloop()
</code></pre>

<p>Here you can see the whole code.</p>

<p>It's importend to check <strong># tab1</strong> in there will be the button. This button refers to the <strong>def state(self):</strong> This one needs to change the label and the statusbar. wich are packed in <strong>self.w</strong> and <strong>self.status</strong> in the program I added a <strong>#text printed!</strong> after the line.</p>

<p>The error is in the <code>Label</code> arguments: a tekst arguments is <em>not</em> updated if the input-variable is updated. You should assign the <code>stateVar</code> to the <code>Label</code>'s <code>textvariable</code> keyword argument and use no <code>text</code> argument.</p>

python class tkinter