Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Kaufmann <humitos@gmail.com>2012-11-02 23:36:16 (GMT)
committer Manuel Kaufmann <humitos@gmail.com>2012-11-02 23:36:16 (GMT)
commit987d93d92d738e9779d8e3ba9468f9ef370e0d90 (patch)
tree8de473d72878b58a5de9d42f29f25bcea421ea13
parent74be1f80f1b8d985c7de82551a4a0d24a04fdfca (diff)
Script for take an screenshot
-rw-r--r--examples/take_screenshot.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/examples/take_screenshot.py b/examples/take_screenshot.py
new file mode 100644
index 0000000..b71f5b3
--- /dev/null
+++ b/examples/take_screenshot.py
@@ -0,0 +1,15 @@
+import cairo
+from gi.repository import Gdk
+
+file_path = '/tmp/screenshot.png'
+
+window = Gdk.get_default_root_window()
+width, height = window.get_width(), window.get_height()
+
+window_cr = Gdk.cairo_create(window)
+window_surface = window_cr.get_target()
+screenshot_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
+cr = cairo.Context(screenshot_surface)
+cr.set_source_surface(window_surface)
+cr.paint()
+screenshot_surface.write_to_png(file_path)