from flexx import app, event, ui

class Example(ui.Widget):

    def init(self):
        with ui.HBox():
            self.but = ui.Button(text='Push me')
            self.label = ui.Label(flex=1, wrap=True, text='This is a label. ')

    def _add_label_text(self, *events):
        self.label.set_text(self.label.text + 'Yes it is. ')
open in new tab

class flexx.ui.Label(*init_args, **kwargs)

Inherits from: Widget

Widget to show text/html.

The node of this widget is a <div> with CSS word-wrap and white-space set appropriately.

properties: html, text, wrap

actions: set_html, set_text, set_wrap


StringProp – The html shown in the label.

Warning: there is a risk of introducing openings for XSS attacks when html is introduced that you do not control (e.g. from user input).


action – Setter for the html property. Use with care.


action – Setter for the text property.


action – Setter for the ‘wrap’ property.


StringProp – The text shown in the label (HTML is shown verbatim).


IntProp – Whether the content is allowed to be wrapped on multiple lines. Set to 0/False for no wrap (default), 1/True for word-wrap, 2 for character wrap.