Revert "Modified to allow transparent widget proxies."

This reverts commit f9ae5655a0.
This commit is contained in:
Tyler Conrad 2012-12-13 16:21:53 -06:00
parent ff9bb377e0
commit 37dd282316
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 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): class WidgetException(Exception):
'''Fired when the widget gets an exception. '''Fired when the widget gets an exception.
''' '''
@ -286,10 +263,7 @@ class Widget(EventDispatcher):
''' '''
if widget is self: if widget is self:
raise WidgetException('You cannot add yourself in a Widget') raise WidgetException('You cannot add yourself in a Widget')
#Use WidgetLike for isinstance comparisons if not isinstance(widget, Widget):
global WidgetLike
# if not isinstance(widget, Widget):
if not isinstance(widget, WidgetLike):
raise WidgetException( raise WidgetException(
'add_widget() can be used only with Widget classes.') 'add_widget() can be used only with Widget classes.')
parent = widget.parent parent = widget.parent
@ -631,5 +605,3 @@ class Widget(EventDispatcher):
See :class:`~kivy.graphics.Canvas` for more information about the usage. See :class:`~kivy.graphics.Canvas` for more information about the usage.
''' '''
# Register Widget as a 'widget equivalent' type
WidgetLike.register(Widget)