Esempio n. 1
0
 def openDatabase(self, tourneyName, openwindow):
     #Make sure that the tournament name entered exists
     try:
         self.cursor.execute("select name from "+tourneyName)
         teams = self.cursor.fetchall()
         teamList = []
         #Turn the tuple into a list
         for i in range(len(teams)):
             teamList.append(teams[i][0])
         #Get the list of teams, as well as their information from the database and pass it on to the bracket window
         self.cursor.execute("select name, startPos, currentRound, currentPos from "+tourneyName)
         openteams = self.cursor.fetchall()
         self.connection.close()
         openwindow.destroy()
         bracketWindow.window(tourneyName, len(teams), teamList, True, openteams)
     except:
         #Give an error message if the tournament doesn't exist
         error = messagebox.showerror("Error", "Please enter the name of a tournament that exists.")  
Esempio n. 2
0
 def createTournament(self, tourneyName, numTeams, teamList):
     teamData=[]
     #Create a list of tuples that contain the data for each team
     for i in range(numTeams):
         teamData.append((i, teamList[i], i, 0, i))
     #Create and update the table using the list of teams
     self.cursor.execute('''create table '''+tourneyName+'''(
                             teamNum integer,
                             name text,
                             startPos integer,
                             currentRound integer,
                             currentPos integer)''')
     for i in range(len(teamData)):
         self.cursor.execute('''insert into '''+tourneyName+'''(
                             teamNum, name, startPos, currentRound, currentPos)
                             values(?,?,?,?,?)''', teamData[i]
                         )
     self.connection.commit()
     #Create the bracket window with the list of teams
     bracketWindow.window(tourneyName, numTeams, teamList, False, (0,))