Skip to main content

python wrapper for Xvfb, Xephyr and Xvnc

Project description

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.5, 3.6, 3.7, 3.8

  • 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:

    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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyVirtualDisplay-0.2.5.tar.gz (32.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PyVirtualDisplay-0.2.5-py2.py3-none-any.whl (13.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file PyVirtualDisplay-0.2.5.tar.gz.

File metadata

  • Download URL: PyVirtualDisplay-0.2.5.tar.gz
  • Upload date:
  • Size: 32.5 kB
  • Tags: Source
  • Uploaded using 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.17

File hashes

Hashes for PyVirtualDisplay-0.2.5.tar.gz
Algorithm Hash digest
SHA256 5b267c8ffc98fcbd084ba852ab4caef3f22e9362bc5d117e1697e767553eaf41
MD5 aa376e8cb97def0dffd81fc17f8073d3
BLAKE2b-256 1e7c28b48481c8992727ac90526bb4395b76081b6df8265835a6d6a478c7e2c9

See more details on using hashes here.

File details

Details for the file PyVirtualDisplay-0.2.5-py2.py3-none-any.whl.

File metadata

  • Download URL: PyVirtualDisplay-0.2.5-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using 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.17

File hashes

Hashes for PyVirtualDisplay-0.2.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 cab4ce130be34a9f62b402954451e829035616d39d7a1ba485dabbf77afb9fb4
MD5 9df48c62cfaf1a9f44c0457d30b66987
BLAKE2b-256 69ec8221a07850d69fa3c57c02e526edd23d18c7c05d58ed103e3b19172757c1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page