Skip to main content

pyvirtualdisplay is a python wrapper for Xvfb, Xephyr and Xvnc

Links:

Travis Coveralls Latest Version Supported Python versions License Code Health Documentation

Features:
  • python wrapper

  • supported python versions: 2.7, 3.4, 3.5, 3.6, 3.7

  • back-ends: Xvfb, Xephyr, Xvnc

Known problems:
  • only a few back-end options are supported

Possible applications:
  • GUI testing

  • automatic GUI screenshot

Basic usages

Start Xephyr:

from pyvirtualdisplay import Display
xephyr=Display(visible=1, size=(320, 240)).start()

Create screenshot of xmessage with Xvfb:

from easyprocess import EasyProcess
from pyvirtualdisplay.smartdisplay import SmartDisplay
with SmartDisplay(visible=0, bgcolor='black') as disp:
    with EasyProcess('xmessage hello'):
        img = disp.waitgrab()
img.show()

Installation

General

  • install Xvfb or Xephyr or Xvnc.

  • install pip

  • optional: pyscreenshot and PIL should be installed for smartdisplay submodule

  • install the program:

    # as root
    pip install pyvirtualdisplay

Ubuntu 14.04

sudo apt-get install python-pip
sudo apt-get install xvfb xserver-xephyr vnc4server
sudo pip install pyvirtualdisplay
# optional
sudo apt-get install python-pil scrot
sudo pip install pyscreenshot
# optional for examples
sudo pip install entrypoint2

Uninstall

# as root
pip uninstall pyvirtualdisplay

Usage

GUI Test

Testing gnumeric on low resolution:

#-- include('examples/lowres.py') --#
from easyprocess import EasyProcess
from pyvirtualdisplay import Display

if __name__ == "__main__":
    # start Xephyr
    Display(visible=1, size=(320, 240)).start()
    # start Gnumeric
    EasyProcess('gnumeric').start()
#-#

Image:

_img/lowres.png

Screenshot

Create screenshot of xmessage in background:

#-- include('examples/screenshot3.py') --#
'''
using :keyword:`with` statement
'''
from easyprocess import EasyProcess
from pyvirtualdisplay.smartdisplay import SmartDisplay

if __name__ == "__main__":
    with SmartDisplay(visible=0, bgcolor='black') as disp:
        with EasyProcess('xmessage hello'):
            img = disp.waitgrab()


    img.show()
#-#

Image:

_img/screenshot3.png

vncserver

#-- include('examples/vncserver.py') --#
'''
Example for Xvnc backend
'''

from easyprocess import EasyProcess
from pyvirtualdisplay.display import Display

if __name__ == "__main__":
    with Display(backend='xvnc', rfbport=5904) as disp:
        with EasyProcess('xmessage hello') as proc:
            proc.wait()
#-#

xauth

Some programs require a functional Xauthority file. PyVirtualDisplay can generate one and set the appropriate environment variables if you pass use_xauth=True to the Display constructor. Note however that this feature needs xauth installed, otherwise a pyvirtualdisplay.xauth.NotFoundError is raised.

Metadata

Release files for PyVirtualDisplay 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyVirtualDisplay 0.2.3
File Size Uploaded Provenance Actions
PyVirtualDisplay-0.2.3.tar.gz 32.5 kB Without provenance Details for PyVirtualDisplay-0.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for PyVirtualDisplay 0.2.3
File Interpreter ABI Platform Actions
PyVirtualDisplay-0.2.3-py2.py3-none-any.whl Python 2, Python 3 none any Details for PyVirtualDisplay-0.2.3-py2.py3-none-any.whl

Total release size: 47.8 kB

Release files / PyVirtualDisplay-0.2.3.tar.gz

Download URL PyVirtualDisplay-0.2.3.tar.gz
Size 32.5 kB
Tags Source
SHA-256 checksum
How to use checksums
658d03ea2d6727cbe70c30af71e9014d3d39114a3c50bd661b75aad188fdd3aa
BLAKE2b-256 checksum
How to use checksums
bbbf599964d05464400b5a0b1dc69c3b2c93b85902e5fc31758ead0ec169b058
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.16

Release files / PyVirtualDisplay-0.2.3-py2.py3-none-any.whl

Download URL PyVirtualDisplay-0.2.3-py2.py3-none-any.whl
Size 15.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
4525385a161fed836438dc57337ed428fd9c45396542a044c885b048c1c424a6
BLAKE2b-256 checksum
How to use checksums
686b4bc5678b5219edba7190ae45a7e3d02b03dc7d20ffae84047c7494b355c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.16

Security for PyVirtualDisplay 0.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page