form.py

open in new tab
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
Simple example that shows two forms, one which is stretched, and one
in which we use a dummy Widget to fill up space so that the form is
more compact.
"""

from flexx import app, ui


class Form(ui.Widget):

    def init(self):

        with ui.BoxPanel():
            with ui.FormLayout() as self.form:
                self.b1 = ui.Button(title='Name:', text='Hola')
                self.b2 = ui.Button(title='Age:', text='Hello world')
                self.b3 = ui.Button(title='Favorite color:', text='Foo bar')
            with ui.FormLayout() as self.form:
                self.b4 = ui.Button(title='Name:', text='Hola')
                self.b5 = ui.Button(title='Age:', text='Hello world')
                self.b6 = ui.Button(title='Favorite color:', text='Foo bar')
                ui.Widget(flex=1)  # Add a flexer


if __name__ == '__main__':
    m = app.launch(Form, 'browser')
    app.run()