Home | Trees | Indices | Help |
|
---|
|
object --+ | EventHandlingBase
This class is used as a base by all classes implementing event handlers.
Look at known subclasses (above in epydoc) to see which classes will allow you to attach your own callables (event handlers) to certain events occuring in them.
Read the respective classes documentations to learn what events are
provided by them. The events are always defined in a class whose name
consist of the name of the class it provides events for followed by
Events
). For example class ISkype provides
events defined in ISkypeEvents. The events class is always defined in the
same submodule as the main class.
The events class is just informative. It tells you what events you can assign your event handlers to, when do they occur and what arguments lists should your event handlers accept.
There are three ways of attaching an event handler to an event.
Events
object.
Use this method if you need to attach many event handlers to many events.
Write your event handlers as methods of a class. The superclass of your class doesn't matter, Skype4Py will just look for methods with apropriate names. The names of the methods and their arguments lists can be found in respective events classes (see above).
Pass an instance of this class as the Events
argument
to the constructor of a class whose events you are interested in. For
example:
import Skype4Py class MySkypeEvents: def UserStatus(self, Status): print 'The status of the user changed' skype = Skype4Py.Skype(Events=MySkypeEvents())
The UserStatus
method will be called when the status
of the user currently logged into skype is changed.
On...
properties.
This method lets you use any callables as event handlers. Simply
assign them to On...
properties (where
"...
" is the name of the event) of the object
whose events you are interested in. For example:
import Skype4Py def user_status(Status): print 'The status of the user changed' skype = Skype4Py.Skype() skype.OnUserStatus = user_status
The user_status
function will be called when the
status of the user currently logged into skype is changed.
The names of the events and their arguments lists should be taken
from respective events classes (see above). Note that there is no
self
argument (which can be seen in the events classes)
simply because our event handler is a function, not a method.
RegisterEventHandler
/
UnregisterEventHandler
methods.
This method, like the second one, also let you use any callables as event handlers. However, it additionally let you assign many event handlers to a single event.
In this case, you use RegisterEventHandler and UnregisterEventHandler methods of the object whose events you are interested in. For example:
import Skype4Py def user_status(Status): print 'The status of the user changed' skype = Skype4Py.Skype() skype.RegisterEventHandler('UserStatus', user_status)
The user_status
function will be called when the
status of the user currently logged into skype is changed.
The names of the events and their arguments lists should be taken
from respective events classes (see above). Note that there is no
self
argument (which can be seen in the events classes)
simply because our event handler is a function, not a method.
Important notes!
The event handlers are always called on a separate thread. At any given time, there is at most one handling thread per event type. This means that when a lot of events of the same type are generated at once, handling of an event will start only after the previous one is handled. Handling of events of different types may happen simultaneously.
In case of second and third method, only weak references to the event handlers are stored. This means that you must make sure that Skype4Py is not the only one having a reference to the callable or else it will be garbage collected and silently removed from Skype4Py's handlers list. On the other hand, it frees you from worrying about cyclic references.
Instance Methods | |||
bool |
|
||
bool |
|
||
|
|||
Inherited from |
Properties | |
Inherited from |
Method Details |
Registers any callable as an event handler.
See Also: EventHandlingBase |
Unregisters a previously registered event handler (a callable).
See Also: EventHandlingBase |
Initializes the object.
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Nov 05 14:55:01 2008 | http://epydoc.sourceforge.net |