-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Matplotlib Device Scaling on Windows #30599
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
base: main
Are you sure you want to change the base?
Conversation
| self.window.protocol("WM_DELETE_WINDOW", destroy) | ||
| self.window.deiconify() | ||
| self.canvas._tkcanvas.focus_set() | ||
| if self._window_dpi.get() != 96: |
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.
why hard-code 96?
|
How does this intersect with the discussion in #21875 ? |
| (GetDpiForWindow_t)GetProcAddress(user32, "GetDpiForWindow"); | ||
| if (GetDpiForWindowPtr == NULL) { | ||
| FreeLibrary(user32); | ||
| return py::cast(false); |
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.
Is completely returning here correct? Is there a case where we may not be able to get the methods for managing the dpi but still need to run the setWindowSubclass method?
| // window_dpi variable stored on interp. | ||
| typedef UINT (WINAPI *GetDpiForWindow_t)(HWND); | ||
| GetDpiForWindow_t GetDpiForWindowPtr = | ||
| (GetDpiForWindow_t)GetProcAddress(user32, "GetDpiForWindow"); |
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.
Please use the shorter style for casting as in #30615.
PR summary
This PR closes #26733.
Basically, the change in DPI is signaled when resizing or changing the device scale, and not when the canvas is launched/loaded, hence the issue.
This video demonstrates the problem and the fix.