I am using Python 2.7 and PyGObject 3.0. (This is VERY important! the PyGObject syntax changed with 3.0!)
I need to put a variable in place of a string in a markup, so the output is formatted. This is the code I have for formatting a standard string in a label.
lbl_tile1.set_markup('<span font_family="serif" font = "48" weight = "bold">W</span>')
However, I need to use the data in a variable. The following changes the text, but removes the formatting.
lbl_tile1.set_markup('<span font_family="serif" font = "48" weight = "bold">W</span>')
lbl_tile1.set_text(t[0])
I need to get the variable "t[0]" in place of "W" in the formatted string. How do I do this?
You don't need use the set_text method. You can put the data on set_markup method.
For example:
lbl_tile1.set_markup('<span font_family="serif" font = "48" weight = "bold">{0}</span>'.format(t[0]))