add error handling for invalid entry into tourneNo field
This commit is contained in:
parent
3467f757d3
commit
391c42cdff
|
@ -58,50 +58,48 @@ class GuiTourneyViewer (threading.Thread):
|
|||
#end def __init__
|
||||
|
||||
def displayClicked(self, widget, data=None):
|
||||
self.prepare(10, 9)
|
||||
if self.prepare(10, 9):
|
||||
result=self.db.getTourneyInfo(self.siteName, self.tourneyNo)
|
||||
x=0
|
||||
y=0
|
||||
for i in range(1,len(result[0])):
|
||||
if y==9:
|
||||
x+=2
|
||||
y=0
|
||||
|
||||
result=self.db.getTourneyInfo(self.siteName, self.tourneyNo)
|
||||
x=0
|
||||
y=0
|
||||
for i in range(1,len(result[0])):
|
||||
if y==9:
|
||||
x+=2
|
||||
y=0
|
||||
label=gtk.Label(result[0][i])
|
||||
self.table.attach(label,x,x+1,y,y+1)
|
||||
|
||||
label=gtk.Label(result[0][i])
|
||||
self.table.attach(label,x,x+1,y,y+1)
|
||||
if result[1][i]==None:
|
||||
label=gtk.Label("N/A")
|
||||
else:
|
||||
label=gtk.Label(result[1][i])
|
||||
self.table.attach(label,x+1,x+2,y,y+1)
|
||||
|
||||
if result[1][i]==None:
|
||||
label=gtk.Label("N/A")
|
||||
else:
|
||||
label=gtk.Label(result[1][i])
|
||||
self.table.attach(label,x+1,x+2,y,y+1)
|
||||
|
||||
y+=1
|
||||
y+=1
|
||||
self.mainVBox.show_all()
|
||||
#def displayClicked
|
||||
|
||||
def displayPlayerClicked(self, widget, data=None):
|
||||
self.prepare(4, 5)
|
||||
if self.prepare(4, 5):
|
||||
result=self.db.getTourneyPlayerInfo(self.siteName, self.tourneyNo, self.playerName)
|
||||
x=0
|
||||
y=0
|
||||
for i in range(1,len(result[0])):
|
||||
if y==5:
|
||||
x+=2
|
||||
y=0
|
||||
|
||||
result=self.db.getTourneyPlayerInfo(self.siteName, self.tourneyNo, self.playerName)
|
||||
x=0
|
||||
y=0
|
||||
for i in range(1,len(result[0])):
|
||||
if y==5:
|
||||
x+=2
|
||||
y=0
|
||||
label=gtk.Label(result[0][i])
|
||||
self.table.attach(label,x,x+1,y,y+1)
|
||||
|
||||
label=gtk.Label(result[0][i])
|
||||
self.table.attach(label,x,x+1,y,y+1)
|
||||
if result[1][i]==None:
|
||||
label=gtk.Label("N/A")
|
||||
else:
|
||||
label=gtk.Label(result[1][i])
|
||||
self.table.attach(label,x+1,x+2,y,y+1)
|
||||
|
||||
if result[1][i]==None:
|
||||
label=gtk.Label("N/A")
|
||||
else:
|
||||
label=gtk.Label(result[1][i])
|
||||
self.table.attach(label,x+1,x+2,y,y+1)
|
||||
|
||||
y+=1
|
||||
y+=1
|
||||
self.mainVBox.show_all()
|
||||
#def displayPlayerClicked
|
||||
|
||||
|
@ -111,12 +109,21 @@ class GuiTourneyViewer (threading.Thread):
|
|||
#end def get_vbox
|
||||
|
||||
def prepare(self, columns, rows):
|
||||
self.tourneyNo=int(self.entryTourney.get_text())
|
||||
try: self.errorLabel.destroy()
|
||||
except: pass
|
||||
|
||||
try:
|
||||
self.tourneyNo=int(self.entryTourney.get_text())
|
||||
except ValueError:
|
||||
self.errorLabel=gtk.Label("invalid entry in tourney number - must enter numbers only")
|
||||
self.mainVBox.add(self.errorLabel)
|
||||
return False
|
||||
self.siteName=self.siteBox.get_active_text()
|
||||
self.playerName=self.entryPlayer.get_text()
|
||||
|
||||
self.table.destroy()
|
||||
self.table=gtk.Table(columns=columns, rows=rows)
|
||||
self.mainVBox.add(self.table)
|
||||
return True
|
||||
#end def readInfo
|
||||
#end class GuiTourneyViewer
|
||||
|
|
Loading…
Reference in New Issue
Block a user