xclient.py 762 B

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