Html

Simple example:

from flexx import app, ui

class Example(ui.Widget):

    def init(self):

        with ui.html.UL():
            ui.html.LI(text='foo')
            ui.html.LI(text='bar')
open in new tab

from flexx import app, ui, event

class Example(ui.Widget):

    def init(self):

        with ui.html.UL():
            ui.html.LI(text='foo')
            ui.html.LI(text='bar')
            with ui.html.LI():
                with ui.html.I():
                    self.now = ui.html.Span(text='0')
        self.but = ui.html.Button(text='press me')

    class JS:

        @event.connect('but.mouse_down')
        def on_click(self, *events):
            self.now.text = window.Date.now()
open in new tab


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

Inherits from: Widget

This class is the base class for “HTML widgets”. These provides a lower-level way of working with HTML content that can feel more natural to users with a background in web development.

Via the flexx.ui.html factory object, it is possible to create any type of DOM element. E.g. ui.html.Table() creates an table and ui.html.b(text='foo') creates a piece of bold text.

Since this class inherits from Widget, all base widget functionality (e.g. mouse events) work as expected. However, the specific functionality of each element (e.g. src for img elements) must be used in the “JavaScript way”.

In contrast to regular Flexx widgets, the css class name of the node only consists of the name(s) provided via the css_class property.

Also see this example.

text

property – The inner HTML for this element.