Ulm-IQO / qudi-core

A framework for modular measurement applications.
GNU General Public License v3.0
27 stars 19 forks source link

Broken axes (misaligned) on dual screen [Bug] #101

Open blupgnup opened 1 month ago

blupgnup commented 1 month ago

Version

Development

What is affected by the bug?

Any GUI that plots graph and display axes when using dual screen computer.

When does the bug occur?

When using qudi-core on a computer with 2 screens of different size, a known bug of PySide2 leads to misaligned axis when plotting a graph. This is mainly due to Windows HighDPI scaling.

How do we replicate the issue?

Create a GUI that plots a graph using a class inheriting QtWidgets.QMainWindow Launch qudi on a dual screen computer with 2 screens using different windows display scaling. Move the GUI on the second screen, the axes will appear completely misaligned although the plot is still ok.

Expected behavior

Axes should remain aligned for a better viewing and especially because, in this case, the data plotted is also not in phase with axes.

Relevant log output

No response

Additional Comments

The following code can fix this issue by making the program "DPI aware". import platform import ctypes if platform.system()=='Windows' and int(platform.release()) >= 8: ctypes.windll.shcore.SetProcessDpiAwareness(True)

However, it is not possible to use this fix in a qudi module as it needs to run before the main GUI initialization. Was tested successfully by making this change in src\qudi\core\gui\gui.py

There could also be some more 'proper' way to do it using QTAttribute: QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True) QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True) but this did not work in my case...

In any case, if the proposed solution is acceptable, it would be great to have it integrated into qudi-core to avoid working with a modified version and I think this could benefit many users facing the same problem.

Contact Details

No response

Neverhorst commented 1 month ago

Hi @blupgnup,

thank you for raising this issue. Just to give more context, I like to point out a subtle difference when it comes to multi-monitor setups under MS Windows:

blupgnup commented 1 month ago

Hi @Neverhorst,

Thanks for pointing out the QT_ENABLE_HIGHDPI_SCALING and the link with display scaling. This actually lead me to another solution to resolve this issue.

Here is the result of some additional tests:

In conclusion, the DLL call, ensure that this is working without user specific action but at the cost of a slightly blurred window (and maybe unwanted side effects). A better way to fix it is by overriding the High DPI scaling of python under windows but requires user awareness of the existence of this option... Or to disable display scaling completely. I am totally fine with closing this issue without adding the DLL call as it works and is less invasive (also I hate this blurry problem that windows still can't properly solve) but I am not sure what would be the best option for other users...