Skip to content

Conversation

@johnzhou721
Copy link
Contributor

@johnzhou721 johnzhou721 commented Jan 3, 2026

WinForms icons in buttons aren't scaled to 32x32 like all other platforms are.

Adds a test for this by adding an intentionally high-res image and making sure icon size is still right.

Also includes unrelated fix.

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@johnzhou721 johnzhou721 marked this pull request as ready for review January 4, 2026 18:07
@johnzhou721
Copy link
Contributor Author

FYI -- pushing an unrelated trivial fix because it's been coming up in testbed runs as a bit of a noise, and is easy to repair. Ready for review iff CI passes.

Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I've fixed one minor markup issue, removed the extra test (as it should be covered by existing tests), and modified the example app to demonstrate (or not, as the case may be) the problem.

More generally, we need to formalise this sort of "get me a 32x icon" API; at present, it's being done ad-hoc through each backend, which isn't ideal. However, we can address that as follow up work.

@@ -0,0 +1 @@
``Screen.as_image`` now properly accounts for HiDPI scaling on Winforms.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Markdown only requires a single quote

Suggested change
``Screen.as_image`` now properly accounts for HiDPI scaling on Winforms.
`Screen.as_image` now properly accounts for HiDPI scaling on Winforms.

image"""
widget.icon = "resources/icons/huge"
await probe.redraw("Button now has a high-resolution image as icon")
probe.assert_icon_size()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT, this test shouldn't be needed - red.png is already 72x72 px, and L81 of this file is asserting that the icon is 32x32. With the fix to the assertion to correct for scaling, that test should be sufficient.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@freakboy3742 Surprisingly when ran on my machine, the red.png thing actually passed. It think it was better to have a guarantee, since the .ico lookup issue on Linux Fedora shows us that the icon lookup order isn't what we think it is sometimes.

@freakboy3742 freakboy3742 merged commit 7c97371 into beeware:main Jan 8, 2026
57 checks passed
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.

2 participants