Python reference with Tkinter label change text -


I am trying to replace my tanker label text with another function. Somehow I can not reference the label and therefore do not change the label, just add a new one over the old.

works within the init-function of the self.errorLabel ['text'] = 'second' window, but I should be able to do it with any other function, Therefore, in some way a reference mistake

This is my code: tkinter import import system import * import ttk class window (frame): def __init __ (self, master = none): Frame .__ init __ (self, master) self.master = master self.errorLabel = Label (self, text = "some text"). Grid (line = 0) self.init_window () def init_window (self): self.master.title ("example") self.pack (fill = both, extension = 1) goButton = button (auto, text = "go! ", Command = self.client_go) .grid (line = 1, column = 1) quitButton = button (auto, text =" off ", command = self.client_exit) .grid (line = 1, column = 0) def client_exit (Self): exit () def client_go (self): self.errorLabel ['text'] = 'second' # type error: 'any type' object item assignment does not support itself e rrorLabel = label (self, Text = "second"). Grid (Row = 0) Return Root = Tk () Root.Ezimetry ("800x500") App = Window (root) root.mainloop ()

This is a very common error with the tanker code widget. Grid returns none , so when you type:

  self.errorLabel = Label (self, text = "some text") .grid ( Line = 0)   

self.errorLabel is none . Instead, create a widget and use its geometry manager's code in different lines:

  self.errorLabel = Label (self, text = "some text") self.errorLabel.grid (Line = 0)    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -