(self, tk_instance, *geometry, fp="background.png", animation_speed=50)
| 13 | __stop = False |
| 14 | |
| 15 | def __init__(self, tk_instance, *geometry, fp="background.png", animation_speed=50): |
| 16 | # Verifica se o parâmetro tk_instance é uma instância de Tk |
| 17 | if not isinstance(tk_instance, Tk): |
| 18 | raise TypeError("The tk_instance argument must be an instance of Tk.") |
| 19 | |
| 20 | # Recebe o caminho de imagem e a velocidade da animação |
| 21 | self.image_path = fp |
| 22 | self.animation_speed = animation_speed |
| 23 | |
| 24 | # Recebe a largura e altura do widget |
| 25 | self.__width = geometry[0] |
| 26 | self.__height = geometry[1] |
| 27 | |
| 28 | # Inicializa o construtor da classe Canvas |
| 29 | Canvas.__init__( |
| 30 | self, master=tk_instance, width=self.__width, height=self.__height |
| 31 | ) |
| 32 | |
| 33 | # Carrega a imagem que será usada no plano de fundo |
| 34 | self.__bg_image = self.getPhotoImage( |
| 35 | image_path=self.image_path, |
| 36 | width=self.__width, |
| 37 | height=self.__height, |
| 38 | closeAfter=True, |
| 39 | )[0] |
| 40 | |
| 41 | # Cria uma imagem que será fixa, ou seja, que não fará parte da animação e serve em situações de bugs na animação |
| 42 | self.__background_default = self.create_image( |
| 43 | self.__width // 2, self.__height // 2, image=self.__bg_image |
| 44 | ) |
| 45 | |
| 46 | # Cria as imagens que serão utilizadas na animação do background |
| 47 | self.__background.append( |
| 48 | self.create_image( |
| 49 | self.__width // 2, self.__height // 2, image=self.__bg_image |
| 50 | ) |
| 51 | ) |
| 52 | self.__background.append( |
| 53 | self.create_image( |
| 54 | self.__width + (self.__width // 2), |
| 55 | self.__height // 2, |
| 56 | image=self.__bg_image, |
| 57 | ) |
| 58 | ) |
| 59 | |
| 60 | def getBackgroundID(self): |
| 61 | """ |
nothing calls this directly
no test coverage detected