May 2019
Intermediate to advanced
542 pages
13h 37m
English
In MainWindow.__init__(), we'll start by creating a board and a QGraphicsView object to display it:
self.board = TTTBoard() self.board_view = qtw.QGraphicsView() self.board_view.setScene(self.board) self.setCentralWidget(self.board_view)
Now we need to create an instance of the game engine and connect its signals. In order to allow us to start games over and over, we'll create a separate method for this:
def start_game(self): self.board.clear_board() self.game = TicTacToeEngine() self.game.game_won.connect(self.game_won) self.game.game_draw.connect(self.game_draw)
This method clears the board, and then it creates an instance of the game engine object, connecting the engine's signals to MainWindow methods to handle ...
Read now
Unlock full access