Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests/inject.py
blob: d69d6ffd986126cbf520a73c093765f39ed2234b (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#Test event injection

import gtk
import gobject
import time
import types

class ClickMaster():
    def __init__(self):
        self.event = None

    def connect(self, button):
        self.id = button.connect("pressed",self.capture_event)
        self.id2 = button.connect("released",self.capture_event2)
        self.id3 = button.connect("clicked",self.capture_event3)
        self.button = button

    def capture_event(self, *args):
        print "Capture Event"
        print args
        self.eventPress = args[-1]
        return False

    def capture_event2(self, *args):
        print "Capture Release"
        print args
        self.eventReleased = args[-1]
        return False

    def capture_event3(self, *args):
        print "Capture Clicked"
        print args
        self.eventClicked = args[-1]
        return False

    def inject_event(self):
        print "Injecting"
        print self.event
        #self.event.put()
        self.button.emit("button_press_event", self.event)

def print_Event(event):
    for att in dir(event):
        if not isinstance(att, types.MethodType):
            print att, getattr(event, att)

if __name__=='__main__':
    w = gtk.Window()
    b = gtk.CheckButton("Auto toggle!")
    c=ClickMaster()
    w.add(b)
    b.show()
    c.connect(b)

    w.show()

    gtk.main()