| Home | Trees | Indices | Help |
|---|
|
|
Functional utilities designed for pychan use cases.
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
This nifty little function takes another function and applies it to a dictionary of keyword arguments. If the supplied function does not expect one or more of the keyword arguments, these are silently discarded. The result of the application is returned. This is useful to pass information to callbacks without enforcing a particular signature. |
Curries a function with extra arguments to create a suitable callback. If you don't know what this means, don't worry. It is designed for the case where you need different buttons to execute basically the same code with different argumnets. Usage:
# The target callback
def printStuff(text):
print text
# Mapping the events
gui.mapEvents({
'buttonHello' : callbackWithArguments(printStuff,"Hello"),
'buttonBye' : callbackWithArguments(printStuff,"Adieu")
})
|
Generates an event callback that sets attributes on the widget it is called on. This is especially useful for mouseEntered/Exited events - to create hover effects. It takes a set of keyword arguments. The keys are treated as attribute names, which are then set to the corresponding value when the callback is called. Some key names are treated special - see below. Usage - Example adapted from demo application:
eventMap = {
'creditsLink' : showCreditsCallback,
'creditsLink/mouseEntered' : attrSetCallback(
text = "Show credits!",
background_color = (255,255,0,255),
do__adaptLayout=True),
'creditsLink/mouseExited' : attrSetCallback(text = "Credits"),
gui.mapEvents(eventMap)
Now when the mouse enters the creditsLink (a Label in our case), the following code will be executed:
#widget is the creditsLink - given to the event callback.
widget.text = "Show credits!"
widget.background_color = (255,255,0,255)
widget.adaptLayout()
The Keys starting with an underscore raise a execptions.PrivateFunctionalityError. |
Chains callbacks to be called one after the other. Example Usage:
def print_event(event=0):
print event
def print_widget(widget=0):
print widget
callback = tools.chainCallbacks(doSomethingUseful, print_event, print_widget)
guiElement.capture(callback)
|
Internal decorator used to profile some pychan functions. Only use with functions without side-effect. Usage:
@repeatALot(n=10000)
def findChild(self,**kwargs):
...
|
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Fri Feb 10 00:00:30 2012 | http://epydoc.sourceforge.net |