Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Member Functions
idlelib.MultiCall._ComplexBinder Class Reference

List of all members.

Public Member Functions

def __init__
def bind
def unbind
def __del__

Public Attributes

 type
 typename
 widget
 widgetinst
 bindedfuncs
 handlerids
 ishandlerrunning
 doafterhandler

Private Member Functions

def __create_handler

Detailed Description

Definition at line 143 of file MultiCall.py.


Constructor & Destructor Documentation

def idlelib.MultiCall._ComplexBinder.__init__ (   self,
  type,
  widget,
  widgetinst 
)

Definition at line 179 of file MultiCall.py.

00179 
00180     def __init__(self, type, widget, widgetinst):
00181         self.type = type
00182         self.typename = _types[type][0]
00183         self.widget = widget
00184         self.widgetinst = widgetinst
00185         self.bindedfuncs = {None: [[] for s in _states]}
00186         self.handlerids = []
00187         # we don't want to change the lists of functions while a handler is
00188         # running - it will mess up the loop and anyway, we usually want the
00189         # change to happen from the next event. So we have a list of functions
00190         # for the handler to run after it finishes calling the binded functions.
00191         # It calls them only once.
00192         # ishandlerrunning is a list. An empty one means no, otherwise - yes.
00193         # this is done so that it would be mutable.
00194         self.ishandlerrunning = []
00195         self.doafterhandler = []
00196         for s in _states:
00197             lists = [self.bindedfuncs[None][i] for i in _state_subsets[s]]
00198             handler = self.__create_handler(lists, type, _state_codes[s])
00199             seq = '<'+_state_names[s]+self.typename+'>'
00200             self.handlerids.append((seq, self.widget.bind(self.widgetinst,
00201                                                           seq, handler)))

Here is the caller graph for this function:

Definition at line 227 of file MultiCall.py.

00227 
00228     def __del__(self):
00229         for seq, id in self.handlerids:
00230             self.widget.unbind(self.widgetinst, seq, id)
00231 
00232 # define the list of event types to be handled by MultiEvent. the order is
# compatible with the definition of event type constants.

Member Function Documentation

def idlelib.MultiCall._ComplexBinder.__create_handler (   self,
  lists,
  mc_type,
  mc_state 
) [private]

Definition at line 151 of file MultiCall.py.

00151 
00152     def __create_handler(self, lists, mc_type, mc_state):
00153         def handler(event, lists = lists,
00154                     mc_type = mc_type, mc_state = mc_state,
00155                     ishandlerrunning = self.ishandlerrunning,
00156                     doafterhandler = self.doafterhandler):
00157             ishandlerrunning[:] = [True]
00158             event.mc_type = mc_type
00159             event.mc_state = mc_state
00160             wascalled = {}
00161             r = None
00162             for l in lists:
00163                 for i in range(len(l)-1, -1, -1):
00164                     func = l[i]
00165                     if func not in wascalled:
00166                         wascalled[func] = True
00167                         r = l[i](event)
00168                         if r:
00169                             break
00170                 if r:
00171                     break
00172             ishandlerrunning[:] = []
00173             # Call all functions in doafterhandler and remove them from list
00174             while doafterhandler:
00175                 doafterhandler.pop()()
00176             if r:
00177                 return r
00178         return handler

Here is the caller graph for this function:

def idlelib.MultiCall._ComplexBinder.bind (   self,
  triplet,
  func 
)

Definition at line 202 of file MultiCall.py.

00202 
00203     def bind(self, triplet, func):
00204         if triplet[2] not in self.bindedfuncs:
00205             self.bindedfuncs[triplet[2]] = [[] for s in _states]
00206             for s in _states:
00207                 lists = [ self.bindedfuncs[detail][i]
00208                           for detail in (triplet[2], None)
00209                           for i in _state_subsets[s]       ]
00210                 handler = self.__create_handler(lists, self.type,
00211                                                 _state_codes[s])
00212                 seq = "<%s%s-%s>"% (_state_names[s], self.typename, triplet[2])
00213                 self.handlerids.append((seq, self.widget.bind(self.widgetinst,
00214                                                               seq, handler)))
00215         doit = lambda: self.bindedfuncs[triplet[2]][triplet[0]].append(func)
00216         if not self.ishandlerrunning:
00217             doit()
00218         else:
00219             self.doafterhandler.append(doit)

Here is the call graph for this function:

Here is the caller graph for this function:

def idlelib.MultiCall._ComplexBinder.unbind (   self,
  triplet,
  func 
)

Definition at line 220 of file MultiCall.py.

00220 
00221     def unbind(self, triplet, func):
00222         doit = lambda: self.bindedfuncs[triplet[2]][triplet[0]].remove(func)
00223         if not self.ishandlerrunning:
00224             doit()
00225         else:
00226             self.doafterhandler.append(doit)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 184 of file MultiCall.py.

Definition at line 194 of file MultiCall.py.

Definition at line 185 of file MultiCall.py.

Definition at line 193 of file MultiCall.py.

Definition at line 180 of file MultiCall.py.

Definition at line 181 of file MultiCall.py.

Definition at line 182 of file MultiCall.py.

Definition at line 183 of file MultiCall.py.


The documentation for this class was generated from the following file: