class WordGameController: def __init__(self, d, s): Thread.__init__(self) self.dict = d self.scoring = s print("The loaded dictionary is ") print(d) self.running = False self.game = None def newGame(self): self.running = True for v in word_variables: v.set("") self.game = WordGameModel(self.dict, self.scoring, self) self.timer = Timer(time_per_game, self.stopGame) self.timer.start() def stopGame(self): self.running = False scoreVar.set("Your score is %i" % (int(self.game.scoreGame()))) def keyReleased(self, event): if self.running and self.game: self.game.keyReleased(event) elif self.running and not self.game: raise Exception("The game controller is running but has no game. This shouldn't happen.") def updateWordlistLabel(self, word, index): word_variables[index].set(word) def updateCurrentWord(self, word): currentWordVar.set(word)
def newGame(self): self.running = True for v in word_variables: v.set("") self.game = WordGameModel(self.dict, self.scoring, self) self.timer = Timer(time_per_game, self.stopGame) self.timer.start()