Laying out multiple form components with grid

Hi,

I have one main form (its basically a dashboard) that launches a number of other forms that I have made components. I’m having problems trying to lay them out nicely though… GridPanel gets all messed up with row sizing, and XYPanel is just too messy.

Basically, I’m trying to do something like this inside a column panel.:

image

I’ve been playing around with different ways, but I feel like there has to be a better way than XYPanel:

def dashboard_button_click(self, **event_args):
    """This method is called when the button is clicked"""
    self.content_panel.clear()
    
    dGrid = XYPanel()
    onGrid1 = Form1()
    offGrid1 = Form1()
    feed_on = Form2(sef_prop = "ON property")
    
    #dGrid.add_component(Form1(),x = 10, y = 10, width=272)
    #dGrid.add_component(Form2(),x=300,y=10)
    #dGrid.add_component(Form1(),x = 10, y=210, width = 275)
    
    self.content_panel.add_component(dGrid,full_width_row=True)
        

A bit of a work around but you can create place holder panels inside the outer ColumnPanel.
This way you can lay it out how you want to and then add the Child Forms to the place holder panels.

Does it need to be created dynamically?

Or you could do this with a HTML form but … :nauseated_face:

Those placeholder panels though, isn’t that the same as just adding a couple components in the python code at the time that I need them?

The benefit is that you have the IDE to lay them out ahead of time. So you can use a combination of LinearPanels FlowPanels and ColumnPanels to get the right layout and then the Child Forms can be added to the right place.

Have you got a clone I can have a quick play with?

You bet, here you go:

https://anvil.works/build#clone:IXN5FOOXSN33WA4P=6FMOT237WDBDZ4QJVXAUX754

The “NotionalGrid” is the Form1 above. And “FeedForm” is Form2 above. Thanks for the help!

Which form are you wanting to go where?

sorry, so:

image

If I make changes / save things, does it update that link I put? or is that link frozen in time?

Using two column panels I get the following screenshot. but I hate the way its clustering in the middle / not using the available space…

So you want to use the full_width_row option to sort that out.

1 Like

ah, doh forgot about that. Maybe this is the route I go then?

That link is frozen. Its 2am here so I am calling it for the day. I will send back a clone link once I get it sorted

1 Like

If that is how you want it for sure.

You might be best off creating a dashboard form and building it in that. Then you will be able to navigate between forms without having to rebuild it every time.

That makes sense. Tx!