Skip to content

Conversation

@dnenov
Copy link
Contributor

@dnenov dnenov commented Dec 10, 2025

Test ComboBox implementation to pyRevitDev toolbar.

Description

Based on #2930 - merge first before this PR!

Adds a ComboBox to the pyRevitDev toolbar. A combobox cannot be added in a pulldown button, so we are adding it to the toolbar instead.

image

Checklist

Before submitting your pull request, ensure the following requirements are met:

  • Code follows the PEP 8 style guide.
  • Code has been formatted with Black using the command:
    pipenv run black {source_file_or_directory}
  • Changes are tested and verified to work as expected.

Related Issues

If applicable, link the issues resolved by this pull request:

  • Resolves #[issue number]

Additional Notes

Include any additional context, screenshots, or considerations for reviewers.


Thank you for contributing to pyRevit! 🎉

dnenov and others added 17 commits November 13, 2025 11:50
- 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
Copy link
Contributor

@devloai devloai bot left a 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 ComboBoxGroup component class with metadata-driven member configuration
  • _PyRevitRibbonComboBox wrapper 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:

  1. IronPython 2.7.12 incompatibility in _sanitize_script_file() function that will cause runtime errors
  2. Missing return statement in create_combobox() method breaking API consistency

Follow-up suggestions:

  • @devloai fix the identified issues
  • @devloai verify the sanitization function is necessary or consider alternative approaches that don't modify user files

@dnenov dnenov mentioned this pull request Dec 10, 2025
3 tasks
Copy link
Contributor

Copilot AI left a 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 _PyRevitRibbonComboBox class with full API support for ComboBox controls
  • Implemented ComboBoxGroup component 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.
@jmcouffin jmcouffin marked this pull request as ready for review December 13, 2025 21:26
@jmcouffin jmcouffin merged commit 9a48de3 into pyrevitlabs:develop Dec 13, 2025
@jmcouffin jmcouffin added the Bundles Issues related to the pyRevit bundles [subsystem] label Dec 13, 2025
@github-actions
Copy link
Contributor

📦 New work-in-progress (wip) builds are available for 5.3.1.25347+2146-wip

@github-actions
Copy link
Contributor

📦 New work-in-progress (wip) builds are available for 5.3.1.25347+2208-wip

@jmcouffin
Copy link
Contributor

@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.

@github-actions
Copy link
Contributor

📦 New work-in-progress (wip) builds are available for 5.3.1.25348+1520-wip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bundles Issues related to the pyRevit bundles [subsystem]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants