Cannot dynamically remove GUI elements and constraints
See original GitHub issueAlthough I’ve found its possible to dynamically add GUI elements (e.g. create and display a new view on button press), there doesn’t seem to be a way to dynamically delete GUI elements.
For example, I was trying to create a ‘show/hide’ button for a specific GUI element. I haven’t been able to figure out how implement this in the current version of Toga.
I was expecting that deleting a Toga GUI element using del my_element
would remove that element and all constraints related to it, but this doesn’t seem to be the case.
Is there another way to achieve this functionality?
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Cannot dynamically remove GUI elements and constraints #30
Although I've found its possible to dynamically add GUI elements (e.g. create and display a new view on button press), there doesn't seem...
Read more >Java Swing - TableLayout - Components Not Removing From ...
Short answer. You are right, the removeLayoutComponent() method doesn't work properly. Longer answer. Although the TableLayout article on ...
Read more >Auto Layout Guide: Working with Constraints in Interface Builder
Describes the constraint-based system for laying out user interface elements.
Read more >Build a Responsive UI with ConstraintLayout
You can delete a constraint by doing any of the following: Click on a constraint to select it, and then press Delete ....
Read more >UIStackView: Lessons learned - Medium
UIStackView is very powerful layout component but it can cause a lot ... to dynamically add or remove any UI elements from the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@freakboy3742, I was thinking of working on this but wanted to check first what a good API would look like. At the moment, there is only the
Widget.add(*children)
method and I am thinking of adding the following:remove(*children)
removes given children from the widget.insert(index, child)
inserts the given child at the index.One could additionally or alternatively also provide:
insert_before(child, new_child)
insertsnew_child
beforechild
.insert_after(child, new_child)
insertsnew_child
beforechild
.replace(child, new_child)
replaceschild
withnew_child
.remove(index)
removed child at index.Personally, I am in favour of keeping it simple and just having the first two methods.
This issue has been solved in #814