Using a singleton QObject to propagate game model update across whole app

This commit is contained in:
Khopa
2019-07-05 21:43:14 +02:00
parent 8246c8e94b
commit 9a73c78705
8 changed files with 52 additions and 16 deletions

View File

@@ -0,0 +1,19 @@
from PySide2.QtCore import QObject, Signal
from game import Game
class GameUpdateSignal(QObject):
instance = None
gameupdated = Signal(Game)
def __init__(self):
super(GameUpdateSignal, self).__init__()
GameUpdateSignal.instance = self
def updateGame(self, game: Game):
self.gameupdated.emit(game)
@staticmethod
def get_instance():
return GameUpdateSignal.instance