Repository navigation
Support Hi DPI monitors - #571
Conversation
Scale fonts and windows according to monitor DPI settings
Test Results1 318 tests 1 309 ✅ 52s ⏱️ For more details on these failures, see this check. Results for commit 68e9c7f. ♻️ This comment has been updated with latest results. |
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
a8706fd to
68e9c7f
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR adds HiDPI support by dynamically scaling fonts, images, padding, and window dimensions, and refactors the UI code to support dependency injection for improved testability and maintainability. Additionally, tests and configuration files have been updated to reflect these changes and to support the new scaling functionality.
- Added DPI scaling detection and dynamic adjustment in BaseWindow.
- Refactored TemplateOverviewWindow to use dependency injection for vehicle components and program settings.
- Updated tests and pytest configuration to enhance coverage and usability.
Reviewed Changes
Copilot reviewed 8 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_frontend_tkinter_base.py | Removed legacy test file for BaseWindow in favor of updated tests. |
| tests/conftest.py | Added shared Tkinter fixtures and configuration for consistent test environments. |
| pytest.ini | Added a marker for slow tests. |
| ardupilot_methodic_configurator/frontend_tkinter_template_overview.py | Refactored window setup for HiDPI scaling and dependency injection. |
| ardupilot_methodic_configurator/frontend_tkinter_parameter_editor.py | Updated image label usage to correctly call the instance method. |
| ardupilot_methodic_configurator/frontend_tkinter_component_editor_base.py | Corrected image height parameter; potential naming typo in constants remains. |
| ardupilot_methodic_configurator/frontend_tkinter_base_window.py | Enhanced DPI detection, theming, and image handling for HiDPI displays. |
| .github/instructions/pytest_testing_instructions.md | Added comprehensive pytest testing instructions and guidelines. |
Comments suppressed due to low confidence (2)
ardupilot_methodic_configurator/frontend_tkinter_component_editor_base.py:71
- [nitpick] The constant 'VEICLE_IMAGE_WIDTH_PIX' appears to contain a typo; consider renaming it to 'VEHICLE_IMAGE_WIDTH_PIX' for consistency.
VEICLE_IMAGE_WIDTH_PIX = 100
ardupilot_methodic_configurator/frontend_tkinter_template_overview.py:93
- The fallback default 'VehicleComponents' is used but not imported in this file, which may lead to a runtime error. Please add the appropriate import statement for VehicleComponents.
self.vehicle_components_provider: VehicleComponentsProviderProtocol = vehicle_components_provider or VehicleComponents
Scale fonts and windows according to monitor DPI settings
Resolves #544
This pull request introduces HiDPI support to the
ardupilot_methodic_configuratorproject by implementing DPI scaling adjustments across the GUI and updating related tests. Key changes include the addition of a DPI scaling factor, refactoring for dependency injection, and enhancements to theTemplateOverviewWindowclass for better modularity and testability.HiDPI Support:
_get_dpi_scaling_factormethod to detect and apply DPI scaling for HiDPI displays inBaseWindow. This scaling factor is used to adjust font sizes, padding, and window geometry dynamically. (ardupilot_methodic_configurator/frontend_tkinter_base_window.py, ardupilot_methodic_configurator/frontend_tkinter_base_window.pyR46-R80)TemplateOverviewWindowto scale UI components (e.g., font sizes, padding, treeview columns, and image heights) based on the DPI scaling factor. (ardupilot_methodic_configurator/frontend_tkinter_template_overview.py, [1] [2] [3] [4]Dependency Injection:
VehicleComponentsProviderProtocolandProgramSettingsProviderProtocolto enable dependency injection for better testability and modularity inTemplateOverviewWindow. (ardupilot_methodic_configurator/frontend_tkinter_template_overview.py, ardupilot_methodic_configurator/frontend_tkinter_template_overview.pyR29-R49)Refactoring and Modularity:
TemplateOverviewWindowto separate concerns into smaller methods (e.g.,_configure_window,_initialize_ui_components,_setup_layout,_configure_treeview) for improved readability and maintainability. (ardupilot_methodic_configurator/frontend_tkinter_template_overview.py, [1] [2]Testing Enhancements:
BaseWindowto verify the DPI scaling factor's initialization, fallback behavior, and integration into the UI. (tests/test_frontend_tkinter_base_window.py, [1] [2]BaseWindowto reflect its updated module name. (tests/test_frontend_tkinter_base_window.py, tests/test_frontend_tkinter_base_window.pyR21-R22)These changes collectively improve the user experience on HiDPI displays, enhance code maintainability, and ensure robust testing of new functionality.