rawpython / remi

Python REMote Interface library. Platform independent. In about 100 Kbytes, perfect for your diet.
Apache License 2.0
3.48k stars 401 forks source link

widgets in table #471

Closed Wouter1 closed 2 years ago

Wouter1 commented 2 years ago

I need to put hyperlinks, text with layout (gui.Label) and buttons in tables. I can also see use of placing other widgets like checkboxes in a table.

How do you put widgets in a table?

dddomodossola commented 2 years ago

Hello @Wouter1 ,

To add widgets to a table you should first append them into a TableItem , and then append the table item to a Table. Here is an example:

import remi.gui as gui
from remi import start, App

class MyApp(App):
    def main(self):
        # creating a container VBox type, vertical (you can use also HBox or Widget)
        main_container = gui.VBox(width=500, height=500, style={'margin': '0px auto'})

        di1 = gui.DropDownItem('drop 1')
        di2 = gui.DropDownItem('drop 2')
        drop = gui.DropDown(children=[di1, di2])

        bt = gui.Button("BUTTON")

        item1 = gui.TableItem('item 1')
        item2 = gui.TableItem(children=drop)
        item3 = gui.TableItem('item 3')
        item4 = gui.TableItem()

        item4.append(bt)

        row1 = gui.TableRow(children=[item1,item2,item3,item4])
        table = gui.Table(children=[row1])

        main_container.append(table)
        # returning the root widget
        return main_container

if __name__ == "__main__":
    # starts the webserver
    start(MyApp, address='0.0.0.0', port=0, start_browser=True)
Wouter1 commented 2 years ago

Great that this is possible, thanks! Might be a good idea to include this with your examples,

dddomodossola commented 2 years ago

@Wouter1 Thank you for the suggestion. I have to rework some examples, maybe I will include this too.