Merge branch 'master' of github.com:kived/kivy

This commit is contained in:
Ryan Pessa 2012-12-13 17:10:25 -06:00
commit cbba1852ea
1 changed files with 1 additions and 29 deletions

View File

@ -88,29 +88,6 @@ from kivy.base import EventLoop
from kivy.lang import Builder
class IClass(object):
'''
Used to register 'widget equivalent' types. Emulates
isinstance(widget, Widget) with isinstance(widget, WidgetLike).
This provides the ability to use transparent widget proxies.
'''
def __init__(self):
self.implementors = set()
def register(self, C):
self.implementors.add(C)
def __instancecheck__(self, x):
return self.__subclasscheck__(type(x))
def __subclasscheck__(self, sub):
return any(c in self.implementors for c in sub.mro())
#Instantiate the IClass registry so we can compare to WidgetLike
WidgetLike = IClass()
class WidgetException(Exception):
'''Fired when the widget gets an exception.
'''
@ -286,10 +263,7 @@ class Widget(EventDispatcher):
'''
if widget is self:
raise WidgetException('You cannot add yourself in a Widget')
#Use WidgetLike for isinstance comparisons
global WidgetLike
# if not isinstance(widget, Widget):
if not isinstance(widget, WidgetLike):
if not isinstance(widget, Widget):
raise WidgetException(
'add_widget() can be used only with Widget classes.')
parent = widget.parent
@ -631,5 +605,3 @@ class Widget(EventDispatcher):
See :class:`~kivy.graphics.Canvas` for more information about the usage.
'''
# Register Widget as a 'widget equivalent' type
WidgetLike.register(Widget)