Skip to content

Matplotlib Device Scaling on Windows#30599

Open
melwyncarlo wants to merge 2 commits intomatplotlib:mainfrom
melwyncarlo:issue_26733
Open

Matplotlib Device Scaling on Windows#30599
melwyncarlo wants to merge 2 commits intomatplotlib:mainfrom
melwyncarlo:issue_26733

Conversation

@melwyncarlo
Copy link
Copy Markdown
Contributor

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.

self.window.protocol("WM_DELETE_WINDOW", destroy)
self.window.deiconify()
self.canvas._tkcanvas.focus_set()
if self._window_dpi.get() != 96:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why hard-code 96?

@tacaswell
Copy link
Copy Markdown
Member

How does this intersect with the discussion in #21875 ?

Comment thread src/_tkagg.cpp
(GetDpiForWindow_t)GetProcAddress(user32, "GetDpiForWindow");
if (GetDpiForWindowPtr == NULL) {
FreeLibrary(user32);
return py::cast(false);
Copy link
Copy Markdown
Member

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?

Comment thread src/_tkagg.cpp
// window_dpi variable stored on interp.
typedef UINT (WINAPI *GetDpiForWindow_t)(HWND);
GetDpiForWindow_t GetDpiForWindowPtr =
(GetDpiForWindow_t)GetProcAddress(user32, "GetDpiForWindow");
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.

Please use the shorter style for casting as in #30615.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Figure sticks out of window after setting window to full screen from code

3 participants