8000 have mkQApp configure QApplication such that it handles HIDPI displays on Windows by j9ac9k · Pull Request #1509 · pyqtgraph/pyqtgraph · GitHub
[go: up one dir, main page]

Skip to content

have mkQApp configure QApplication such that it handles HIDPI displays on Windows #1509

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

Merged
merged 7 commits into from
Jan 27, 2021

Conversation

j9ac9k
Copy link
Member
@j9ac9k j9ac9k commented Jan 23, 2021

Still need to do some more testing, looks like Qt6 has great support for hidpi on windows from the get-go. On Qt5, you need to set some environment variables, which this PR is meant to address.

Leaving this PR in draft form as it needs more testing.

Also need to verify fractional scaling; for reference here is how fractional scaling was addressed in matplotlib: matplotlib/matplotlib#15656

@j9ac9k
Copy link
Member Author
j9ac9k commented Jan 23, 2021

This seems to address the issues with a single monitor; I have the equipment to check w/ multiple monitors with different DPI properties...will try verify against those.

Sorry, something went wrong.

@j9ac9k
Copy link
Member Author
j9ac9k commented Jan 24, 2021

Experimenting w/ this locally; I'm having a tough time getting all the above

  • Text to remain not blurry on hidpi and non-hidpi displays
  • QCheckBox 's to not be clipped (easily visible in examples/parametertree.py) on the non-hidpi display

Still have more experimentation to make...

@j9ac9k
Copy link
Member Author
j9ac9k commented Jan 24, 2021

🤦‍♂️ here I'm testing examples, wondering why nothing is behaving different, only to realize when running an example by itself, it spins up it's own QApplication and does not use pg.mkQApp() ... editing all the examples to use mkQApp() now... There may be some caveats with Qt < 5.14; but for 5.14+ I think this will work reliably...

@j9ac9k j9ac9k marked this pull request as ready for review January 24, 2021 06:33
8000
@j9ac9k j9ac9k force-pushed the fix-windows-hidpi branch from 7a80c05 to 3503a3e Compare January 24, 2021 06:34
@j9ac9k
Copy link
Member Author
j9ac9k commented Jan 24, 2021

Special thanks for @QuLogic for creating matplotlib/matplotlib#19123 which was the implementation I needed to see to fix #422

@j9ac9k
Copy link
Member Author
j9ac9k commented Jan 24, 2021

On Qt < 5.14, I would get the QCheckBox clipped in the parameter tree example on a non-scaled display. That was really the only visual issue I could identify but not resolve. The text in my scaled and non-scaled display was always sharp.

In the comments of #756 there was an interesting comment from @Androwei about using ctypes and on windows setting the process to be DPI aware, no matter how I used that example, the text on my second, non-hidpi display was always fuzzy. @t-sommer I see you linked to that issue and incorporated that solution in your app. I would suggest taking a look to see if you notice the same fuzziness I saw on Windows, and if so, I would suggest either migrating to Qt5.14+ and incorporating the arguments in this PR (or better yet, use Qt6).

@j9ac9k j9ac9k changed the title set environment variables before starting QApp have mkQApp configure QApplication such that it handles HIDPI displays on Windows Jan 24, 2021
@2xB
Copy link
Contributor
2xB commented Jan 25, 2021

This concept is great! Just wondering: You are not removing old High DPI-fixes there, so this should not change anything on old code, right? Is there any reason for using PyQtGraph without these flags you set there? In any case, it might be a good idea to write this also in the documentation for people that do not rely on mkQApp?

@2xB
Copy link
Contributor
2xB commented Jan 25, 2021

PS: Can't stress it enough - Finally being able to just code for PyQtGraph without worrying about HighDPI screens is a really awesome sight!

@j9ac9k
Copy link
Member Author
j9ac9k commented Jan 25, 2021 via email

@j9ac9k
Copy link
Member Author
j9ac9k commented Jan 25, 2021

This concept is great! Just wondering: You are not removing old High DPI-fixes there, so this should not change anything on old code, right? Is there any reason for using PyQtGraph without these flags you set there? In any case, it might be a good idea to write this also in the documentation for people that do not rely on mkQApp?

I'm not aware of any dpi related fixes that were in the library before.

Also I'm not opposed to adding something to some documentation, but I'm not sure where it would go.

@2xB
Copy link
Contributor
2xB commented Jan 25, 2021

@j9ac9k You are of course right. I think the great thing is that if this issue is brought up in the future, one can just point people to the documentation or the definition of mkQApp and ask them to use these lines even if they are not using mkQApp, instead of adapting further DPI related fixes. Such fixes would currently btw. be #668 and

self.fontScaleFactor = p.device().logicalDpiX() / 96
. For the documentation, I think
https://pyqtgraph.readthedocs.io/en/latest/how_to_use.html#embedding-widgets-inside-pyqt-applications
could be reasonable?

@j9ac9k
Copy link
Member Author
j9ac9k commented Jan 25, 2021

Oh right! I forgot about the date axis... I'll take a look there.

@j9ac9k
Copy link
Member Author
j9ac9k commented Jan 26, 2021

Regarding the fontScaleFactor bit; I'm unable to "break" it ... but I'm struggling to recall the condition that warranted its usage to begin with:

on non-hidpi external display:
image

on hidpi primary display:
image

Looks much the same on Qt6.... I'm going to remove its usage and say it's good... if someone has a hidpi monitor that can verify examples\DateAxisItem.py works that would be great.

@j9ac9k
Copy link
Member Author
j9ac9k commented Jan 26, 2021

@2xB (or anyone else for that matter) ... I'm having trouble getting a link to work in the documentation:

In the section I just wrote, I have this line, wanting to link to mkQApp

PyQtGraph has a method :func:`mkQApp <pyqtgraph.Qt.mkQApp>` that by default...

Problem is that it does not appear that the contents of Qt.py are in the documentation, so the link doesn't work... so there is a docstring for mkQApp; but it doesn't look like sphinx picks it up?... Keep in mind I know next to nothing about sphinx, how do I go about getting that added in there?

EDIT: Disregard, figured it out 👍

@j9ac9k
Copy link
Member Author
j9ac9k commented Jan 26, 2021

Ok, I think this is ready to merge, I think @ksunden said he would try and verify on his hidpi display, I'll give him another day. I think this guy is ready to merge unless there are further suggestions.

@j9ac9k
Copy link
Member Author
j9ac9k commented Jan 27, 2021

Alright, given I haven't heard anyone saying they've had issues, I'll merge, and await the hidpi issues to come in later 😆

@j9ac9k j9ac9k merged commit 98f6b2f into pyqtgraph:master Jan 27, 2021
@j9ac9k j9ac9k deleted the fix-windows-hidpi branch January 27, 2021 18:06
@j9ac9k j9ac9k restored the fix-windows-hidpi branch January 27, 2021 18:22
j9ac9k added a commit that referenced this pull request Jan 27, 2021
j9ac9k added a commit that referenced this pull request Jan 27, 2021
@j9ac9k j9ac9k mentioned this pull request Jan 27, 2021
@andybarry
Copy link

Congratulations, this is fantastic!

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