0

I have a class that gather and calculate data and returns a list of stats to DataCollected. Is there any ways I can collect stat_list in DataCollected without having to run the calculation class again and put the stat_list into my other class that are frames. I know global is an option but I heard using global is not a good practice

class DataCollected():

    def collect_data(self, name):

        Key = '-------------------------'
        num_game = 20
        ids = Id_Collect()
        game = Game()
        wins = Win_Calc()

        accId = ids.id_collected(name, Key)

        if accId != 'NO':
            game_list = game.find_game_ids(accId, Key, name, num_game)
            stat_list = game.game_data(game_list, Key, num_game)
            
            return 1
        else: 
            return 2

KillPage is a class for one of my frames. I want to be able to get stat_list[0] and put that into a label.Then repeat that for my other class frames.

class KillPage(tk.Frame):
    
    def __init__(self, parent, controller):
        
        tk.Frame.__init__(self, parent)
        self.controller = controller
        label = tk.Label(self, text=stat_list[0], font=controller.title_font)
        label.pack(side="top", fill="x", pady=10)
        button = tk.Button(self, text="Back", width = 20, bg = 'brown', fg = 'white',
                           command=lambda: controller.show_frame("MenuPage")).place(x=180,y=300)

0 Answers0