-
-
Notifications
You must be signed in to change notification settings - Fork 407
Feature test combobox button bundle #2963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature test combobox button bundle #2963
Conversation
- added initial combobox bundle to test case
- Add COMBOBOX_POSTFIX to extension directory hash calculation - Implement ComboBox creation and member handling in uimaker.py - Add _PyRevitRibbonComboBox wrapper class in ribbon.py - Add ComboBoxGroup component class with members parsing
- the combobox loads and tirggers update
- because of event handling and initialization, we had to match the design pattern used with the smartbutton - using delayed script loading
- Added comprehensive ComboBox property support (Name, ToolTip, Image, ItemText, Current, etc.) - Implemented all ComboBox methods (add_item, add_items, add_separator, get_items, etc.) - Fixed member properties by preserving full member dictionaries in components.py (was converting to tuples) - Fixed member icon/tooltip/group properties by setting on ComboBoxMember object after AddItem - Added encoding declaration to uimaker.py to fix non-ASCII character error - Enhanced logging for ComboBox creation and member property setting - Updated add_item() to return ComboBoxMember for property setting - Full support for ComboBoxMemberData properties (icon, tooltip, group, tooltip_ext, tooltip_image)
- Added comprehensive ComboBox property support (Name, ToolTip, Image, ItemText, Current, etc.) - Implemented all ComboBox methods (add_item, add_items, add_separator, get_items, etc.) - Fixed member properties by preserving full member dictionaries in components.py (was converting to tuples) - Fixed member icon/tooltip/group properties by setting on ComboBoxMember object after AddItem - Added encoding declaration to uimaker.py to fix non-ASCII character error - Updated add_item() to return ComboBoxMember for property setting - Full support for ComboBoxMemberData properties (icon, tooltip, group, tooltip_ext, tooltip_image) - Removed all debugging logging statements
- Formatted components.py, ribbon.py, and uimaker.py with Black - Ensures code follows PEP 8 style guidelines
- resolved auto generated Copilot checks
- Fix debug logging levels and exception handling - Improve code style: reduce nesting, extract helpers - Add missing docstring documentation - Remove redundant code and clarify comments Addresses Copilot AI and human review suggestions.
- Extract _setup_combobox_objects() to handle validation and object creation - Extract _add_combobox_members() to handle member addition logic - Refactor _produce_ui_combobox() for better readability and maintainability - Fix critical indentation bug: unindent code after icon check so tooltips, members, and activation run regardless of icon file presence This refactoring improves code organization by separating concerns: - Setup/validation logic is isolated and testable - Member addition logic is self-contained - Main function focuses on high-level configuration flow
- Add _sanitize_script_file() function to replace common non-ASCII characters with ASCII equivalents - Call sanitization before loading combobox scripts to prevent SyntaxError - Handles em/en dashes, smart quotes, ellipsis, and non-breaking spaces
- Keep only TaskDialog notifications for dropdown changed and closed events - Minimal implementation for testing combobox event handlers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary:
This PR adds ComboBox support to the pyRevit toolbar system, enabling dropdown selection controls in extension ribbons. The implementation includes:
- New
ComboBoxGroupcomponent class with metadata-driven member configuration _PyRevitRibbonComboBoxwrapper class with full property support (icons, tooltips, contextual help)- UI maker integration for ComboBox creation and script initialization
- Test ComboBox bundle in pyRevitDevTools for validation
- Support for event handlers via
__selfinit__pattern
Review Summary:
Reviewed this new feature implementation against IronPython 2.7.12 compatibility requirements, exception handling standards, API consistency patterns, and repository coding practices. The implementation follows established patterns from existing button classes and includes comprehensive property support. Identified 2 issues requiring attention before merge.
Critical Issues Found:
- IronPython 2.7.12 incompatibility in
_sanitize_script_file()function that will cause runtime errors - Missing return statement in
create_combobox()method breaking API consistency
Follow-up suggestions:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements ComboBox functionality for the pyRevit toolbar, adding a new UI component type that allows dropdown selection controls. The implementation includes full property support (icons, tooltips, members) and follows the existing pyRevit architecture patterns for UI components.
Key changes:
- Added
_PyRevitRibbonComboBoxclass with full API support for ComboBox controls - Implemented
ComboBoxGroupcomponent class to handle ComboBox metadata and members - Added file sanitization utility to handle non-ASCII characters in script files
- Integrated ComboBox into the UI creation pipeline with proper lifecycle management
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| pyrevitlib/pyrevit/loader/uimaker.py | Added _sanitize_script_file utility, _produce_ui_combobox function, and ComboBox member handling logic |
| pyrevitlib/pyrevit/extensions/components.py | Added ComboBoxGroup class to handle ComboBox component definition and member metadata processing |
| pyrevitlib/pyrevit/extensions/init.py | Added COMBOBOX_POSTFIX constant to register the new component type |
| pyrevitlib/pyrevit/coreutils/ribbon.py | Added _PyRevitRibbonComboBox wrapper class with full ComboBox API implementation and create_combobox method |
| extensions/pyRevitDevTools.extension/pyRevitDev.tab/Debug.panel/bundle.yaml | Added test ComboBox entry to Debug panel for testing the new feature |
- Change condition to set combobox title only when no current item is selected, improving UI behavior.
- Introduced a new dark icon image for the Test ComboBox combobox to enhance UI aesthetics.
- Updated the submodule reference for pyRevitLabs.Python.Net. - Modified the combobox setup method to return the activated combobox instance, enhancing usability.
…tion - Updated the _sanitize_script_file() function to use codecs for reading and writing files, ensuring better handling of UTF-8 and Latin-1 encodings. - Enhanced error handling to catch LookupError in addition to UnicodeDecodeError, improving robustness when dealing with various file encodings.
|
📦 New work-in-progress (wip) builds are available for 5.3.1.25347+2146-wip |
|
📦 New work-in-progress (wip) builds are available for 5.3.1.25347+2208-wip |
|
@dnenov do you mind providing a notion page for me to include in the pyrevit notion docs about the combobox feature. This will go into Bundles pages. |
|
📦 New work-in-progress (wip) builds are available for 5.3.1.25348+1520-wip |
Test ComboBox implementation to pyRevitDev toolbar.
Description
Based on #2930 - merge first before this PR!
Adds a ComboBox to the
pyRevitDevtoolbar. Acomboboxcannot be added in a pulldown button, so we are adding it to the toolbar instead.Checklist
Before submitting your pull request, ensure the following requirements are met:
pipenv run black {source_file_or_directory}Related Issues
If applicable, link the issues resolved by this pull request:
Additional Notes
Include any additional context, screenshots, or considerations for reviewers.
Thank you for contributing to pyRevit! 🎉