def but(): if not list1.currentItem(): QMessageBox.critical(window,'error','Not league selected') else: defense = [] ln=str(list1.currentItem().text()) loopvar = QMessageBox.Yes rn,test = QInputDialog.getText(window,'New roster','Please enter the name for the new roster you\'d like to add:').strip() rn = str(rn) while loopvar == QMessageBox.Yes: dn,test = QInputDialog.getText(window,'Defense','Please enter a team to use as defense:').strip() if test: d = nflgame.standard_team(str(dn)) if d is None: QMessageBox.critical(window,'error','Invalid team name') else: defense.append(d) if defense: loopvar = QMessageBox.question(window,'???','Would you like to add another defense team?',QMessageBox.Yes|QMessageBox.No,QMessageBox.Yes) elif not defense: QMessageBox.critical(window,'error','Cannot have no defense') else: loopvar = QMessageBox.No status = fbTool.addRoster(ln,rn,defense) if status >=3: errstr = 'defense team ' + defense[status-3] + ' is already used' QMessageBox.critical(window,'error',errstr) elif status ==1: QMessageBox.critical(window,'error','Team already exists.') elif status: QMessageBox.critical(window,'error','Something is horribly wrong') mainMenu.updateTree()
def but1(): if li.currentItem(): ln = li.currentItem().text() te = QMessageBox.question(window,'???','Are you sure you want to delete this league? (it will remove the league and all of the teams on the league)',QMessageBox.Yes|QMessageBox.No,QMessageBox.No) if te == QMessageBox.Yes: fbTool.removeLeague(str(ln)) li.clear() for i in fbTool.leagueLists: li.addItem(i.leagueName) mainMenu.updateTree() else: QMessageBox.critical(window,'error','No league selected')
def but1(): if list2.currentItem(): ln = list1.currentItem().text() rn = list2.currentItem().text() te = QMessageBox.question(window,'???','Are you sure you want to delete this roster?',QMessageBox.Yes|QMessageBox.No,QMessageBox.No) if te == QMessageBox.Yes: fbTool.removeRoster(str(ln),str(rn)) for i in fbTool.leagueLists: if i.leagueName == str(ln): list2.clear() for j in i.rosters: list2.addItem(j.rosterName) mainMenu.updateTree() else: QMessageBox.critical(window,'error','No roster selected')
def but2(): if not list3.currentItem(): QMessageBox.critical(window,'error','No player selected') else: ln = list1.currentItem().text() rn = list2.currentItem().text() pn = str(list3.currentItem().text()) te = QMessageBox.question(window,'???','Are you sure you want to delete this player?',QMessageBox.Yes|QMessageBox.No,QMessageBox.No) if te == QMessageBox.Yes: if pn[-1]==')': pn=pn[:-3] ret = fbTool.removePlayer(nflgame.find(pn,team=None),str(ln),str(rn)) if ret: QMessageBox.critical(window,'error','SOMETHING BROKE!') else: poplist3(list2.currentItem()) mainMenu.updateTree()
def but3(): if not list3.currentItem(): QMessageBox.critical(window,'error','No player selected') else: ln=str(list1.currentItem().text()) rn=str(list2.currentItem().text()) pn=str(list3.currentItem().text()) if pn[-1]==')': pn=pn[:-3] for i in fbTool.leagueLists: if i.leagueName == ln: for j in i.rosters: if j.rosterName == rn: for k in j.players: if pn==(k.firstName + ' ' + k.lastName): fbTool.setPlayerActiveFlag(k) poplist3(list2.currentItem()) mainMenu.updateTree()
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 but(): if not leagues.currentItem(): QMessageBox.critical(window,'error','League not selected from league list') elif not rosters1.currentItem(): QMessageBox.critical(window,'error','Roster not selected from top rosters box') elif not rosters2.currentItem(): QMessageBox.critical(window,'error','Roster not selected from bottom rosters box') elif not roster1.currentItem(): QMessageBox.critical(window,'error','Player not selected from top roster') elif not roster2.currentItem(): QMessageBox.critical(window,'error','Player not selected from the bottom roster') elif roster1.currentItem().text()==roster2.currentItem().text(): QMessageBox.critical(window,'error','Roster cannot trade to self') else: ln = str(leagues.currentItem().text()) r1 = str(rosters1.currentItem().text()) r2 = str(rosters2.currentItem().text()) ret = fbTool.tradePlayers(pl1,pl2,ln,r1,r2) if ret: QMessageBox.critical(window,'error','Something is broken.') else: popRoster1() popRoster2() mainMenu.updateTree()