def update_matches(self, match):

        matches = tr_api.matchList(self.activeRound)
        row_num = 0
        if "rows" not in matches.keys():
            messagebox.showerror("List Matches",
                                 "Database Communication Error")
            return
        elif len(matches["rows"]) > 0:
            match_list = matches["rows"]
            for i in range(0, len(match_list)):
                if match_list[i]["id"] == match:

                    row_num = i + 1

                    # delete the previous matches
                    for row in self.frame_matchList.grid_slaves(row=row_num):
                        row.grid_forget()
                        row.destroy()

                    self.matchframeupdate(match_list, row_num)
                    self.frame_matchList.update_idletasks()
示例#2
0
 def setUp(self):
     if done is False:
         setUpHelper(self)
     self.topdict = tr_api.matchList(3)
示例#3
0
def main():
    
    while True: # no do while in python :(
        result = None
        command = input(">")
        if len(command) == 0:
            continue
        command = command.split()

        try:
            if command[0].lower() == 'cp':
                # concatenate the command strings after a certain point together so
                # that first and last names can be added. 
                name = concat_end(command, 2)
                if name == None:
                    raise IndexError("No name")
                result = tr_api.createPlayer(int(command[1]), name)
                table_print(result)
            elif command[0].lower() == 'ct':
                # concatenate the command strings after a certain point together so
                # that first and last names can be added. 
                name = concat_end(command, 2)
                if name == None:
                    raise IndexError("No name")
                result = tr_api.createTournament(name, int(command[1]))
                table_print(result)
            elif command[0].lower() == 'sp':
                # concatenate the command strings after a certain point together so
                # that first and last names can be added. 
                name = concat_end(command, 1)
                if name == None:
                    raise IndexError("No name")
                result = tr_api.searchPlayers(name)
                table_print(result)
            elif command[0].lower() == 'ap':
                result = tr_api.addPlayer(int(command[1]),int(command[2]))
                table_print(result)
            elif command[0].lower() == 'rp':
                result = tr_api.removePlayer(int(command[1]),int(command[2]))
                table_print(result)
            elif command[0].lower() == 'lp':
                result = tr_api.listPlayers()
                table_print(result)
            elif command[0].lower() == 'lt':
                result = tr_api.listTournaments(None, None)
                table_print(result)
            elif command[0].lower() == 'ltp':
                result = tr_api.listTournamentPlayers(int(command[1]))
                table_print(result)
            elif command[0].lower() == 'latp':
                result = tr_api.listActiveTournamentPlayers(int(command[1]))
                table_print(result)
            elif command[0].lower() == 'fr':
                result = tr_api.finishRound(int(command[1]))
                table_print(result)
            elif command[0].lower() == 'genpairings':
                result = tr_api.generatePairings(int(command[1]))
                table_print(result)
            elif command[0].lower() == 'gtp':
                result = tr_api.getTournamentPlayer(int(command[1]))
                print(result)
            elif command[0].lower() == 'gp':
                result = tr_api.getPlayer(int(command[1]))
                player_print(result)
            elif command[0].lower() == 'lm':
                result = tr_api.matchList(int(command[1]))
                table_print(result)
            elif command[0].lower() == 'lr':
                result = tr_api.roundList(int(command[1]))
                table_print(result)
            elif command[0].lower() == 'st':
                result = tr_api.startTournament(int(command[1]))
                table_print(result)
            elif command[0].lower() == 'smr':
                result = tr_api.setMatchResults(
                        int(command[1]), int(command[2]), int(command[3]), int(command[4]))
                table_print(result)

            elif command[0].lower() == 'help':
                print_help()
                continue

            elif command[0].lower() == 'exit':
                return

            else:
                print("Invalid command")
                continue
        except ValueError:
            print("Invalid parameter type")
            continue
        except IndexError:
            print("Invalid number of parameters")
            continue
    def action_MatchViewer(self):
        """
        creates a new window to submit results of a match.
        """

        if (self.activeRound is None):
            messagebox.showerror("Match List", "No known round selected.")
            return

        self.win_listMatches = Tk()  # create the new window
        self.win_listMatches.title("Match Viewer")  # set the title of window
        Label(self.win_listMatches,
              text="Match Viewer",
              font=("Helvetica", 16)).pack()

        self.frame_matchList = Frame(self.win_listMatches)  # create a frame
        self.frame_matchList.pack(side="top", padx=20,
                                  pady=20)  # and place it on the top
        frame_playerFooter = Frame(self.win_listMatches)
        frame_playerFooter.pack(side="bottom")

        # create the labels that define what each input box is used for, and align them
        Label(self.frame_matchList, fg="blue", text="Matches").grid(row=0,
                                                                    column=0,
                                                                    sticky=W)
        Label(self.frame_matchList, fg="blue", text="Player 1").grid(row=0,
                                                                     column=1)
        Label(self.frame_matchList, fg="blue", text="Player 2").grid(row=0,
                                                                     column=2)
        Label(self.frame_matchList, fg="blue",
              text="Table Location").grid(row=0, column=3, sticky=W)
        Label(self.frame_matchList, fg="blue",
              text="Player 1 Wins").grid(row=0, column=4, sticky=W)
        Label(self.frame_matchList, fg="blue",
              text="Player 2 Wins").grid(row=0, column=5, sticky=W)
        Label(self.frame_matchList, fg="blue", text="Draws").grid(row=0,
                                                                  column=6,
                                                                  sticky=W)
        Label(self.frame_matchList, fg="blue", text="----").grid(row=0,
                                                                 column=7,
                                                                 sticky=W)

        matches = tr_api.matchList(self.activeRound)
        row_num = 0
        if "rows" not in matches.keys():
            messagebox.showerror("List Matches",
                                 "Database Communication Error")
            return
        elif len(matches["rows"]) > 0:
            match_list = matches["rows"]
            for i in range(0, len(match_list)):
                row_num = i + 1
                self.matchframeupdate(match_list, row_num)

        # bind these keystrokes
        btn_addPlayer_cancel = Button(
            frame_playerFooter,
            text="Cancel",
            command=self.win_listMatches.destroy).grid(row=0,
                                                       column=0,
                                                       sticky=W)