From 8547d1e8ed7c7b296e2626e72d8c2aeef5406567 Mon Sep 17 00:00:00 2001 From: Thomas Thurman Date: Mon, 12 May 2008 03:31:32 +0000 Subject: [PATCH] Basic Python-based Xlib client for testing and building upon. 2008-05-12 Thomas Thurman * tools/xlib.py: Basic Python-based Xlib client for testing and building upon. svn path=/trunk/; revision=3707 --- ChangeLog | 5 +++++ tools/xlib.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 tools/xlib.py diff --git a/ChangeLog b/ChangeLog index e2e22b37e..e7fe1931f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-05-12 Thomas Thurman + + * tools/xlib.py: Basic Python-based Xlib client for testing + and building upon. + 2008-05-09 Elijah Newren * src/ui/color.[ch]: diff --git a/tools/xlib.py b/tools/xlib.py new file mode 100644 index 000000000..4a244c4f6 --- /dev/null +++ b/tools/xlib.py @@ -0,0 +1,43 @@ +# Very simple Xlib-based client in Python. +# Copyright (c) 2008 Thomas Thurman ; GPL 2.0 or later. +# Originally based around example code in python-xlib +# by Peter Liljenberg . + +import sys + +from Xlib import X +from Xlib.protocol import display +from Xlib.protocol.request import * + +display = display.Display() +screen = display.info.roots[display.default_screen] +window = display.allocate_resource_id() +gc = display.allocate_resource_id() + +CreateWindow(display, None, + depth = screen.root_depth, + wid = window, + parent = screen.root, + x = 100, y = 100, width = 250, height = 250, border_width = 2, + window_class = X.InputOutput, visual = X.CopyFromParent, + background_pixel = screen.white_pixel, + event_mask = (X.ExposureMask | + X.StructureNotifyMask | + X.ButtonPressMask | + X.ButtonReleaseMask | + X.Button1MotionMask), + colormap = X.CopyFromParent) + +CreateGC(display, None, gc, window) + +MapWindow(display, None, window) + +while 1: + event = display.next_event() + + if event.type == X.DestroyNotify: + sys.exit(0) + + print event + +