Modified to allow transparent widget proxies.
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>kivymod</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.python.pydev.PyDevBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.python.pydev.pythonNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?eclipse-pydev version="1.0"?><pydev_project>
|
||||
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
|
||||
<path>/kivymod</path>
|
||||
</pydev_pathproperty>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
|
||||
</pydev_project>
|
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 936 B After Width: | Height: | Size: 936 B |
Before Width: | Height: | Size: 753 B After Width: | Height: | Size: 753 B |
Before Width: | Height: | Size: 831 B After Width: | Height: | Size: 831 B |
Before Width: | Height: | Size: 856 B After Width: | Height: | Size: 856 B |
Before Width: | Height: | Size: 292 B After Width: | Height: | Size: 292 B |
Before Width: | Height: | Size: 478 B After Width: | Height: | Size: 478 B |
Before Width: | Height: | Size: 292 B After Width: | Height: | Size: 292 B |
|
@ -88,6 +88,23 @@ 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.
|
||||
'''
|
||||
|
@ -263,7 +280,10 @@ class Widget(EventDispatcher):
|
|||
'''
|
||||
if widget is self:
|
||||
raise WidgetException('You cannot add yourself in a Widget')
|
||||
if not isinstance(widget, Widget):
|
||||
#Use WidgetLike for isinstance comparisons
|
||||
global WidgetLike
|
||||
# if not isinstance(widget, Widget):
|
||||
if not isinstance(widget, WidgetLike):
|
||||
raise WidgetException(
|
||||
'add_widget() can be used only with Widget classes.')
|
||||
parent = widget.parent
|
||||
|
@ -605,3 +625,5 @@ class Widget(EventDispatcher):
|
|||
|
||||
See :class:`~kivy.graphics.Canvas` for more information about the usage.
|
||||
'''
|
||||
# Register Widget as a 'widget equivalent' type
|
||||
WidgetLike.register(Widget)
|
||||
|
|