File: xclient.py

package info (click to toggle)
python-cffi 1.12.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,540 kB
  • sloc: python: 26,777; ansic: 13,858; asm: 116; makefile: 103; sh: 28
file content (27 lines) | stat: -rw-r--r-- 762 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import sys, os

# run xclient_build first, then make sure the shared object is on sys.path
from _xclient_cffi import ffi, lib


# ffi "knows" about the declared variables and functions from the
#     cdef parts of the module xclient_build created,
# lib "knows" how to call the functions from the set_source parts
#     of the module.


class XError(Exception):
    pass

def main():
    display = lib.XOpenDisplay(ffi.NULL)
    if display == ffi.NULL:
        raise XError("cannot open display")
    w = lib.XCreateSimpleWindow(display, lib.DefaultRootWindow(display),
                            10, 10, 500, 350, 0, 0, 0)
    lib.XMapRaised(display, w)
    event = ffi.new("XEvent *")
    lib.XNextEvent(display, event)

if __name__ == '__main__':
    main()