Skip to content

Commit def445f

Browse files
author
BoboTiG
committed
Add pip setup, ready to use 'pip install mss'
1 parent b64c030 commit def445f

5 files changed

Lines changed: 132 additions & 93 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
*.pyc
12
tests/
3+
MANIFEST.in

README.md

Lines changed: 0 additions & 90 deletions
This file was deleted.

README.rst

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
**********************************************************************
2+
A cross-platform multi-screen shot module in pure python using ctypes
3+
**********************************************************************
4+
5+
Very basic, it will grab one screen shot by monitor or a screen shot of all monitors and save it to an optimised/progressive PNG/JPEG file, Python 2.7/3.3 compatible.
6+
7+
So, while you can `pip install mss`, you may just drop it in your project and forget about it.
8+
9+
MSS stands for Multi-Screen Shot.
10+
11+
It's under zlib licence.
12+
13+
14+
Instance the good class
15+
========================
16+
17+
You can determine automatically which class to use::
18+
19+
from platform import system
20+
from mss import *
21+
22+
systems = {
23+
'Darwin' : MSSMac,
24+
'Linux' : MSSLinux,
25+
'Windows': MSSWindows
26+
}
27+
try:
28+
MSS = systems[system()]
29+
except KeyError:
30+
err = 'System "{0}" not implemented.'.format(system())
31+
raise NotImplementedError(err)
32+
33+
Or simply import the good one::
34+
35+
from mss import MSSLinux as MSS
36+
37+
38+
init(debug=False)
39+
-----------------
40+
41+
When initalising an instance of MSS, you can enable debug output::
42+
43+
mss = MSS(debug=True)
44+
45+
46+
save(output='mss', oneshot=False, ext='png', ftype=0)
47+
-----------------------------------------------------
48+
49+
For each monitor, grab a screen shot and save it to a file.
50+
51+
Parameters::
52+
53+
output - string - the output filename without extension
54+
oneshot - boolean - grab only one screen shot of all monitors
55+
ext - string - file format to save
56+
ftype - int - PNG filter type (0..4 [slower])
57+
58+
This is a generator which returns created files::
59+
60+
'output-1.ext',
61+
'output-2.ext',
62+
...,
63+
'output-NN.ext'
64+
or
65+
'output-full.ext'
66+
67+
68+
Example
69+
========
70+
71+
Then, it is quite simple::
72+
73+
try:
74+
mss = MSS()
75+
76+
# One screen shot per monitor
77+
for filename in mss.save():
78+
print('File "{0}" created.'.format(filename))
79+
80+
# A shot to grab them all :)
81+
for filename in mss.save(oneshot=True):
82+
print('File "{0}" created.'.format(filename))
83+
except Exception as ex:
84+
print(ex)
85+
raise
86+
87+
88+
Bonus
89+
======
90+
91+
Just for fun ...
92+
Show us your screen shot with all monitors in one file, we will update the gallery.
93+
94+
Link to the galley: https://tiger-222.fr/tout/python-mss/galerie/

mss.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
''' An attempt to create a full functionnal multi-screen shot module
5-
in _pure_ python using ctypes.
4+
''' A cross-platform multi-screen shot module in pure python using ctypes.
65
76
This module is maintained by Mickaël Schoentgen <contact@tiger-222.fr>.
87
If you find problems, please submit bug reports/patches via the
@@ -202,7 +201,7 @@ def save(self, output='mss', oneshot=False, ext='png', ftype=0):
202201
203202
Parameters:
204203
- output - string - the output filename without extension
205-
- oneshot - boolean -grab only one screen shot of all monitors
204+
- oneshot - boolean - grab only one screen shot of all monitors
206205
- ext - string - file format to save
207206
- ftype - int - PNG filter type (0..4 [slower])
208207

setup.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
try:
3+
from distutils.core import setup
4+
except ImportError:
5+
from setuptools import setup
6+
7+
open('MANIFEST.in', 'w').write('\n'.join((
8+
"include *.rst",
9+
)))
10+
11+
from mss import __version__
12+
13+
setup(
14+
15+
name="mss",
16+
version=__version__,
17+
author="Tiger-222",
18+
py_modules=['MSS'],
19+
author_email="contact@tiger-222.fr",
20+
description="A cross-platform multi-screen shot module in pure python using ctypes.",
21+
long_description=open('README.rst').read(),
22+
classifiers=[
23+
'Programming Language :: Python',
24+
"Intended Audience :: Developers",
25+
"Intended Audience :: Information Technology",
26+
"License :: OSI Approved :: zlib/libpng License",
27+
"Natural Language :: English",
28+
"Programming Language :: Python :: 2.7",
29+
"Programming Language :: Python :: 3.3",
30+
"Topic :: Multimedia :: Graphics :: Capture :: Screen Capture",
31+
],
32+
url="https://github.com/BoboTiG/python-mss"
33+
)
34+

0 commit comments

Comments
 (0)