This creates an anonymous XYPanel
, but doesn’t attach it to the current form, so it won’t be displayed. And without a lasting reference to that object, Python will discard it.
I suspect you should be referring to your form’s existing XYPanel
:
An XYPanel
is probably not what you want here. With an XYPanel
, your code takes full responsibility for placing everything in that XYPanel
, i.e., everything that has the XYPanel
as its direct parent. And as you’ve found out, once placed in that container, a component is not going to move automatically, even if its neighbors are [un]hidden.
Whereas, if your container is a LinearPanel
or ColumnPanel
, instead of an XYPanel
, then Anvil takes responsibility for closing up the space, automatically, when one of its components is [un]hidden. This is a feature I use frequently in my GUIs.