MCPcopy Create free account
hub / github.com/PyQt5/PyQt / DynamicClient

Class DynamicClient

QtRemoteObjects/simpleswitch/directconnectdynamicclient.py:60–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58
59
60class DynamicClient(QObject):
61 # This signal is connected with server_slot() slot of the source object and
62 # echoes back the switch state received from the source.
63 echoSwitchState = pyqtSignal(bool)
64
65 def __init__(self, replica, parent=None):
66 super().__init__(parent)
67
68 self._replica = replica
69 self._clientSwitchState = False
70
71 replica.initialized.connect(self.initConnection)
72
73 @pyqtSlot(bool)
74 def recSwitchState(self, value):
75 self._clientSwitchState = self._replica.property('currState')
76
77 print("Received source state", value, self._clientSwitchState)
78
79 # Emit the signal to echo the received state back to the server.
80 self.echoSwitchState.emit(self._clientSwitchState)
81
82 @pyqtSlot()
83 def initConnection(self):
84 # Connect the replica source signal currStateChanged() with the
85 # client's recSwitchState() slot to receive the source's current state.
86 self._replica.currStateChanged.connect(self.recSwitchState)
87
88 # Connect the client's echoSwitchState() signal with replica's
89 # server_slot() to echo back the received state.
90 self.echoSwitchState.connect(self._replica.server_slot)
91
92
93if __name__ == '__main__':

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected