我有一个曾经在 python2 上运行良好的代码。此代码是一个 cefpython 浏览器,与位于 cefpython 的 git 存储库中的 wxpython 示例非常相似。现在我搬到了python3,我面临着像这张照片一样的显示错误:
关于 dpi 的代码如下:
def main():
...
if WINDOWS:
# noinspection PyUnresolvedReferences, PyArgumentList
cef.DpiAware.EnableHighDpiSupport()
cef.Initialize(settings=settings)
class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, parent=None, id=wx.ID_ANY,
title='', size=(WIDTH, HEIGHT))
self.browser = None
...
global g_count_windows
g_count_windows += 1
if WINDOWS:
# noinspection PyUnresolvedReferences, PyArgumentList
print("[wxpython.py] System DPI settings: %s"
% str(cef.DpiAware.GetSystemDpi()))
if hasattr(wx, "GetDisplayPPI"):
print("[wxpython.py] wx.GetDisplayPPI = %s" % wx.GetDisplayPPI())
print("[wxpython.py] wx.GetDisplaySize = %s" % wx.GetDisplaySize())
print("[wxpython.py] MainFrame declared size: %s"
% str((WIDTH, HEIGHT)))
size = scale_window_size_for_high_dpi(WIDTH, HEIGHT)
print("[wxpython.py] MainFrame DPI scaled size: %s" % str(size))
wx.Frame.__init__(self, parent=None, id=wx.ID_ANY,
title='wxPython example', size=size)
print("[wxpython.py] MainFrame actual size: %s" % self.GetSize())
与 dpi 和版本相关的输出打印是:
[wxpython.py] CEF Python 66.0
[wxpython.py] Python 3.7.3 32bit
[wxpython.py] wxPython 4.0.6 msw (phoenix) wxWidgets 3.0.5
[wxpython.py] System DPI settings: (120, 120)
[wxpython.py] wx.GetDisplayPPI = (157, 158)
[wxpython.py] wx.GetDisplaySize = (1920, 1080)
[wxpython.py] MainFrame declared size: (800, 600)
[wxpython.py] MainFrame DPI scaled size: (1000, 750)
如何在 python3 上运行此示例?
感谢您提供任何进一步的帮助。里卡多