Skip to content
sandeep-gh edited this page Jan 18, 2021 · 8 revisions

#Under development

This repo provides a set of APIs to describe UI-template and generate UI-layout and associated code stubs. To showcase we will create a layout that looks as follows:

The snippet below gives a flavor how the API looks-n-feels. It describes two button elements that are to be stacked horizontally and framed.

bld1 = BlockLD([
    Gelem("button1", "button 1", sg.Button,  sty={"auto_size_button": 'False',
                                                  "size": (8, 4)
                                                  }, ex_toggle_attrs=[('button_color',  (
                                                      ('white', 'green'), ('blue', 'black')))]),
    Gelem("button2", "button 2", sg.Button,  sty={"auto_size_button": 'False',
                                                  "size": (8, 4)
                                                  })
], stacked='H', framed=True
)

To create a layout fragment that contains two instantiation of the bld1 template:

bli1 = BlockLI(bld1, ['A', 'B'])

Lets create another similar template and an instance:

bld2 = BlockLD([
    Gelem("text1", "text 1", sg.Text,  sty={"auto_size_text": 'False',
                                            "size": (8, 4)
                                            }),
    Gelem("text2", "text 2", sg.Text,  sty={"auto_size_text": 'False',
                                            "size": (8, 4)
                                            })
], stacked='H', framed=False
)

bli2 = BlockLI(bld2, ['A', 'B'])

Now the two layouts can be composed as follows:

tnli = TreeNodeLI(bli1,
                  bli2,  stacked='H', framed=True)
Clone this wiki locally