def fill_column_table(self, id, column_items, item_type, params=DEFAULT_ENTRY_PARAMS, odds=False):
        label_place = self.labels_dict[id]['place']
        grid = label_place.copy()
        grid.add_row(1)
        grid.pady=5

        if(self.entries is not None):
            for entry in self.entries:
                entry.destroy()

        for item in column_items:
            if(item_type == 'double' and not odds):
                item_value = f'{float(item)*100:.0f} %'
            elif(item_type == 'double' and odds):
                item_value = f'{float(item):.2f}'
            else:
                item_value = item

            var = tk.StringVar()
            var.set(item_value)

            state = tk.NORMAL
            entry_widget = insert_entry(self.frames['data'], var, params=params)
            entry_widget.config(state=state)
            # label = insert_label(self, text=item, font=ITEMS_FONT, justify=tk.LEFT)
            place_widget(entry_widget, grid)
            grid.add_row(1)
    def fill_column_table(self, id, column_items):
        label_place = self.labels_dict[id]['place']
        grid = label_place.copy()
        grid.add_row(1)
        grid.pady=5

        for item in column_items:
            label = insert_label(self, text=item, font=ITEMS_FONT, justify=tk.LEFT)
            place_widget(label, grid)
            grid.add_row(1)
    def init_elements(self):
        self.frames = {'data': None,
                       'buttons': None}

        self.frames['buttons'] = Frame_Window(self, None)

        self.prob_button = tk.Button(self.frames['buttons'], text='Probabilities', command=self.init_prob_result)
        self.prob_button.config(state=tk.DISABLED)
        prob_button_grid = Grid_Structure(1, 0, padx=50, pady=30)
        place_widget(self.prob_button, prob_button_grid)

        self.odds_button = tk.Button(self.frames['buttons'], text='Odds', command=self.init_odds_result)
        self.odds_button.config(state=tk.NORMAL)
        odds_button_grid = Grid_Structure(1, 1, padx=50, pady=30)
        place_widget(self.odds_button, odds_button_grid)

        self.init_table()
        self.init_prob_result()
    def init_elements(self):
        # TITLE
        title_label = ttk.Label(self.master, text='Soccer Prediction App', font=TITLE_FONT)
        title_grid = Grid_Structure(row=0, column=0, columnspan=3, pady=1, padx=1)
        place_widget(title_label, title_grid)

        buttons_frame = Frame_Window(self.master, None)
        frame_grid = Grid_Structure(row=title_grid.row+1, column=0, columnspan=3)
        place_widget(buttons_frame, frame_grid)

        # PREDICT BUTTON
        predict_button = ttk.Button(buttons_frame, text='Predict',
                                    command=self.controller.open_predict_view)

        predict_grid = Grid_Structure(row=title_grid.row+1, column=0, padx=20, pady=20)
        place_widget(predict_button, predict_grid)

        # PROBABILITIES BUTTON
        thr_button = ttk.Button(buttons_frame, text='Probabilities',
                                command=self.controller.open_probability_view)
        prob_grid = predict_grid.copy()
        prob_grid.add_column(1)
        place_widget(thr_button, prob_grid)

        # THR ANALYSIS BUTTON
        thr_button = ttk.Button(buttons_frame, text='Thr. Analysis',
                                command=self.controller.open_analysis_view)
        thr_grid = prob_grid.copy()
        thr_grid.add_column(1)
        place_widget(thr_button, thr_grid)

        # TEAMS SCORES
        scores_button = ttk.Button(buttons_frame, text='Teams Strength',
                                   command=self.controller.open_score_view)
        scores_grid = thr_grid.copy()
        scores_grid.add_column(1)
        place_widget(scores_button, scores_grid)
    def init_labels(self):
        """

        Returns:
            labels_dict:  dict { 'title': {'label': widget,
                                           'place': Pack_Structure | Grid_Structure},
                                 'match': {'label': widget,
                                           'place': Pack_Structure | Grid_Structure},
                                 'home_bet': {'label': widget,
                                              'place': Pack_Structure | Grid_Structure},
                                 'away_bet': {'label': widget,
                                              'place': Pack_Structure | Grid_Structure},
                                 'home_pred': {'label': widget,
                                               'place': Pack_Structure | Grid_Structure},
                                 'away_pred': {'label': widget,
                                               'place': Pack_Structure | Grid_Structure},
                                 'home_pred_bet': {'label': widget,
                                                   'place': Pack_Structure | Grid_Structure},
                                 'away_pred_bet': {'label': widget,
                                                   'place': Pack_Structure | Grid_Structure},
                                 'event': {'label': widget,
                                           'place': Pack_Structure | Grid_Structure},
                                 'pred': {'label': widget,
                                          'place': Pack_Structure | Grid_Structure}}

        """
        labels_dict = {}

        title_label = insert_label(self, text='Prediction Results', font=TITLE_FONT)
        title_grid = Grid_Structure(row=0, column=0, columnspan=9, pady=10)
        place_widget(title_label, title_grid)
        labels_dict['title'] = {'label': title_label,
                                'place': title_grid}

        header_grid = Grid_Structure(row=title_grid.row + 1, column=0, padx=15, pady=10)
        match_label = insert_label(self, text='Match', font=HEADER_FONT)
        place_widget(match_label, header_grid)
        labels_dict['match'] = {'label': match_label,
                                'place': header_grid}

        home_bet_grid = header_grid.copy()
        home_bet_grid.add_column(1)
        home_bet_label = insert_label(self, text='1X odd', font=HEADER_FONT)
        place_widget(home_bet_label, home_bet_grid)
        labels_dict['home_bet'] = {'label': home_bet_label,
                                   'place': home_bet_grid}

        away_bet_grid = home_bet_grid.copy()
        away_bet_grid.add_column(1)
        away_bet_label = insert_label(self, text='X2 odd', font=HEADER_FONT)
        place_widget(away_bet_label, away_bet_grid)
        labels_dict['away_bet'] = {'label': away_bet_label,
                                'place': away_bet_grid}

        home_pred_grid = away_bet_grid.copy()
        home_pred_grid.add_column(1)
        home_pred_label = insert_label(self, text='1X prob', font=HEADER_FONT)
        place_widget(home_pred_label, home_pred_grid)
        labels_dict['home_pred'] = {'label': home_pred_label,
                                    'place': home_pred_grid}

        away_pred_grid = home_pred_grid.copy()
        away_pred_grid.add_column(1)
        away_pred_label = insert_label(self, text='X2 prob', font=HEADER_FONT)
        place_widget(away_pred_label, away_pred_grid)
        labels_dict['away_pred'] = {'label': away_pred_label,
                                    'place': away_pred_grid}

        home_pred_bet_grid = away_pred_grid.copy()
        home_pred_bet_grid.add_column(1)
        home_pred_bet_label = insert_label(self, text='Real 1X', font=HEADER_FONT)
        place_widget(home_pred_bet_label, home_pred_bet_grid)
        labels_dict['home_pred_bet'] = {'label': home_pred_bet_label,
                                        'place': home_pred_bet_grid}

        away_pred_bet_grid = home_pred_bet_grid.copy()
        away_pred_bet_grid.add_column(1)
        away_pred_bet_label = insert_label(self, text='Real X2', font=HEADER_FONT)
        place_widget(away_pred_bet_label, away_pred_bet_grid)
        labels_dict['away_pred_bet'] = {'label': away_pred_bet_label,
                                    'place': away_pred_bet_grid}

        event_grid = away_pred_bet_grid.copy()
        event_grid.add_column(1)
        event_label = insert_label(self, text='Event', font=HEADER_FONT)
        place_widget(event_label, event_grid)
        labels_dict['event'] = {'label': event_label,
                                'place': event_grid}

        prob_grid = event_grid.copy()
        prob_grid.add_column(1)
        prob_label = insert_label(self, text='Match Prob.', font=HEADER_FONT)
        place_widget(prob_label, prob_grid)
        labels_dict['prob'] = {'label': prob_label,
                                'place': prob_grid}

        return labels_dict
 def main_window(self):
     for i, frame in enumerate(self.frames.values()):
         place_widget(frame, Grid_Structure(i+20, 0, columnspan=10))
    def init_labels(self):
        """

        Returns:
            labels_dict:  dict { 'title': {'label': widget,
                                           'place': Pack_Structure | Grid_Structure},
                                 'match': {'label': widget,
                                           'place': Pack_Structure | Grid_Structure},
                                 'home': {'label': widget,
                                              'place': Pack_Structure | Grid_Structure},
                                 'draw': {'label': widget,
                                              'place': Pack_Structure | Grid_Structure},
                                 'away': {'label': widget,
                                               'place': Pack_Structure | Grid_Structure},
                                 'under': {'label': widget,
                                               'place': Pack_Structure | Grid_Structure},
                                 'over': {'label': widget,
                                                   'place': Pack_Structure | Grid_Structure},
                                 'goal': {'label': widget,
                                                   'place': Pack_Structure | Grid_Structure},
                                 'noprob': {'label': widget,
                                           'place': Pack_Structure | Grid_Structure}

        """
        if(self.frames['data'] is not None):
            self.frames['data'].destroy()

        self.frames['data'] = Frame_Window(self, None)

        labels_dict = {}

        title_label = insert_label(self.frames['data'], text='Prediction Results', font=TITLE_FONT)
        title_grid = Grid_Structure(row=0, column=0, columnspan=9, pady=10)
        place_widget(title_label, title_grid)
        labels_dict['title'] = {'label': title_label,
                                'place': title_grid}

        header_grid = Grid_Structure(row=title_grid.row + 1, column=0, padx=15, pady=10)
        match_label = insert_label(self.frames['data'], text='Match', font=HEADER_FONT)
        place_widget(match_label, header_grid)
        labels_dict['match'] = {'label': match_label,
                                'place': header_grid}

        home_prob_grid = header_grid.copy()
        home_prob_grid.add_column(1)
        home_prob_label = insert_label(self.frames['data'], text='1', font=HEADER_FONT)
        place_widget(home_prob_label, home_prob_grid)
        labels_dict['home'] = {'label': home_prob_label,
                                   'place': home_prob_grid}

        draw_prob_grid = home_prob_grid.copy()
        draw_prob_grid.add_column(1)
        draw_prob_label = insert_label(self.frames['data'], text='X', font=HEADER_FONT)
        place_widget(draw_prob_label, draw_prob_grid)
        labels_dict['draw'] = {'label': draw_prob_label,
                                    'place': draw_prob_grid}

        away_prob_grid = draw_prob_grid.copy()
        away_prob_grid.add_column(1)
        away_prob_label = insert_label(self.frames['data'], text='2', font=HEADER_FONT)
        place_widget(away_prob_label, away_prob_grid)
        labels_dict['away'] = {'label': away_prob_label,
                                    'place': away_prob_grid}

        under_prob_grid = away_prob_grid.copy()
        under_prob_grid.add_column(1)
        under_prob_label = insert_label(self.frames['data'], text='Under', font=HEADER_FONT)
        place_widget(under_prob_label, under_prob_grid)
        labels_dict['under'] = {'label': under_prob_label,
                                    'place': under_prob_grid}

        over_prob_grid = under_prob_grid.copy()
        over_prob_grid.add_column(1)
        over_prob_label = insert_label(self.frames['data'], text='Over', font=HEADER_FONT)
        place_widget(over_prob_label, over_prob_grid)
        labels_dict['over'] = {'label': over_prob_label,
                                        'place': over_prob_grid}

        goal_prob_grid = over_prob_grid.copy()
        goal_prob_grid.add_column(1)
        goal_prob_label = insert_label(self.frames['data'], text='Goal', font=HEADER_FONT)
        place_widget(goal_prob_label, goal_prob_grid)
        labels_dict['goal'] = {'label': goal_prob_label,
                                    'place': goal_prob_grid}

        nogoal_prob_grid = goal_prob_grid.copy()
        nogoal_prob_grid.add_column(1)
        nogoal_prob_label = insert_label(self.frames['data'], text='No Goal', font=HEADER_FONT)
        place_widget(nogoal_prob_label, nogoal_prob_grid)
        labels_dict['nogoal'] = {'label': nogoal_prob_label,
                                'place': nogoal_prob_grid}

        return labels_dict
Ejemplo n.º 8
0
    def init_elements(self):
        self.matches_vars = {
            'home_team': [],
            'away_team': [],
            '1X_bet': [],
            'X2_bet': []
        }

        self.matches = {
            '1X_bet': [],
            'home_team': [],
            'away_team': [],
            'X2_bet': []
        }

        self.league_var = tk.StringVar()
        self.round_var = tk.StringVar()

        self.frames = {
            'league': Frame_Window(self, None),
            'matches': Frame_Window(self, None),
            'buttons': Frame_Window(self, None)
        }

        # TEAMA MENU ITEMS
        league_pack = Pack_Structure(fill=tk.X, padx=5, pady=5)

        first_item = 'Select one League'
        league_menu = insertOptionMenu(self.frames['league'],
                                       self.league_var,
                                       elem_list=self.league_list)
        place_widget(league_menu, league_pack)

        calculate_pack = Pack_Structure(side=tk.RIGHT, padx=30, pady=50)

        # CALCULATE BUTTON
        args_fn = {
            'root': self,
            'round_var': self.round_var,
            'matches': self.matches_vars,
            'league': self.league_var,
            'api_config': self.api_config
        }

        self.confirm_button = tk.Button(
            self.frames['buttons'],
            text='Confirm',
            command=lambda *args, x=args_fn: calculate_action(x, *args))
        place_widget(self.confirm_button, calculate_pack)

        # LOAD MATCHES BUTTON
        args_fn = {
            'root': self,
            'matches_vars': self.matches_vars,
            'next_matches': self.next_matches,
            'league_var': self.league_var,
        }

        self.load_button = tk.Button(
            self.frames['buttons'],
            text='Load Matches',
            command=lambda *args, x=args_fn: load_matches(x, *args))
        clear_pack = Pack_Structure(side=tk.LEFT, padx=30, pady=50)
        place_widget(self.load_button, clear_pack)

        # ROUND
        # tk.Label(self.root, text='Round N.').grid(row=calculate_grid.row - 1,
        #                                           column=1,
        #                                           pady=(20, 10))

        round_label = tk.Label(self.frames['buttons'], text='Round N.')
        round_pack = Pack_Structure(side=tk.LEFT, padx=30, pady=20)
        place_widget(round_label, round_pack)

        # tk.Entry(self.root, textvariable=self.round_var,
        #          justify='center',
        #          width=7).grid(row=calculate_grid.row, column=1)

        round_entry = tk.Entry(self.frames['buttons'],
                               textvariable=self.round_var,
                               justify='center',
                               width=7)
        round_pack.set_padx(10)
        place_widget(round_entry, round_pack)