Giter Club home page Giter Club logo

pyvirtualdisplay's Introduction

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

Warning

at least one back-end should be installed

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()
#-#

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.

pyvirtualdisplay's People

Contributors

ponty avatar kingdread avatar avdn avatar ozans avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.