May-25-2023, 07:37 PM
Do you understand the error message now?
You got an error doing this:
You got an error doing this:
label[x]label is a tkinter Label object. Label objects support indexing, but you provide an attribute name as in label["bg"]. x is an int, not a str. Label objects don't understand indexing using ints. When Python tries to get the object associated with the index/key, it calls this.
return self.tk.call(self._w, 'cget', '-' + key)Normally key would be a str, like "bg", but in your code it is an int (0). It cannot add 'cget' + 0. When you try to add an int and a str you get a type error.
Error:TypeError: can only concatenate str (not "int") to str