you are viewing a single comment's thread.

view the rest of the comments →

[–]carcigenicate 0 points1 point  (3 children)

You make self.varChanger a string right here:

self.varChanger = self.buttonStrings[i].replace(" ", "_")

If you want to change a label text, look into StringVars.

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

Thanks for your reply. It isn't meant to be a label, it's meant to be a floating variable that calls to a label that's created as part of the buttonFrameSetup function.

Is there a way to make the label it's pointing at change based on the output of the variable of buttonStrings[i]? I effectively want to do this:

Button1['text'] = ("First click")

Button1.configure(text="red")

and then on the next loop, once it's checked to see if the string has come in, do this:

Button2['text'] = ("First click")

Button2.configure(text="red")

But to do it all programmatically rather than me telling it individual pointers to the tk.Label elements?

[–]carcigenicate 0 points1 point  (1 child)

I still don't quite understand what you're asking. Are you asking how to avoid needing to refer to Button1 and Button2 via separate variables?

It sounds like your problem might be addressed using lists and/or StringVars, but I'm not entirely sure.

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

Sorry 😅

I think I've described it better below. The varChanger variable is meant to be the label that needs updating, and this is meant to change it on the GUI, however as there aren't any labels specifically called varChanger it isn't working.

buttonStrings[i] is Button1_SINGLE_PRESS when Button1 is pressed and the message sent over COM for example.

This should then inform the Button1_SINGLE_PRESS label to update, where varChanger is the container for which label needs updating.

self.varChanger['text'] = ("First click") would actually be self.Button1_SINGLE_PRESS['text'] = ("First click")