Skip to content

Support Hi DPI monitors - #571

Merged
amilcarlucas merged 3 commits into
masterfrom
Hi_DPI
Jun 22, 2025
Merged

amilcarlucas merged 3 commits into
masterfrom
Hi_DPI

Conversation

@amilcarlucas

@amilcarlucas amilcarlucas commented Jun 20, 2025 •

Copy link
Copy Markdown
Collaborator

Scale fonts and windows according to monitor DPI settings

Resolves #544

This pull request introduces HiDPI support to the ardupilot_methodic_configurator project 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 the TemplateOverviewWindow class for better modularity and testability.

HiDPI Support:

  • Added a _get_dpi_scaling_factor method to detect and apply DPI scaling for HiDPI displays in BaseWindow. 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)
  • Updated TemplateOverviewWindow to 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:

Refactoring and Modularity:

  • Refactored TemplateOverviewWindow to 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:

  • Enhanced tests for BaseWindow to verify the DPI scaling factor's initialization, fallback behavior, and integration into the UI. (tests/test_frontend_tkinter_base_window.py, [1] [2]
  • Renamed the test file for BaseWindow to 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.

Scale fonts and windows according to monitor DPI settings
Copilot AI review requested due to automatic review settings June 20, 2025 23:20

This comment was marked as outdated.

@github-actions

github-actions Bot commented Jun 21, 2025 •

Copy link
Copy Markdown
Contributor

Test Results

1 318 tests   1 309 ✅  52s ⏱️
    1 suites      7 💤
    1 files        2 ❌

For more details on these failures, see this check.

Results for commit 68e9c7f.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Jun 21, 2025 •

Copy link
Copy Markdown
Contributor

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
6868 5151 75% 73% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
ardupilot_methodic_configurator/frontend_tkinter_base_window.py 87% 🟢
ardupilot_methodic_configurator/frontend_tkinter_component_editor_base.py 56% 🟢
ardupilot_methodic_configurator/frontend_tkinter_parameter_editor.py 21% 🟢
ardupilot_methodic_configurator/frontend_tkinter_template_overview.py 91% 🟢
TOTAL 63% 🟢

updated for commit: 8ce29d4 by action🐍

@amilcarlucas
amilcarlucas force-pushed the Hi_DPI branch 3 times, most recently from a8706fd to 68e9c7f Compare June 22, 2025 17:53
@amilcarlucas
amilcarlucas requested a review from Copilot June 22, 2025 17:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vehicle template selection does not render correctly on linux HiDPI displays when not using a uv created venv

2 participants