Creating a TextArea in a specific area of a GridPanel through a function

What I’m trying to do: I am trying to add two TextAreas inside of a GridPanel through Code

What I’ve tried and what’s not working: I tried grabbing the information and attributes of the existing TextArea but I’m not sure which properties determine where TextArea sits in the GridPanel.

Code Sample: my function that is linked to the button to add a new row

def button_add_experience_click(self, **event_args):
    """This method is called when the button is clicked"""
    new_textarea_category = TextArea()
    new_textarea_description = TextArea()

    for component in self.experience1_grid.get_components():
      if isinstance(component, TextArea):
        textarea_desc = component
        print(textarea_desc)
        print(textarea_desc.width) ``` 

Clone link: Anvil | Login

When you add to a grid panel via code, you name the row that you want to add the components to, and then say what column the component starts in: Anvil Docs | Containers

New rows (names you haven’t used before) are added to the bottom of the grid panel.

It’ll likely be easiest if you restrict yourself to adding to a grid panel only through code, or only through the IDE. Put a grid panel inside a grid panel to have an inner one to use for adding content through code.

1 Like