Modified to allow transparent widget proxies.

This commit is contained in:
Tyler Conrad 2012-12-10 13:55:11 -06:00
parent 7af2c89d68
commit d143f2bad6
21 changed files with 48 additions and 1 deletions

17
.project Normal file
View File

@ -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>

8
.pydevproject Normal file
View File

@ -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>

0
doc/sources/.static/kivy-logo-black-64.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

0
kivy/core/window/__init__.py Executable file → Normal file
View File

0
kivy/data/logo/kivy-icon-128.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

0
kivy/data/logo/kivy-icon-16.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

0
kivy/data/logo/kivy-icon-24.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

0
kivy/data/logo/kivy-icon-256.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

0
kivy/data/logo/kivy-icon-32.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

0
kivy/data/logo/kivy-icon-512.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 78 KiB

0
kivy/data/logo/kivy-icon-64.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

0
kivy/tools/packaging/osx/kivy.sh Executable file → Normal file
View File

0
kivy/tools/pep8checker/pre-commit.githook Executable file → Normal file
View File

0
kivy/tools/theming/defaulttheme/audio-volume-high.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 936 B

After

Width:  |  Height:  |  Size: 936 B

0
kivy/tools/theming/defaulttheme/audio-volume-low.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 753 B

After

Width:  |  Height:  |  Size: 753 B

View File

Before

Width:  |  Height:  |  Size: 831 B

After

Width:  |  Height:  |  Size: 831 B

0
kivy/tools/theming/defaulttheme/audio-volume-muted.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 856 B

After

Width:  |  Height:  |  Size: 856 B

View File

Before

Width:  |  Height:  |  Size: 292 B

After

Width:  |  Height:  |  Size: 292 B

View File

Before

Width:  |  Height:  |  Size: 478 B

After

Width:  |  Height:  |  Size: 478 B

View File

Before

Width:  |  Height:  |  Size: 292 B

After

Width:  |  Height:  |  Size: 292 B

View File

@ -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)