app/home_page.py
def change_language(self, language):
        """Change Home Page elements language."""

        # Control
        if self.actual_language == language:
            return

        # Set actual language
        self.actual_language = language

        # Set proper data based on choosed language
        tk_obj_values_dict = constants.ENG_TK_OBJ_VALUES_DICT if \
            language == 'eng' else constants.PL_TK_OBJ_VALUES_DICT
        canv_obj_values_dict = constants.ENG_CANV_OBJ_VALUES_DICT if \
            language == 'eng' else constants.PL_CANV_OBJ_VALUES_DICT

        # Translate Tkinter elements
        for obj in tk_obj_values_dict.items():
            obj_name = obj[0]
            obj_trans_text = obj[1][0]
            obj_width_attr = obj[1][1]
            obj_x_coordinate = obj[1][2]
            obj_y_coordinate = obj[1][3]

            getattr(self, obj_name).configure(
                text=obj_trans_text, width=obj_width_attr,
            )
            getattr(self, obj_name).place(
                x=obj_x_coordinate, y=obj_y_coordinate
            )

        # Translate Canvas elements
        for obj in canv_obj_values_dict.items():
            obj_name = obj[0]
            obj_trans_text = obj[1]

            canvas_obj = getattr(self, obj_name)

            self.canvas_background.itemconfigure(
                tagOrId=canvas_obj, text=obj_trans_text,
            )
Change Home Page elements language.
Change Home Page elements language.
Change Home Page elements language .
def change_language(self, language):
        if self.actual_language == language:
            return
        self.actual_language = language
        tk_obj_values_dict = constants.ENG_TK_OBJ_VALUES_DICT if \
            language == 'eng' else constants.PL_TK_OBJ_VALUES_DICT
        canv_obj_values_dict = constants.ENG_CANV_OBJ_VALUES_DICT if \
            language == 'eng' else constants.PL_CANV_OBJ_VALUES_DICT
        for obj in tk_obj_values_dict.items():
            obj_name = obj[0]
            obj_trans_text = obj[1][0]
            obj_width_attr = obj[1][1]
            obj_x_coordinate = obj[1][2]
            obj_y_coordinate = obj[1][3]
            getattr(self, obj_name).configure(
                text=obj_trans_text, width=obj_width_attr,
            )
            getattr(self, obj_name).place(
                x=obj_x_coordinate, y=obj_y_coordinate
            )
        for obj in canv_obj_values_dict.items():
            obj_name = obj[0]
            obj_trans_text = obj[1]
            canvas_obj = getattr(self, obj_name)
            self.canvas_background.itemconfigure(
                tagOrId=canvas_obj, text=obj_trans_text,
            )
def change_language ( self , language ) : if self . actual_language == language : return self . actual_language = language tk_obj_values_dict = constants . ENG_TK_OBJ_VALUES_DICT if language == 'eng' else constants . PL_TK_OBJ_VALUES_DICT canv_obj_values_dict = constants . ENG_CANV_OBJ_VALUES_DICT if language == 'eng' else constants . PL_CANV_OBJ_VALUES_DICT for obj in tk_obj_values_dict . items ( ) : obj_name = obj [ 0 ] obj_trans_text = obj [ 1 ] [ 0 ] obj_width_attr = obj [ 1 ] [ 1 ] obj_x_coordinate = obj [ 1 ] [ 2 ] obj_y_coordinate = obj [ 1 ] [ 3 ] getattr ( self , obj_name ) . configure ( text = obj_trans_text , width = obj_width_attr , ) getattr ( self , obj_name ) . place ( x = obj_x_coordinate , y = obj_y_coordinate ) for obj in canv_obj_values_dict . items ( ) : obj_name = obj [ 0 ] obj_trans_text = obj [ 1 ] canvas_obj = getattr ( self , obj_name ) self . canvas_background . itemconfigure ( tagOrId = canvas_obj , text = obj_trans_text , )
Change Home Page elements language.
Change Home Page elements language .
"""Change Home Page elements language.""" # Control # Set actual language # Set proper data based on choosed language # Translate Tkinter elements # Translate Canvas elements
self
language