/usr/include/wx-3.0/wx/wxPython/i_files/_event_ex.py is in python-wxgtk3.0-dev 3.0.2.0+dfsg-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | #---------------------------------------------------------------------------
class PyEventBinder(object):
"""
Instances of this class are used to bind specific events to event
handlers.
"""
def __init__(self, evtType, expectedIDs=0):
if expectedIDs not in [0, 1, 2]:
raise ValueError, "Invalid number of expectedIDs"
self.expectedIDs = expectedIDs
if type(evtType) == list or type(evtType) == tuple:
self.evtType = evtType
else:
self.evtType = [evtType]
def Bind(self, target, id1, id2, function):
"""Bind this set of event types to target."""
for et in self.evtType:
target.Connect(id1, id2, et, function)
def Unbind(self, target, id1, id2, handler=None):
"""Remove an event binding."""
success = 0
for et in self.evtType:
success += target.Disconnect(id1, id2, et, handler)
return success != 0
def _getEvtType(self):
"""
Make it easy to get to the default wxEventType typeID for this
event binder.
"""
return self.evtType[0]
typeId = property(_getEvtType)
def __call__(self, *args):
"""
For backwards compatibility with the old EVT_* functions.
Should be called with either (window, func), (window, ID,
func) or (window, ID1, ID2, func) parameters depending on the
type of the event.
"""
assert len(args) == 2 + self.expectedIDs
id1 = wx.ID_ANY
id2 = wx.ID_ANY
target = args[0]
if self.expectedIDs == 0:
func = args[1]
elif self.expectedIDs == 1:
id1 = args[1]
func = args[2]
elif self.expectedIDs == 2:
id1 = args[1]
id2 = args[2]
func = args[3]
else:
raise ValueError, "Unexpected number of IDs"
self.Bind(target, id1, id2, func)
# These two are square pegs that don't fit the PyEventBinder hole...
def EVT_COMMAND(win, id, cmd, func):
win.Connect(id, -1, cmd, func)
def EVT_COMMAND_RANGE(win, id1, id2, cmd, func):
win.Connect(id1, id2, cmd, func)
#---------------------------------------------------------------------------
|