• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import sys, os
2
3# run xclient_build first, then make sure the shared object is on sys.path
4from _xclient_cffi import ffi, lib
5
6
7# ffi "knows" about the declared variables and functions from the
8#     cdef parts of the module xclient_build created,
9# lib "knows" how to call the functions from the set_source parts
10#     of the module.
11
12
13class XError(Exception):
14    pass
15
16def main():
17    display = lib.XOpenDisplay(ffi.NULL)
18    if display == ffi.NULL:
19        raise XError("cannot open display")
20    w = lib.XCreateSimpleWindow(display, lib.DefaultRootWindow(display),
21                            10, 10, 500, 350, 0, 0, 0)
22    lib.XMapRaised(display, w)
23    event = ffi.new("XEvent *")
24    lib.XNextEvent(display, event)
25
26if __name__ == '__main__':
27    main()
28