def removeElement(self, nameToRemove, t): if t == "textBlock": for i,sprite in enumerate(self.allElements): if sprite.getName() == nameToRemove and isinstance(sprite, Row): sprite.toggleButton("unExpand") break i += 1 sprite = self.allElements.pop(i) #print "THE SPRITE IN QUESTION IS: ", sprite for counter in range(i, len(self.allElements)): self.allElements[counter].updateY(-(sprite.get_height() + self.CURSOR_BORDER_INCREMENT)) self.redrawAll()
def addTextBlock(self, name, data): ## name is the name of recipe this textBlock refers to # should be able to find that name within the list of allElements # first we find the row that has the name of the recipe data we are adding for i,sprite in enumerate(self.allElements): if sprite.getName() == name: sprite.toggleButton( "expand") i += 1 break # add the recipe data textBlock right after that row,@ sprite.rect. bottom newTextBlock = TextBlock(name, data, self.theFont, sprite.getRect().bottom + self.CURSOR_BORDER_INCREMENT) for counter in range(i,len(self.allElements)): #print self.allElements[counter], " @ ", self.allElements[counter].getRect().top, self.allElements[counter].updateY(newTextBlock.get_height() + self.CURSOR_BORDER_INCREMENT) self.allElements.insert(i, newTextBlock) self.redrawAll()