fix: Make UICollection/EntityCollection match Python list semantics
Breaking change: UICollection.remove() now takes a value (element) instead of an index, matching Python's list.remove() behavior. New methods added to both UICollection and EntityCollection: - pop([index]) -> element: Remove and return element at index (default: last) - insert(index, element): Insert element at position Semantic fixes: - remove(element): Now removes first occurrence of element (was: remove by index) - All methods now have docstrings documenting behavior Note on z_index sorting: The collections are sorted by z_index before each render. Using index-based operations (pop, insert) with non-default z_index values may produce unexpected results. Use name-based .find() for stable element access when z_index sorting is in use. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
deb5d81ab6
commit
afcb54d9fe
5 changed files with 564 additions and 31 deletions
|
|
@ -30,6 +30,8 @@ public:
|
|||
static PyObject* append(PyUICollectionObject* self, PyObject* o);
|
||||
static PyObject* extend(PyUICollectionObject* self, PyObject* iterable);
|
||||
static PyObject* remove(PyUICollectionObject* self, PyObject* o);
|
||||
static PyObject* pop(PyUICollectionObject* self, PyObject* args);
|
||||
static PyObject* insert(PyUICollectionObject* self, PyObject* args);
|
||||
static PyObject* index_method(PyUICollectionObject* self, PyObject* value);
|
||||
static PyObject* count(PyUICollectionObject* self, PyObject* value);
|
||||
static PyObject* find(PyUICollectionObject* self, PyObject* args, PyObject* kwds);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue