app/compare_page.py
def display_fighter(self, which):
        """Based on passed argument, fill entries with
        proper values & changes photos for first or second fighter."""

    ##########  CONTROL  ##########
        display = False
        selected_fighter = self.fighters_list.curselection()

        fighter_name_from_entry = self.first_fighter_choose_entry.get() \
            if which == 'first' else self.second_fighter_choose_entry.get()
        fighter_name_from_entry = fighter_name_from_entry.upper()

        ### NO SELECT  &  NO WRITE
        if not selected_fighter and not fighter_name_from_entry:
            messagebox.showerror(
                title='Error!',
                message="Choose fighter from database or write his name!!!"
            )

        ### NO SELECT  &  WRITE <= 3
        elif not selected_fighter and len(fighter_name_from_entry) <= 3:
            messagebox.showerror(
                title="Error!",
                message="Can't match any fighter with a few letters!!!"
            )

        ### NO SELECT  &  WRITE > 3
        elif not selected_fighter and fighter_name_from_entry:
            error = True
            for fighter_name_from_list in self.fighters_list.get(0, END):
                if fighter_name_from_entry in fighter_name_from_list:
                    person = fighter_name_from_list
                    error = False
                    display = True
                    break
            if error:
                messagebox.showerror(
                    title='Error!',
                    message="Fighter has not been found in our database!\n"
                            "Maybe You've done some misspelling?"
                )

        ### SELECT
        elif selected_fighter:
            person = self.fighters_list.get(selected_fighter)
            display = True

        ### FINAL CONTROL
        if not display:
            return


    ##########  CONTROL PASSED, LET'S START WITH DISPLAYING  ##########
        ### RIGHT BOX ENTRY
        if which == 'first':
            self.first_fighter_choose_entry.delete(0, END)
            self.first_fighter_choose_entry.insert(
                0, person.split(maxsplit=1)[1])
        elif which == 'second':
            self.second_fighter_choose_entry.delete(0, END)
            self.second_fighter_choose_entry.insert(
                0, person.split(maxsplit=1)[1])


        ### GRAB FIGHTER INFOS
        person_in_base = f"{person.split()[1]} {person.split()[2]}"
        for fighter in DatabaseManager().return_fighter_names():
            if person_in_base in fighter[0]:
                person_in_base = fighter[0]
                break

        fighter_stats = DatabaseManager().return_fighter_stats_for_comparing(
            fighter_name=person_in_base
        )


        ### PHOTO, FLAG, TITLE
        if which == 'first':
            self.first_photo.configure(
                file=f'app/static/fighters_photos/{person_in_base}(photo).png')
            self.first_flag.configure(
                file=f'app/static/fighters_photos/{person_in_base}(flag).png')

            self.first_name.delete(0, END)
            self.first_name.insert(
                index=0, string=utilities.center_value(
                    obj=fighter_stats[0], stat_or_name='name')
            )
        elif which == 'second':
            self.second_photo.configure(
                file=f'app/static/fighters_photos/{person_in_base}(photo).png')
            self.second_flag.configure(
                file=f'app/static/fighters_photos/{person_in_base}(flag).png')

            self.second_name.delete(0, END)
            self.second_name.insert(
                index=0, string=utilities.center_value(
                    obj=fighter_stats[0], stat_or_name='name'))


        ### ENTRIES
        entry_list = constants.FIRST_FIGHTER_ENTRY_NAMES_FOR_DISPLAYING if \
            which == 'first' else constants.SECOND_FIGHTER_ENTRY_NAMES_FOR_DISPLAYING

        entry_abbreviations = iter(constants.ENTRY_ABBREVIATIONS)
        fighter_stats = list(fighter_stats)
        fighter_stats[3] = f"{fighter_stats[3]}KG / {fighter_stats[4]}CM"
        del fighter_stats[4]

        for index, entry_name in enumerate(entry_list):
            index += 1
            entry = getattr(self, entry_name)
            entry.delete(0, END)

            entry.insert(
                    0, utilities.center_value(
                        obj=str(fighter_stats[index]) + next(entry_abbreviations),
                        stat_or_name='stat' if index > 7 else None,
                    )
                )

        ### BARS
        fighter_bar_list = [*constants.BAR_LIST[6:12], *constants.BAR_LIST[:6]] \
            if which == 'first' else constants.BAR_LIST[12:]
        index = 9
        for control, bar_name in enumerate(fighter_bar_list):
            if control != 0 and control % 2 == 0:
                index += 2
            getattr(self, bar_name).configure(value=fighter_stats[index])
Based on passed argument, fill entries with
        proper values & changes photos for first or second fighter.
Based on passed argument, fill entries with
proper values & changes photos for first or second fighter.
Based on passed argument fill entries with proper values & changes photos for first or second fighter .
def display_fighter(self, which):
        display = False
        selected_fighter = self.fighters_list.curselection()
        fighter_name_from_entry = self.first_fighter_choose_entry.get() \
            if which == 'first' else self.second_fighter_choose_entry.get()
        fighter_name_from_entry = fighter_name_from_entry.upper()
        if not selected_fighter and not fighter_name_from_entry:
            messagebox.showerror(
                title='Error!',
                message="Choose fighter from database or write his name!!!"
            )
        elif not selected_fighter and len(fighter_name_from_entry) <= 3:
            messagebox.showerror(
                title="Error!",
                message="Can't match any fighter with a few letters!!!"
            )
        elif not selected_fighter and fighter_name_from_entry:
            error = True
            for fighter_name_from_list in self.fighters_list.get(0, END):
                if fighter_name_from_entry in fighter_name_from_list:
                    person = fighter_name_from_list
                    error = False
                    display = True
                    break
            if error:
                messagebox.showerror(
                    title='Error!',
                    message="Fighter has not been found in our database!\n"
                            "Maybe You've done some misspelling?"
                )
        elif selected_fighter:
            person = self.fighters_list.get(selected_fighter)
            display = True
        if not display:
            return
        if which == 'first':
            self.first_fighter_choose_entry.delete(0, END)
            self.first_fighter_choose_entry.insert(
                0, person.split(maxsplit=1)[1])
        elif which == 'second':
            self.second_fighter_choose_entry.delete(0, END)
            self.second_fighter_choose_entry.insert(
                0, person.split(maxsplit=1)[1])
        person_in_base = f"{person.split()[1]} {person.split()[2]}"
        for fighter in DatabaseManager().return_fighter_names():
            if person_in_base in fighter[0]:
                person_in_base = fighter[0]
                break
        fighter_stats = DatabaseManager().return_fighter_stats_for_comparing(
            fighter_name=person_in_base
        )
        if which == 'first':
            self.first_photo.configure(
                file=f'app/static/fighters_photos/{person_in_base}(photo).png')
            self.first_flag.configure(
                file=f'app/static/fighters_photos/{person_in_base}(flag).png')
            self.first_name.delete(0, END)
            self.first_name.insert(
                index=0, string=utilities.center_value(
                    obj=fighter_stats[0], stat_or_name='name')
            )
        elif which == 'second':
            self.second_photo.configure(
                file=f'app/static/fighters_photos/{person_in_base}(photo).png')
            self.second_flag.configure(
                file=f'app/static/fighters_photos/{person_in_base}(flag).png')
            self.second_name.delete(0, END)
            self.second_name.insert(
                index=0, string=utilities.center_value(
                    obj=fighter_stats[0], stat_or_name='name'))
        entry_list = constants.FIRST_FIGHTER_ENTRY_NAMES_FOR_DISPLAYING if \
            which == 'first' else constants.SECOND_FIGHTER_ENTRY_NAMES_FOR_DISPLAYING
        entry_abbreviations = iter(constants.ENTRY_ABBREVIATIONS)
        fighter_stats = list(fighter_stats)
        fighter_stats[3] = f"{fighter_stats[3]}KG / {fighter_stats[4]}CM"
        del fighter_stats[4]
        for index, entry_name in enumerate(entry_list):
            index += 1
            entry = getattr(self, entry_name)
            entry.delete(0, END)
            entry.insert(
                    0, utilities.center_value(
                        obj=str(fighter_stats[index]) + next(entry_abbreviations),
                        stat_or_name='stat' if index > 7 else None,
                    )
                )
        fighter_bar_list = [*constants.BAR_LIST[6:12], *constants.BAR_LIST[:6]] \
            if which == 'first' else constants.BAR_LIST[12:]
        index = 9
        for control, bar_name in enumerate(fighter_bar_list):
            if control != 0 and control % 2 == 0:
                index += 2
            getattr(self, bar_name).configure(value=fighter_stats[index])
def display_fighter ( self , which ) : display = False selected_fighter = self . fighters_list . curselection ( ) fighter_name_from_entry = self . first_fighter_choose_entry . get ( ) if which == 'first' else self . second_fighter_choose_entry . get ( ) fighter_name_from_entry = fighter_name_from_entry . upper ( ) if not selected_fighter and not fighter_name_from_entry : messagebox . showerror ( title = 'Error!' , message = "Choose fighter from database or write his name!!!" ) elif not selected_fighter and len ( fighter_name_from_entry ) <= 3 : messagebox . showerror ( title = "Error!" , message = "Can't match any fighter with a few letters!!!" ) elif not selected_fighter and fighter_name_from_entry : error = True for fighter_name_from_list in self . fighters_list . get ( 0 , END ) : if fighter_name_from_entry in fighter_name_from_list : person = fighter_name_from_list error = False display = True break if error : messagebox . showerror ( title = 'Error!' , message = "Fighter has not been found in our database!\n" "Maybe You've done some misspelling?" ) elif selected_fighter : person = self . fighters_list . get ( selected_fighter ) display = True if not display : return if which == 'first' : self . first_fighter_choose_entry . delete ( 0 , END ) self . first_fighter_choose_entry . insert ( 0 , person . split ( maxsplit = 1 ) [ 1 ] ) elif which == 'second' : self . second_fighter_choose_entry . delete ( 0 , END ) self . second_fighter_choose_entry . insert ( 0 , person . split ( maxsplit = 1 ) [ 1 ] ) person_in_base = f"{person.split()[1]} {person.split()[2]}" for fighter in DatabaseManager ( ) . return_fighter_names ( ) : if person_in_base in fighter [ 0 ] : person_in_base = fighter [ 0 ] break fighter_stats = DatabaseManager ( ) . return_fighter_stats_for_comparing ( fighter_name = person_in_base ) if which == 'first' : self . first_photo . configure ( file = f'app/static/fighters_photos/{person_in_base}(photo).png' ) self . first_flag . configure ( file = f'app/static/fighters_photos/{person_in_base}(flag).png' ) self . first_name . delete ( 0 , END ) self . first_name . insert ( index = 0 , string = utilities . center_value ( obj = fighter_stats [ 0 ] , stat_or_name = 'name' ) ) elif which == 'second' : self . second_photo . configure ( file = f'app/static/fighters_photos/{person_in_base}(photo).png' ) self . second_flag . configure ( file = f'app/static/fighters_photos/{person_in_base}(flag).png' ) self . second_name . delete ( 0 , END ) self . second_name . insert ( index = 0 , string = utilities . center_value ( obj = fighter_stats [ 0 ] , stat_or_name = 'name' ) ) entry_list = constants . FIRST_FIGHTER_ENTRY_NAMES_FOR_DISPLAYING if which == 'first' else constants . SECOND_FIGHTER_ENTRY_NAMES_FOR_DISPLAYING entry_abbreviations = iter ( constants . ENTRY_ABBREVIATIONS ) fighter_stats = list ( fighter_stats ) fighter_stats [ 3 ] = f"{fighter_stats[3]}KG / {fighter_stats[4]}CM" del fighter_stats [ 4 ] for index , entry_name in enumerate ( entry_list ) : index += 1 entry = getattr ( self , entry_name ) entry . delete ( 0 , END ) entry . insert ( 0 , utilities . center_value ( obj = str ( fighter_stats [ index ] ) + next ( entry_abbreviations ) , stat_or_name = 'stat' if index > 7 else None , ) ) fighter_bar_list = [ * constants . BAR_LIST [ 6 : 12 ] , * constants . BAR_LIST [ : 6 ] ] if which == 'first' else constants . BAR_LIST [ 12 : ] index = 9 for control , bar_name in enumerate ( fighter_bar_list ) : if control != 0 and control % 2 == 0 : index += 2 getattr ( self , bar_name ) . configure ( value = fighter_stats [ index ] )
Based on passed argument, fill entries with
proper values & changes photos for first or second fighter.
Based on passed argument fill entries with proper values & changes photos for first or second fighter .
"""Based on passed argument, fill entries with
        proper values & changes photos for first or second fighter.""" ##########  CONTROL  ########## ### NO SELECT  &  NO WRITE ### NO SELECT  &  WRITE <= 3 ### NO SELECT  &  WRITE > 3 ### SELECT ### FINAL CONTROL ##########  CONTROL PASSED, LET'S START WITH DISPLAYING  ########## ### RIGHT BOX ENTRY ### GRAB FIGHTER INFOS ### PHOTO, FLAG, TITLE ### ENTRIES ### BARS
self
which