aboutsummaryrefslogtreecommitdiffstats
path: root/examples/webchannel/standalone/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/webchannel/standalone/main.py')
-rw-r--r--examples/webchannel/standalone/main.py75
1 files changed, 19 insertions, 56 deletions
diff --git a/examples/webchannel/standalone/main.py b/examples/webchannel/standalone/main.py
index d3119141f..8c04aa64f 100644
--- a/examples/webchannel/standalone/main.py
+++ b/examples/webchannel/standalone/main.py
@@ -1,54 +1,17 @@
-#############################################################################
-##
-## Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Milian Wolff <milian.wolff@kdab.com>
-## Copyright (C) 2020 The Qt Company Ltd.
-## Contact: http://www.qt.io/licensing/
-##
-## This file is part of the Qt for Python examples of the Qt Toolkit.
-##
-## $QT_BEGIN_LICENSE:BSD$
-## You may use this file under the terms of the BSD license as follows:
-##
-## "Redistribution and use in source and binary forms, with or without
-## modification, are permitted provided that the following conditions are
-## met:
-## * Redistributions of source code must retain the above copyright
-## notice, this list of conditions and the following disclaimer.
-## * Redistributions in binary form must reproduce the above copyright
-## notice, this list of conditions and the following disclaimer in
-## the documentation and/or other materials provided with the
-## distribution.
-## * Neither the name of The Qt Company Ltd nor the names of its
-## contributors may be used to endorse or promote products derived
-## from this software without specific prior written permission.
-##
-##
-## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
+# Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Milian Wolff <milian.wolff@kdab.com>
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import os
import sys
-from PySide2.QtWidgets import QApplication
-from PySide2.QtGui import QDesktopServices
-from PySide2.QtNetwork import QHostAddress, QSslSocket
-from PySide2.QtCore import (QFile, QFileInfo, QUrl)
-from PySide2.QtWebChannel import QWebChannel
-from PySide2.QtWebSockets import QWebSocketServer
+from PySide6.QtWidgets import QApplication
+from PySide6.QtGui import QDesktopServices
+from PySide6.QtNetwork import QHostAddress, QSslSocket
+from PySide6.QtCore import (QFile, QFileInfo, QUrl)
+from PySide6.QtWebChannel import QWebChannel
+from PySide6.QtWebSockets import QWebSocketServer
from dialog import Dialog
from core import Core
@@ -61,10 +24,10 @@ if __name__ == '__main__':
print('The example requires SSL support.')
sys.exit(-1)
cur_dir = os.path.dirname(os.path.abspath(__file__))
- jsFileInfo = QFileInfo(cur_dir + "/qwebchannel.js")
- if not jsFileInfo.exists():
+ js_file_info = QFileInfo(f"{cur_dir}/qwebchannel.js")
+ if not js_file_info.exists():
QFile.copy(":/qtwebchannel/qwebchannel.js",
- jsFileInfo.absoluteFilePath())
+ js_file_info.absoluteFilePath())
# setup the QWebSocketServer
server = QWebSocketServer("QWebChannel Standalone Example Server",
@@ -74,11 +37,11 @@ if __name__ == '__main__':
sys.exit(-1)
# wrap WebSocket clients in QWebChannelAbstractTransport objects
- clientWrapper = WebSocketClientWrapper(server)
+ client_wrapper = WebSocketClientWrapper(server)
# setup the channel
channel = QWebChannel()
- clientWrapper.clientConnected.connect(channel.connectTo)
+ client_wrapper.client_connected.connect(channel.connectTo)
# setup the UI
dialog = Dialog()
@@ -88,12 +51,12 @@ if __name__ == '__main__':
channel.registerObject("core", core)
# open a browser window with the client HTML page
- url = QUrl.fromLocalFile(cur_dir + "/index.html")
+ url = QUrl.fromLocalFile(f"{cur_dir}/index.html")
QDesktopServices.openUrl(url)
- message = "Initialization complete, opening browser at {}.".format(
- url.toDisplayString())
- dialog.displayMessage(message)
+ display_url = url.toDisplayString()
+ message = f"Initialization complete, opening browser at {display_url}."
+ dialog.display_message(message)
dialog.show()
- sys.exit(app.exec_())
+ sys.exit(app.exec())