mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-18 20:53:50 -04:00
pass most keyword arguments through to function
This commit is contained in:
parent
b47f037907
commit
2e3f848e85
@ -21,9 +21,19 @@ class FunctionInterval(Interval.Interval):
|
|||||||
notify = directNotify.newCategory('FunctionInterval')
|
notify = directNotify.newCategory('FunctionInterval')
|
||||||
|
|
||||||
# Class methods
|
# Class methods
|
||||||
def __init__(self, function, name = None, openEnded = 1, extraArgs = []):
|
def __init__(self, function, **kw):
|
||||||
"""__init__(function, name = None)
|
"""__init__(function, name = None, openEnded = 1, extraArgs = [])
|
||||||
"""
|
"""
|
||||||
|
name = kw.get('name', None)
|
||||||
|
openEnded = kw.get('openEnded', 1)
|
||||||
|
extraArgs = kw.get('extraArgs', [])
|
||||||
|
if kw.has_key('name'):
|
||||||
|
del kw['name']
|
||||||
|
if kw.has_key('openEnded'):
|
||||||
|
del kw['openEnded']
|
||||||
|
if kw.has_key('extraArgs'):
|
||||||
|
del kw['extraArgs']
|
||||||
|
|
||||||
# Record instance variables
|
# Record instance variables
|
||||||
self.function = function
|
self.function = function
|
||||||
# Create a unique name for the interval if necessary
|
# Create a unique name for the interval if necessary
|
||||||
@ -33,6 +43,7 @@ class FunctionInterval(Interval.Interval):
|
|||||||
assert(isinstance(name, types.StringType))
|
assert(isinstance(name, types.StringType))
|
||||||
# Record any arguments
|
# Record any arguments
|
||||||
self.extraArgs = extraArgs
|
self.extraArgs = extraArgs
|
||||||
|
self.kw = kw
|
||||||
# Initialize superclass
|
# Initialize superclass
|
||||||
# Set openEnded true if privInitialize after end time cause interval
|
# Set openEnded true if privInitialize after end time cause interval
|
||||||
# function to be called. If false, privInitialize calls have no effect
|
# function to be called. If false, privInitialize calls have no effect
|
||||||
@ -42,7 +53,7 @@ class FunctionInterval(Interval.Interval):
|
|||||||
|
|
||||||
def privInstant(self):
|
def privInstant(self):
|
||||||
# Evaluate the function
|
# Evaluate the function
|
||||||
apply(self.function, self.extraArgs)
|
self.function(*self.extraArgs, **self.kw)
|
||||||
# Print debug information
|
# Print debug information
|
||||||
self.notify.debug(
|
self.notify.debug(
|
||||||
'updateFunc() - %s: executing Function' % self.name)
|
'updateFunc() - %s: executing Function' % self.name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user