widget: throw an exception when the user is trying to add itself to the children. closes #410

This commit is contained in:
Mathieu Virbel 2012-03-19 18:23:24 +01:00
parent ec1b470242
commit f7f47320d8
1 changed files with 2 additions and 0 deletions

View File

@ -222,6 +222,8 @@ class Widget(EventDispatcher):
>>> slider = Slider()
>>> root.add_widget(slider)
'''
if widget is self:
raise WidgetException('You cannot add yourself in a Widget')
if not isinstance(widget, Widget):
raise WidgetException(
'add_widget() can be used only with Widget classes.')