It would be really helpful if you could add custom HTML, instead of text, because that would enable you to add further formatting to labels rather than just formatting the whole label. You would add this HTML through an attribute like the current label.text attribute.
EG you could add strong or a tags, as below (could look like this):
self.label_1.html = 'For more information <a href="#">click here</a>'
I would be very pleased if this could be added!
Edit: Am I missing a trick here? If this is already possible, please say so!
Actually, there is a Custom HTML form, that you can create and then use as a component.
1 Like
@p.colbert - I hadn’t thought of that beforehand.
So considering how that would work, you would add a custom HTML form as a component - the only thing that might not work so well is passing variables to the form through python, it might be a challenge getting them in the html. Guess there’s probably a way to do this with JavaScript, however.
Actually, in the form, the html text is accessible from Python, and can be set from Python. So, your code can set it directly. There are examples of this elsewhere in the forum.
Edit: and in the docs.
1 Like
Ah, I will give it a try. Thanks for your help!
With the Javascript improvements, you can also set the HTML of a label using Javascript:
label = js.get_dom_node(self.label_1)
label.innerHTML = "<b>Hello</b>"
Note that this is problematic, since you lose the class that the label originally had, but if your intent is to complete replace the HTML of the label with something else, it’ll do it.
2 Likes