Método para iniciar a animação do background
(self)
| 144 | ) |
| 145 | |
| 146 | def run(self): |
| 147 | """ |
| 148 | Método para iniciar a animação do background |
| 149 | """ |
| 150 | |
| 151 | # Enquanto o atributo "stop" for False, a animação continuará em um loop infinito |
| 152 | if not self.__stop: |
| 153 | # Move as imagens de background na posição X |
| 154 | self.move(self.__background[0], -10, 0) |
| 155 | self.move(self.__background[1], -10, 0) |
| 156 | self.tag_lower(self.__background[0]) |
| 157 | self.tag_lower(self.__background[1]) |
| 158 | self.tag_lower(self.__background_default) |
| 159 | |
| 160 | # Se a primeira imagem da lista tiver saído da área do widget, uma nova será criada depois da segunda imagem |
| 161 | if self.bbox(self.__background[0])[2] <= 0: |
| 162 | # Deleta a primeira imagem da lista (imagem que saiu da área do widget) |
| 163 | self.delete(self.__background[0]) |
| 164 | self.__background.remove(self.__background[0]) |
| 165 | |
| 166 | # Cria uma nova imagem a partir da última imagem da animação |
| 167 | width = self.bbox(self.__background[0])[2] + self.__width // 2 |
| 168 | self.__background.append( |
| 169 | self.create_image(width, self.__height // 2, image=self.__bg_image) |
| 170 | ) |
| 171 | |
| 172 | # Executa novamente o método depois de um certo tempo |
| 173 | self.after(self.animation_speed, self.run) |
| 174 | |
| 175 | def stop(self): |
| 176 | """ |