wx.html2.WebView 显示网页, 发现页面有点模糊.
发现是高分屏引起的, 按照wxPython官档的几个方法进行修改, 都没有效果.
网上最终解决的是打包成exe文件, 然后设置dpi缩放, 那不是更加麻烦
今天碰巧搜索到另一种解决方法, 在windows系统显式为进程设置默认 DPI 感知模式, 代码如下:
"""设置DPI缩放等, wxpython高分辨率下模糊的问题处理"""
import ctypes
# Query DPI Awareness (Windows 10 and 8)
awareness = ctypes.c_int()
errorCode = ctypes.windll.shcore.GetProcessDpiAwareness(0, ctypes.byref(awareness))
print(awareness.value)
# ===============Set DPI Awareness (Windows 10 and 8)===========================
# the argument is the awareness level, which can be 0, 1 or 2:
# for 1-to-1 pixel control I seem to need it to be non-zero
errorCode = ctypes.windll.shcore.SetProcessDpiAwareness(1)
# ===============Set DPI Awareness (Windows 7 and Vista)===========================
# behaviour on later OSes is undefined, although when I run it on my Windows 10 machine,
# it seems to work with effects identical to SetProcessDpiAwareness(1)
# success = ctypes.windll.user32.SetProcessDPIAware()
按照文章链接, 可以解决所有的模糊问题, 而不局限于wxPython, 留贴备查.
实际效果很好, 发现wxPython 所有的控件都存在dpi缩放问题, 不光光只是 WebView

发现是高分屏引起的, 按照wxPython官档的几个方法进行修改, 都没有效果.
网上最终解决的是打包成exe文件, 然后设置dpi缩放, 那不是更加麻烦
今天碰巧搜索到另一种解决方法, 在windows系统显式为进程设置默认 DPI 感知模式, 代码如下:
"""设置DPI缩放等, wxpython高分辨率下模糊的问题处理"""
import ctypes
# Query DPI Awareness (Windows 10 and 8)
awareness = ctypes.c_int()
errorCode = ctypes.windll.shcore.GetProcessDpiAwareness(0, ctypes.byref(awareness))
print(awareness.value)
# ===============Set DPI Awareness (Windows 10 and 8)===========================
# the argument is the awareness level, which can be 0, 1 or 2:
# for 1-to-1 pixel control I seem to need it to be non-zero
errorCode = ctypes.windll.shcore.SetProcessDpiAwareness(1)
# ===============Set DPI Awareness (Windows 7 and Vista)===========================
# behaviour on later OSes is undefined, although when I run it on my Windows 10 machine,
# it seems to work with effects identical to SetProcessDpiAwareness(1)
# success = ctypes.windll.user32.SetProcessDPIAware()
按照文章链接, 可以解决所有的模糊问题, 而不局限于wxPython, 留贴备查.
实际效果很好, 发现wxPython 所有的控件都存在dpi缩放问题, 不光光只是 WebView
