app/search_page.py
def display_fighter_stats(self):
        """Fill entries & change photo based on selected fighter."""

        ######### check if any fighter has been selected
        selected_option = self.fighters_list.curselection()
        if not selected_option:
            messagebox.showerror(
                title='Display',
                message='You have to choose a fighter in order to do that!'
            )
            return

        ######### get fighter name from db
        person = self.fighters_list.get(selected_option)
        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

        ######### grab his stats
        data = DatabaseManager(
            ).return_fighter_info(fighter_name=person_in_base)


        ######### PHOTO & FLAG
        self.fighter_photo.configure(
            file=f'app/static/fighters_photos/{person_in_base}(photo).png'
        )
        self.fighter_flag.configure(
            file=f'app/static/fighters_photos/{person_in_base}(flag).png'
        )

        ######### INFO & STAT ENTRIES
        entries_name_list = [
            *constants.INFO_ENTRY_NAMES,
            *constants.STAT_ENTRY_NAMES,
            'f_draws',
        ]
        entry_abbreviations = iter(constants.ENTRY_ABBREVIATIONS)
        for index, entry_name in enumerate(entries_name_list):
            entry = getattr(self, entry_name)
            entry.configure(state='normal')
            entry.delete(0, END)
            entry.insert(0, f"{data[index]}{next(entry_abbreviations)}")

        ######### BARS
        index = 15
        for bar_name in constants.BAR_NAMES:
            bar = getattr(self, bar_name)
            bar.configure(value=data[index])
            index += 2

        ######### UPCOMING FIGHTS
        self.upcoming_fights.configure(state='normal')
        self.upcoming_fights.delete(0.0, 'end-1c')

        if data[-5] == '<<  No fight signed up at the moment  >>':
            self.upcoming_fights.insert(INSERT, data[-5])
        else:
            self.upcoming_fights.insert(
                INSERT, f"{10*'*'}    {data[-5]}    {10*'*'}\n\n")
            self.upcoming_fights.insert(
                INSERT, f"-->    {data[-4]}\n")
            self.upcoming_fights.insert(
                INSERT, f"-->    {data[-3]}\n\nFIGTERS:\n")
            self.upcoming_fights.insert(
                INSERT, f"\t{data[-2].split('VS')[0].strip()}      VS\n")
            self.upcoming_fights.insert(
                INSERT, f"\t{data[-2].split('VS')[1].strip()}")

        self.upcoming_fights.configure(state='disabled')

        ######### CAREER HISTORY
        fight_list = DatabaseManager(
            ).return_fighter_career_history(fighter_name=person_in_base)

        self.career_history.delete(0, END)
        for index, fight in enumerate(fight_list):
            result = fight[1]
            opponent = fight[2]
            event = fight[3].split('-')[0].strip()
            date = fight[4].replace(' / ', '-')
            how = fight[5].replace(' (', '-').replace(')', '')
            round_time = f"ROUND {fight[6]}({fight[7]})"
            row = \
                f"{index + 1}. {result}  VS  {opponent}, " \
                f"{event}({date}), {how},  {round_time}"
            self.career_history.insert(index, row)

            if result == 'WIN':
                row_color = 'green'
            elif result == 'LOSS':
                row_color = 'red'
            elif result == 'DRAW' or result == 'NC':
                row_color = 'orange'

            self.career_history.itemconfigure(index=index, bg=row_color)
Fill entries & change photo based on selected fighter.
Fill entries & change photo based on selected fighter.
Fill entries & change photo based on selected fighter .
def display_fighter_stats(self):
        selected_option = self.fighters_list.curselection()
        if not selected_option:
            messagebox.showerror(
                title='Display',
                message='You have to choose a fighter in order to do that!'
            )
            return
        person = self.fighters_list.get(selected_option)
        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
        data = DatabaseManager(
            ).return_fighter_info(fighter_name=person_in_base)
        self.fighter_photo.configure(
            file=f'app/static/fighters_photos/{person_in_base}(photo).png'
        )
        self.fighter_flag.configure(
            file=f'app/static/fighters_photos/{person_in_base}(flag).png'
        )
        entries_name_list = [
            *constants.INFO_ENTRY_NAMES,
            *constants.STAT_ENTRY_NAMES,
            'f_draws',
        ]
        entry_abbreviations = iter(constants.ENTRY_ABBREVIATIONS)
        for index, entry_name in enumerate(entries_name_list):
            entry = getattr(self, entry_name)
            entry.configure(state='normal')
            entry.delete(0, END)
            entry.insert(0, f"{data[index]}{next(entry_abbreviations)}")
        index = 15
        for bar_name in constants.BAR_NAMES:
            bar = getattr(self, bar_name)
            bar.configure(value=data[index])
            index += 2
        self.upcoming_fights.configure(state='normal')
        self.upcoming_fights.delete(0.0, 'end-1c')
        if data[-5] == '<<  No fight signed up at the moment  >>':
            self.upcoming_fights.insert(INSERT, data[-5])
        else:
            self.upcoming_fights.insert(
                INSERT, f"{10*'*'}    {data[-5]}    {10*'*'}\n\n")
            self.upcoming_fights.insert(
                INSERT, f"-->    {data[-4]}\n")
            self.upcoming_fights.insert(
                INSERT, f"-->    {data[-3]}\n\nFIGTERS:\n")
            self.upcoming_fights.insert(
                INSERT, f"\t{data[-2].split('VS')[0].strip()}      VS\n")
            self.upcoming_fights.insert(
                INSERT, f"\t{data[-2].split('VS')[1].strip()}")
        self.upcoming_fights.configure(state='disabled')
        fight_list = DatabaseManager(
            ).return_fighter_career_history(fighter_name=person_in_base)
        self.career_history.delete(0, END)
        for index, fight in enumerate(fight_list):
            result = fight[1]
            opponent = fight[2]
            event = fight[3].split('-')[0].strip()
            date = fight[4].replace(' / ', '-')
            how = fight[5].replace(' (', '-').replace(')', '')
            round_time = f"ROUND {fight[6]}({fight[7]})"
            row = \
                f"{index + 1}. {result}  VS  {opponent}, " \
                f"{event}({date}), {how},  {round_time}"
            self.career_history.insert(index, row)
            if result == 'WIN':
                row_color = 'green'
            elif result == 'LOSS':
                row_color = 'red'
            elif result == 'DRAW' or result == 'NC':
                row_color = 'orange'
            self.career_history.itemconfigure(index=index, bg=row_color)
def display_fighter_stats ( self ) : selected_option = self . fighters_list . curselection ( ) if not selected_option : messagebox . showerror ( title = 'Display' , message = 'You have to choose a fighter in order to do that!' ) return person = self . fighters_list . get ( selected_option ) 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 data = DatabaseManager ( ) . return_fighter_info ( fighter_name = person_in_base ) self . fighter_photo . configure ( file = f'app/static/fighters_photos/{person_in_base}(photo).png' ) self . fighter_flag . configure ( file = f'app/static/fighters_photos/{person_in_base}(flag).png' ) entries_name_list = [ * constants . INFO_ENTRY_NAMES , * constants . STAT_ENTRY_NAMES , 'f_draws' , ] entry_abbreviations = iter ( constants . ENTRY_ABBREVIATIONS ) for index , entry_name in enumerate ( entries_name_list ) : entry = getattr ( self , entry_name ) entry . configure ( state = 'normal' ) entry . delete ( 0 , END ) entry . insert ( 0 , f"{data[index]}{next(entry_abbreviations)}" ) index = 15 for bar_name in constants . BAR_NAMES : bar = getattr ( self , bar_name ) bar . configure ( value = data [ index ] ) index += 2 self . upcoming_fights . configure ( state = 'normal' ) self . upcoming_fights . delete ( 0.0 , 'end-1c' ) if data [ - 5 ] == '<<  No fight signed up at the moment  >>' : self . upcoming_fights . insert ( INSERT , data [ - 5 ] ) else : self . upcoming_fights . insert ( INSERT , f"{10*'*'}    {data[-5]}    {10*'*'}\n\n" ) self . upcoming_fights . insert ( INSERT , f"-->    {data[-4]}\n" ) self . upcoming_fights . insert ( INSERT , f"-->    {data[-3]}\n\nFIGTERS:\n" ) self . upcoming_fights . insert ( INSERT , f"\t{data[-2].split('VS')[0].strip()}      VS\n" ) self . upcoming_fights . insert ( INSERT , f"\t{data[-2].split('VS')[1].strip()}" ) self . upcoming_fights . configure ( state = 'disabled' ) fight_list = DatabaseManager ( ) . return_fighter_career_history ( fighter_name = person_in_base ) self . career_history . delete ( 0 , END ) for index , fight in enumerate ( fight_list ) : result = fight [ 1 ] opponent = fight [ 2 ] event = fight [ 3 ] . split ( '-' ) [ 0 ] . strip ( ) date = fight [ 4 ] . replace ( ' / ' , '-' ) how = fight [ 5 ] . replace ( ' (' , '-' ) . replace ( ')' , '' ) round_time = f"ROUND {fight[6]}({fight[7]})" row = f"{index + 1}. {result}  VS  {opponent}, " f"{event}({date}), {how},  {round_time}" self . career_history . insert ( index , row ) if result == 'WIN' : row_color = 'green' elif result == 'LOSS' : row_color = 'red' elif result == 'DRAW' or result == 'NC' : row_color = 'orange' self . career_history . itemconfigure ( index = index , bg = row_color )
Fill entries & change photo based on selected fighter.
Fill entries & change photo based on selected fighter .
"""Fill entries & change photo based on selected fighter.""" ######### check if any fighter has been selected ######### get fighter name from db ######### grab his stats ######### PHOTO & FLAG ######### INFO & STAT ENTRIES ######### BARS ######### UPCOMING FIGHTS ######### CAREER HISTORY
self