feat(elements): make Slider's cb argument optional - #134
Merged
Conversation
Slider(cb, ...) required a callback positionally, forcing every named slider used with the env.values/handle.callback idiom (the common case) to pass a throwaway `lambda v: None`. cb now defaults to None and falls back to a no-op internally, so it can be omitted or passed as a keyword. Cleaned up the now-unnecessary dummy lambda in the examples that only ever used the named-slider pattern.
2 tasks
petercorke
added a commit
to petercorke/swift
that referenced
this pull request
Aug 22, 2026
- Link "this release's changelog" to CHANGELOG.md (was plain text) - Drop the now-unneeded Slider(lambda v: None, ...) positional cb and manual while-True/step/sleep loops in both examples, in favour of cb=None (default since jhavl#134) and env.run(dt=...) -- matches the Sphinx tutorial's current style. Verified both still run headless. - Rewrite the pip extras section following bdsim's pattern (concrete "to include X:" + real extra name) rather than RTB's generic optionlist placeholder + install matrix -- swift only has one real extra (nb), so RTB's matrix would be overkill. - Drop a stray double blank line before the first example.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Slider(cb, ...)required a callback positionally, forcing every named slider used with theenv.values/handle.callbackidiom (the common case — seeexamples/box_sliders.py,panda_ik_sliders.py,two_link_arm.py) to pass a throwawaylambda v: Nonecbnow defaults toNoneand falls back to a no-op internally, so it can be omitted entirely or passed as a keyword —Swift.process_events()'s unconditionalself.elements[event].cb(...)call stays safe either wayTest plan
pytest tests/test_swift_element.py tests/test_assembly_handle.py— addedtest_slider_cb_is_optional, all existing tests (which still pass an explicitcb) untouchedpytest— no regressions (one pre-existing, unrelated failure:test_add_path_sends_points_radius_and_linewidth, caused by the installedspatialgeometryPyPI release lagging behind an unreleasedPolylinerename)🤖 Generated with Claude Code