~bennabiy/+junk/python-xlib

« back to all changes in this revision

Viewing changes to examples/record_demo.py

  • Committer: Package Import Robot
  • Author(s): Andrew Shadura, Ramkumar Ramachandra, Andrew Shadura
  • Date: 2015-08-13 08:14:19 UTC
  • mfrom: (6.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20150813081419-hdefinnghp2iydkx
Tags: 0.14+20091101-3
[ Ramkumar Ramachandra ]
* Remove useless debugging output (Closes: #565996)

[ Andrew Shadura ]
* Switch to 3.0 (quilt) format.
* Rename patches.
* Use debhelper 9 in its short form.
* Use pybuild.
* Bump Standards-Version.
* Don't build or install PostScript documentation and info files.
* Use system-provided texi2html instead of a shipped version
  (Closes: #795057).
* Update debian/copyright (Closes: #795057).
* Don't install Makefile or texi2html with the documentation.
* Set executable bit for examples.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
    if reply.category != record.FromServer:
45
45
        return
46
46
    if reply.client_swapped:
47
 
        print "* received swapped protocol data, cowardly ignored"
 
47
        print("* received swapped protocol data, cowardly ignored")
48
48
        return
49
 
    if not len(reply.data) or ord(reply.data[0]) < 2:
 
49
    if not len(reply.data) or reply.data[0] < 2:
50
50
        # not an event
51
51
        return
52
52
 
59
59
 
60
60
            keysym = local_dpy.keycode_to_keysym(event.detail, 0)
61
61
            if not keysym:
62
 
                print "KeyCode%s" % pr, event.detail
 
62
                print("KeyCode%s %s" % (pr, event.detail))
63
63
            else:
64
 
                print "KeyStr%s" % pr, lookup_keysym(keysym)
 
64
                print("KeyStr%s %s" % (pr, lookup_keysym(keysym)))
65
65
 
66
66
            if event.type == X.KeyPress and keysym == XK.XK_Escape:
67
67
                local_dpy.record_disable_context(ctx)
68
68
                local_dpy.flush()
69
69
                return
70
70
        elif event.type == X.ButtonPress:
71
 
            print "ButtonPress", event.detail
 
71
            print("ButtonPress %s" % event.detail)
72
72
        elif event.type == X.ButtonRelease:
73
 
            print "ButtonRelease", event.detail
 
73
            print("ButtonRelease %s" % event.detail)
74
74
        elif event.type == X.MotionNotify:
75
 
            print "MotionNotify", event.root_x, event.root_y
 
75
            print("MotionNotify %i %i" % (event.root_x, event.root_y))
76
76
 
77
77
 
78
78
# Check if the extension is present
79
79
if not record_dpy.has_extension("RECORD"):
80
 
    print "RECORD extension not found"
 
80
    print("RECORD extension not found")
81
81
    sys.exit(1)
82
82
r = record_dpy.record_get_version(0, 0)
83
 
print "RECORD extension version %d.%d" % (r.major_version, r.minor_version)
 
83
print("RECORD extension version %d.%d" % (r.major_version, r.minor_version))
84
84
 
85
85
# Create a recording context; we only want key and mouse events
86
86
ctx = record_dpy.record_create_context(