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()
def addText(self, string): self.text = string textBox = TextBlock("doesntMatter", string, self.theFont, 15,60, self.height - 200) self.image.blit(textBox.getImage(), textBox.getRect())