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')
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()
-
class
flexx.ui.Div(*init_args, **kwargs)¶ Inherits from:
WidgetThis 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.htmlfactory object, it is possible to create any type of DOM element. E.g.ui.html.Table()creates an table andui.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.srcfor 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_classproperty.Also see this example.
-
text¶ property – The inner HTML for this element.
-