def but1(): if not list2.currentItem(): QMessageBox.critical(window,'error','No roster selected') else: ln = list1.currentItem().text() rn = list2.currentItem().text() pn,test = QInputDialog.getText(window,'Input dialog','Enter Player to Add\'s Name:').strip() if test: tn,test = QInputDialog.getText(window,'Input dialog','Enter name of NFL team player plays on:').strip() ret=fbTool.addPlayer(str(ln),str(rn),str(pn),str(tn)) if ret == 1: QMessageBox.critical(window,'error','Could not add player: Player already rostered') if ret == 2: QMessageBox.critical(window,'error','Could not add player: Player does not exist') if not ret: mainMenu.updateTree() poplist3(list2.currentItem()) mainMenu.updateTree()
def addPlayerUI(): ln=getLeagueName(0) tn=getTeamName(ln) inp = 'y' while inp.lower() in ['y','yes']: printPlayers(ln,tn) plName=raw_input('Please input the desired player to add\'s name: ') plTeam=raw_input('Please input the desired player\'s NFL team: ') testVar=fbTool.addPlayer(ln,tn,plName,plTeam) if not testVar: print 'Succesfully added %s to %s from league %s' % (plName,tn,ln) else: print 'Failed to add player...' if testVar == 1: print 'Player already rostered in league %s'%ln if testVar == 2: print 'Player %s not found in database'%plName if testVar == 3: print 'Team does not exist.' userInVar = ' ' while userInVar.lower() not in ['y','yes','n','no']: userInVar = raw_input('Would you like to add it? (y/n): ').strip() if userInVar.lower() not in ['y','yes','n','no']: print 'Invalid input. Please try again.' if userInVar.lower()=='y' or userInVar.lower()=='yes': if not addRosterUI(ln,tn,[]): testVar = fbTool.addPlayer(ln,tn,plName,plTeam) if not testVar: print 'Successfully added %s to %s from league %s' %(plName,tn,ln) else: print 'Failed to add player.' if testVar == 1: print 'Player already rostered in league %s'%ln if testVar == 2: print 'Player %s not found in database'%plName else: print 'Failed to add roster.' raw_input ('Press return to continue...').strip() return -1 if testVar == 4: print 'League does not exist.' userInVar=' ' while userInVar.lower() not in ['y','yes','n','no']: userInVar = raw_input('Would you like to add the league and team? (y/n): ').strip() if userInVar.lower() not in ['y','yes','no','n']: print 'Invalid input. Please try again.' if userInVar.lower()=='y' or userInVar.lower()=='yes': if not fbTool.addLeague(ln): if not addRosterUI(ln,tn,[]): testVar =fbTool.addPlayer(ln,tn,plName,plTeam) if not testVar: print 'Successfully added %s to %s from league %s' %(plName,tn,ln) else: print 'Failed to add player.' if testVar == 1: print 'Player already rostered in league %s'%ln if testVar == 2: print 'Player %s not found in database'%plName else: print 'failed to add team to league' else: print 'something went horribly wrong.' inp = raw_input ('Would you like to add another player? (y/n) ') while inp.lower() not in ['y','yes','n','no']: print 'Invalid input. Please try again...' inp = raw_input ('Would you like to add another player? (y/n) ')