Question

I'm trying to run a web browser in a virtual display, using the Python library pyvirtualdisplay, which relies on Xvfb. The problem is that I need that browser to be maximized, something I'm not achieving. I start a display with a size of 1024x768, but the browser just takes a portion of the screen, and can't maximize it. I even tried to run the browser with flags that should open it maximized (google-chrome -start-maximized), with no success. As there is no button to maximize the window, I tried pressing F11 to enter in full screen mode, but just takes the same portion of the screen. The result can be seen in the image below:

enter image description here

The code I use to start the display:

from pyvirtualdisplay import Display

Display(visible=1, size=(1024,768)).start()
Était-ce utile?

La solution 2

Problem was that I was not using a window manager, so installing Fluxbox (a lightweight one) and running it after starting the virtual display did the trick.

Autres conseils

For your Chrome parameters, specify the size and position:

chromium browser --window-size=1280,720 --window-position=0,0

I ran into the same problem. If you don't want to use a full window manager, the following should work pretty well:

import Xlib
import Xlib.display

### Create virtual display and open the browser here ###

dpy = Xlib.display.Display()
root = dpy.screen().root
geometry = root.get_geometry()
for win in root.query_tree().children:
    win.configure(x = 0, y = 0,
        width = geometry.width, height = geometry.height)
dpy.sync()
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top