How to Set Dynamically Added Button Heights?

23 views
Skip to first unread message

Frank Duffy

unread,
May 30, 2022, 4:28:37 PM5/30/22
to Enaml
Hi All,

I'm wondering if anyone could point me in the right direction on resizing buttons that were added dynamically via Include. I have four columns which are being modified dynamically by an "Add" button at the top of the UI. 

Each time Add is pressed, a new field is added to the 1st, 2nd, and third col, and a button is added to the fourth. I would like the button to be the same size as the fields in the same row. Each column is a VGroup with a nested Include.

Currently, the VGroups are all constrained to an hbox. I can modify the constraints on the VGroups, but I've been having trouble trying to figure out how to modify the constraints on the VGroup's dynamically added nested elements.

All the best,
Frank


Matthieu Dartiailh

unread,
May 31, 2022, 3:47:08 AM5/31/22
to en...@googlegroups.com
Hi,

From your description it sounds like what you want is actually a grid to display your widgets, and you need to be able to react to the addiction of new widgets.

I would hence suggest you to use a single Container, the grid layout helper function and to override the layout_constraints declarative function to generate the constraints. This function will be called by the framework at the appropriate time, typically each time the children of your widget change.

You can have a look at the example at https://github.com/nucleic/enaml/blob/main/examples/layout/advanced/override_layout_constraints.enaml for how to override layout_constraints (and it also uses a grid).

Best

Matthieu
--
You received this message because you are subscribed to the Google Groups "Enaml" group.
To unsubscribe from this group and stop receiving emails from it, send an email to enaml+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/enaml/64e0985b-f335-4ebb-998d-3ea73dadca40n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages