Skip to main content

pyvirtualdisplay is a python wrapper for Xvfb, Xephyr and Xvnc

Links:

Travis Coveralls Latest Version Supported Python versions License Downloads Code Health Documentation

Features:
  • python wrapper

  • supported python versions: 2.6, 2.7, 3.3, 3.4, 3.5

  • 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__":
    Display(visible=1, size=(320, 240)).start()
    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()
#-#

Release files for PyVirtualDisplay 0.2

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
File Size Uploaded
PyVirtualDisplay-0.2.tar.gz 29.6 kB Details

Release files / PyVirtualDisplay-0.2.tar.gz

Download URL PyVirtualDisplay-0.2.tar.gz
Size 29.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8bf0827b04487b6b9ad8490b03254c03948ca7f23bb1de420637b2c09e59ed84
BLAKE2b-256 checksum
How to use checksums
cedf9ab299661784d36e1da9f025d904e96a9a223813be97970277cbb1ca1a04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

3.0

2 release files

2.2

2 release files

2.1

2 release files

2.0

2 release files

1.3.2

2 release files

1.3

2 release files

1.1

2 release files

1.0

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.1

1 release file

This release

0.2 This release

1 release file

0.1.5

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

0.0.0

1 release file

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