Example #1
0
 def __init__(self, *args, **kwargs):
     super(WindowMaster, self).__init__(*args, **kwargs)
     # 监听剪切板
     clipboard = QApplication.clipboard()
     clipboard.dataChanged.connect(self.on_data_changed)
     # 开启节点
     host = QRemoteObjectHost(QUrl('tcp://0.0.0.0:' + sys.argv[1]), parent=self)
     host.enableRemoting(self, 'WindowMaster')
     self.append('开启节点完成')
Example #2
0
    def __init__(self, *args, **kwargs):
        super(WindowMaster, self).__init__(*args, **kwargs)
        self.setupUi()

        # 开启节点
        host = QRemoteObjectHost(QUrl('local:WindowMaster'), parent=self)
        host.enableRemoting(self, 'WindowMaster')
        print('开启节点完成')

        # 定时器更新进度条
        self._value = 0
        self.utimer = QTimer(self, timeout=self.updateProgress)
        self.utimer.start(200)
Example #3
0
        secondItem = QStandardItem("FancyRow2TextNumber {}".format(i))
        if i % 2 == 0:
            firstItem.setBackground(Qt.red)

        sourceModel.invisibleRootItem().appendRow([firstItem, secondItem])

    # Needed by QMLModelViewClient.
    roleNames = {Qt.DisplayRole: b'_text', Qt.BackgroundRole: b'_color'}
    sourceModel.setItemRoleNames(roleNames)

    roles = [Qt.DisplayRole, Qt.BackgroundRole]

    node = QRemoteObjectRegistryHost(QUrl('local:registry'))

    node2 = QRemoteObjectHost(QUrl('local:replica'), QUrl('local:registry'))
    node2.enableRemoting(sourceModel, 'RemoteModel', roles)

    view = QTreeView()
    view.setWindowTitle("SourceView")
    view.setModel(sourceModel)
    view.show()

    handler = TimerHandler(sourceModel)
    QTimer.singleShot(5000, handler.changeData)
    QTimer.singleShot(10000, handler.insertData)
    QTimer.singleShot(11000, handler.changeFlags)
    QTimer.singleShot(12000, handler.removeData)
    QTimer.singleShot(13000, handler.moveData)

    sys.exit(app.exec_())
        # The switch state echoed back by the client.
        print("Replica state is", clientState)

    def _timeout(self):
        # Note that we don't decorate this callable so that it doesn't get
        # exposed in a replica.
        self.currState = not self.currState

        print("Source state is", self.currState)


if __name__ == '__main__':

    app = QCoreApplication(sys.argv)

    # Create the simple switch.
    srcSwitch = SimpleSwitch()

    # Create the node that hosts the registry.  This could be in a separate
    # process.
    regNode = QRemoteObjectRegistryHost(QUrl('local:registry'))

    # Create the host object node.  This will connect to the registry node
    # rather than to a client.
    srcNode = QRemoteObjectHost(QUrl('local:replica'), QUrl('local:registry'))

    # Enable remoting.
    srcNode.enableRemoting(srcSwitch, 'SimpleSwitch')

    sys.exit(app.exec_())
Example #5
0
                             notify=currStateChanged)

    # The slot exposed to a remote client.
    @pyqtSlot(bool)
    def server_slot(self, clientState):
        # The switch state echoed back by the client.
        print("Replica state is", clientState)

    def _timeout(self):
        # Note that we don't decorate this callable so that it doesn't get
        # exposed in a replica.
        self.currState = not self.currState

        print("Source state is", self.currState)


if __name__ == "__main__":

    app = QCoreApplication(sys.argv)

    # Create the simple switch.
    srcSwitch = SimpleSwitch()

    # Create the host object node.
    srcNode = QRemoteObjectHost(QUrl("local:replica"))

    # Enable remoting.
    srcNode.enableRemoting(srcSwitch, "SimpleSwitch")

    sys.exit(app.exec_())