本文整理匯總了Python中kivy.event.EventDispatcher類的典型用法代碼示例。如果您正苦於以下問題:Python EventDispatcher類的具體用法?Python EventDispatcher怎麽用?Python EventDispatcher使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了EventDispatcher類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __getattribute__
def __getattribute__(self, key):
# print ">> Trying to get %s" % key
if key in ("_model_attr", "__parent", "_model_class", "_model"):
return object.__getattribute__(self, key)
elif key in self._model_attr:
# print " INTERCEPTED!"
# Get the value of this key from the common data model
val = getattr(self.__parent, key)
# print " val or %s is %s" % (key, val)
# Typecase as needed
if isinstance(val, list):
# Construct a list of property objects
val2 = []
for a in val:
# We have to create a whole new UI model for these...
# class SubModel(UI_DataModel):
# _model_class = type(a)
# val2.append(SubModel(a))
val2.append(str(a))
else:
val2 = str(val)
# Invoke kivy's Property setter by setting our attribute
setattr(self, key, val2)
# Proceed as normal
return EventDispatcher.__getattribute__(self, key)
else:
# print " Pushing up to base class"
return EventDispatcher.__getattribute__(self, key)
示例2: __init__
def __init__(self, anim, widget):
EventDispatcher.__init__(self)
self.anim = anim
self.widget = widget
self.anim.bind(on_start=self._anim_started,
on_progress=self._anim_progress,
on_complete=self._anim_completed)
示例3: __new__
def __new__(cls, **kwargs):
if cls.__instance is None:
cls.__instance = EventDispatcher.__new__(cls)
return cls.__instance
示例4: __init__
def __init__(self, tile, maze, **kwargs):
MazeObject.__init__(self, tile=tile)#inherits from MazeObject
EventDispatcher.__init__(self, **kwargs)
self.orientation = 0 #0,1,2,3 = left,right,up,down
self.maze = maze