Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Accessing canvas text elements with string.format

Dear Forum,

I have a short question concerning a canvas text element which I am trying to access to change the text:

This is the original text element:

my_canvas["expected_value"] = Text("Durchschnitt: {expected_value}".format(expected_value = states[l]["expected_value"]),center=True, x=256, y=0, font_size=22)

And this is how I try to access the element to change the text since l in states[l] has changed:

my_canvas["expected_value"].text = "Durchschnitt: {expected_value}".format(expected_value = states[l]["expected_value"]

Unfortunately, there seems to be an issue with the syntax.

Do you have any recommendations how I could approach this issue?

Thanks a lot in advance :)

Best,

Sarah

Comments

Sign In or Register to comment.