beeware / toga

A Python native, OS native GUI toolkit.
https://toga.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
4.19k stars 656 forks source link

Add API to replace children #2301 #2591

Closed funkyrailroad closed 1 month ago

funkyrailroad commented 1 month ago

Added replace and index methods to base widget class and minimal test cases. Added another test case to verify the functionality of children access/assignment via square bracket notation __setitem__/ __getitem__.

This allows users to replace a child widget with another with a single method, instead of needing to remove the old one, keep track of the index, and insert a new one.

Fixes #2301

PR Checklist:

freakboy3742 commented 1 month ago

If you're still at the sprints, don't forget to come by and get your challenge coin!