Changing font sizes for single canvas elements
Dear Forum,
I have a question about accessing and changing font sizes of elements that are part of a canvas. For my experiment, I created a canvas consisting of different text elements. Since I want to change the font size of some of those elements, I was wondering whether this is possible and what is the right way to do it?
I found the function for changing the font of the entire canvas (my_canvas.set_font("font", font size)), but I only want to access single text elements and change their font size. Is there maybe a similar way to do so like when changing the color of a text element (my_canvas["element_name"].color = "color")?
I am looking forward to your recommendations!
Thanks a lot in advance :)
Best, Sarah
Comments
Hi @sarah_alexandra ,
You can do this by using
*style_argsand setting the font_size keyword argument:# Create a canvas with two text elements my_canvas = Canvas() my_canvas['string1'] = Text("I like", x=0, y=0, font_size=30) my_canvas['string2'] = Text("programming", x=0, y=100) my_canvas.show()Hope this helps!
Cheers,
Lotje
Did you like my answer? Feel free to

Hi Lotje,
Thanks a lot, this works perfectly! :)
Best,
Sarah