widget: fix widget insertion with or without canvas.before. closes #1021.

This commit is contained in:
Mathieu Virbel 2013-03-22 15:06:33 -05:00
parent 3936836ef7
commit e95717c650
3 changed files with 22 additions and 2 deletions

View File

@ -33,7 +33,7 @@ cdef class Instruction:
cdef void rremove(self, InstructionGroup ig)
cdef class InstructionGroup(Instruction):
cdef list children
cdef public list children
cdef InstructionGroup compiled_children
cdef GraphicsCompiler compiler
cdef void build(self)

View File

@ -595,6 +595,23 @@ cdef class Canvas(CanvasBase):
self._after = c
return self._after
property has_before:
'''Property to see if the canvas.before is already created
.. versionadded:: 1.6.1
'''
def __get__(self):
return self._before is not None
property has_after:
'''Property to see if the canvas.after is already created
.. versionadded:: 1.6.1
'''
def __get__(self):
return self._after is not None
property opacity:
'''Property for get/set the opacity value of the canvas.

View File

@ -280,7 +280,7 @@ class Widget(EventDispatcher):
children = self.children
if index >= len(children):
index = len(children)
next_index = -1
next_index = 0
else:
next_child = children[index]
next_index = canvas.indexof(next_child.canvas)
@ -290,6 +290,9 @@ class Widget(EventDispatcher):
next_index += 1
children.insert(index, widget)
# we never want to insert widget _before_ canvas.before.
if next_index == 0:
next_index = 1
canvas.insert(next_index, widget.canvas)
def remove_widget(self, widget):