1

I have a code that used to run fine on python2. This code is a cefpython browser very similar to wxpython example located on git repository of cefpython. Now i moved to python3 and I am facing display bugs like the one of this picture:

diaply bug

The code regarding dpi is the following:

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())

And the output prints related to dpi and versions are:

[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)

How can I run this example on python3?

Thank you for any further help. Ricardo

  • 1
    See this comment: https://github.com/cztomczak/cefpython/issues/530#issuecomment-505066492 – Czarek Tomczak Aug 14 '19 at 20:27
  • I had a similar problem with python2 and this solution did not work. But now, with python3, this solution worked for me: cef.Initialize(settings={}, switches={'disable-gpu-compositing': None}) . Thank you a lot! – Ricardo Goncalves Aug 19 '19 at 07:44

1 Answers1

0

The solution to my problem was pointed by Czarek Tomczak on a comment to my question: https://github.com/cztomczak/cefpython/issues/530#issuecomment-505066492

Adding the parameter {'disable-gpu': ''} to the switches solved my problem.

cef.Initialize(settings={}, switches={'disable-gpu': ""})

On the thread available on the link, it says that this is not the right solution. It worked for me, and I am not having problems until now. But if anyone knows another solution I can try it.

  • You have to attach High DPI manifest for both main executable and subprocess executable. Disabling GPU is not recommended, you may just be lucky that it works due to faster startup timing on your machine. – Czarek Tomczak Aug 19 '19 at 11:39
  • Well, I am sorry if my doubts are basic, but I have some questions regarding your comment: (1) What is a High DPI manifest? It is like a config file? Can you give me an example? (2) When you say main executable, are you assuming that i am bundling a cef python script with pyinstaller? (3) To attach a manifest, do I only need to place the manifest on the same path of the executables you've mentioned? – Ricardo Goncalves Aug 21 '19 at 11:01