Code generated form with multiple components on single line

I’m trying to create dynamic forms. Most lines exist out of multiple components: a Label and and text box, next to each other. When I use addcomponent to a form, it’s always place vertically and I can’t seem to find a way to get two or more components next to each other. I tried by creating a container. I did find a reference to using grids, but that seems overkill. Any hint on how to implement this would be appreciated?

Use a Grid Panel :

https://anvil.works/docs/client/components/containers#gridpanel

This will add a label and a text box on the same line (extracted from a project and modified for simplicity) :

  lbl = Label(text="My Label")
  self.grid_panel_1.add_component(lbl, col_xs=0, width_xs=6)
        
  tb = TextBox(text="My Text Box")
  self.grid_panel_1.add_component(tb, col_xs=6, width_xs=6)

It’s the only way I know how to do it, and it’s the recommended way :

1 Like