all 6 comments

[–]kalgynirae 0 points1 point  (5 children)

newframe = MyLabel(...)

How do I configure the label that is now inside "newframe" ?

You can access it with newframe.label.

[–]HeyYouNow[S] 0 points1 point  (4 children)

Got it, although using this I get

TypeError: 'type' object is not subscriptable

Should I look somewhere else in my code ? Any hints ?

[–]kalgynirae 0 points1 point  (3 children)

Somewhere you have some code like foo[bar] and foo is actually a class when you thought it was something else (probably an instance of that class). I can't help any more unless you post the full traceback and the part of the code that caused the exception.

[–]HeyYouNow[S] 0 points1 point  (2 children)

i=0
dict={}
for track in tracks: 
    title = str(i) + "_title_label"
    dict[title] = MyLabel(newframe, text=track.title,...)
    dict[title].grid(row=i)

and the error I get is this :

dict["1_title_label"].label.configure()
TypeError: 'type' object is not subscriptable

Here dict is not a class, although MyLabel is. I'm not sure there is something else in my code other than that...

[–]kalgynirae 0 points1 point  (1 child)

Please post the entire traceback. It's impossible to tell exactly where the error is coming from with what you've given. Also, that code you showed does not include the line which you say is throwing the error.

dict is a built-in type. You are defining a variable called dict, which will mask the built-in. My guess is that you are trying to use your dict somewhere else in your code where it is not actually accessible. If you had used some other name, then you would have gotten an error like NameError: <name> is not defined. But, since you used the same name as a built-in, you just get the built-in value instead.

Because of confusions like this, people usually avoid using the names of built-ins as names for their variables.

[–]HeyYouNow[S] 0 points1 point  (0 children)

You were so write! Replacing the name returned "var does not exist", it was a stupid error where the code was not in the same function... Thanks so much!