Allowing a User to build a menu tree dynamically

I want the users to build and modify a nested menu tree ( expand and collapsing)
See below example

Dynamic Menu

Not tried to do this just wondering if it is possible and if so I would welcome any suggestions or examples please

It is not directly supported – there is no built-in expanding/collapsing tree or outline component – but it is definitely possible to build one yourself.

I made several attempts when I was first learning Python and Anvil.

It bugged me that the expand/contract buttons were huge, and there was a similar amount of spacing around items, making the outline much bigger, visually, than necessary. (Anvil’s UI library assumes that it will have to work on a tiny phone screen, for fat-fingered users, and tries to enforce minimum sizes and spacings to make that work. But my app was for desktop only, so…)

I tried to work around the sizing issues, micro-managing placing of widgets. The resulting code was frankly awful, overly complex, and I wouldn’t want to share it here. The better solution, I think, would be to find a suitable Javascript library, and use it instead, via Anvil’s Javascript integration.

Hi Phil, Many thanks for your help here. Much appreciated. I will give it a try.

Syd

There are some great examples of tree structures on the forum—with apps you may clone too.

Back in the day I used a tree in this file share app.

It worked very well!