1

I have a Flask app that render some page on localhost:3000. To display correctly this page on every computer i use chromium browser (Basically WXpython example from cefpython3 with minor changes: https://github.com/cztomczak/cefpython/blob/master/examples/wxpython.py). However on some computers that have a different resolution/zoom level i have to re-run the code with a different value of parameter 'auto_zooming' in order to display correctly the page:

...

zoom = '0'
settings = {'debug': False, 'auto_zooming': zoom} 
cef.Initialize(settings=settings)

...

My question is: There is any way to change the zoom level of Cefpython browser without have to rerun the code everytime i want to change the zoom? I was thinking on something like 'ctrl - +' or 'ctrl - -'.

Thanks in advance, Ricardo

1 Answers1

1

Can't you detect zoom level before initializing CEF?

The auto_zooming option will call SetBrowserDpiSettings C++ function. It sets zoom level constantly in a 50 ms timer. You can implement similar functionality in pure Python. It uses four functions and their Python equivalents are: Browser.SetZoomLevel, Browser.GetZoomLevel, cef.DpiAware.GetSystemDpi and cef.PostDelayedTask.

See the C++ function source code here:

https://github.com/cztomczak/cefpython/blob/6f5bf081fec19647e1860bb3e0f3638c02bb9d11/src/client_handler/dpi_aware.cpp#L163

Czarek Tomczak
  • 20,079
  • 5
  • 49
  • 56