@rdb: Thank you!
@EdBighead:
You need an instance of your HighScoreDataSource where you passed the name of the datasource to the constructor.
Below is how I got it to work:
import traceback
class HighScoreDataSource(DataSource):
def __init__(self, name):
self.scores = [] # could be any name
self.scores.append({'name': 'Mike', 'wave': 1, 'score': "42", "colour": "USSExcelsior"})
DataSource.__init__(self, name)
def GetRow(self, table_name, index, columns):
row = list()
try:
if index > len(self.scores)-1:
return row
if(table_name == 'scores'):
for col in columns:
if col not in self.scores[index]:
continue # skip columns we don't know
if(col == 'name'):
row.append(self.scores[index][col])
elif(col == 'score'):
row.append(self.scores[index][col])
elif(col == 'colour'):
row.append(self.scores[index][col])
elif(col == 'wave'):
row.append(self.scores[index][col])
except:
traceback.print_exc()
return row
def GetNumRows(self, table_name):
if(table_name == 'scores'):
return len(self.scores)
return 0
hs = HighScoreDataSource("high_scores")