question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot dynamically remove GUI elements and constraints

See original GitHub issue

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 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:closed
  • Created 9 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
samschottcommented, Feb 9, 2020

@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) inserts new_child before child.
  • insert_after(child, new_child) inserts new_child before child.
  • replace(child, new_child) replaces child with new_child.
  • remove(index) removed child at index.

Personally, I am in favour of keeping it simple and just having the first two methods.

0reactions
obulatcommented, Jun 5, 2021

This issue has been solved in #814

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found