diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-05-19 13:46:56 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-05-19 14:12:36 +0200 |
commit | af83219d8a6e7ac1c0c8776f61b99ee37f30ef04 (patch) | |
tree | 51fa216a02cefef75aef77313a048bf879c91a32 /examples/webchannel/standalone/main.py | |
parent | 8cd50636102be2e1178c8c602a3e374891398e3e (diff) |
Polish the QtWebChannel example
- Rename according to snake case conventions
- Connect sending to QLineEdit.returnPressed
Task-number: PYSIDE-1112
Change-Id: Ia0e1b81309985219688739a4cead8a252acd8dcc
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'examples/webchannel/standalone/main.py')
-rw-r--r-- | examples/webchannel/standalone/main.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/examples/webchannel/standalone/main.py b/examples/webchannel/standalone/main.py index 68f199336..cd55a3814 100644 --- a/examples/webchannel/standalone/main.py +++ b/examples/webchannel/standalone/main.py @@ -1,7 +1,7 @@ ############################################################################# ## ## 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. +## Copyright (C) 2021 The Qt Company Ltd. ## Contact: http://www.qt.io/licensing/ ## ## This file is part of the Qt for Python examples of the Qt Toolkit. @@ -61,10 +61,10 @@ if __name__ == '__main__': print('The example requires SSL support.') sys.exit(-1) cur_dir = os.path.dirname(os.path.abspath(__file__)) - jsFileInfo = QFileInfo(f"{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 +74,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() @@ -91,8 +91,9 @@ if __name__ == '__main__': url = QUrl.fromLocalFile(f"{cur_dir}/index.html") QDesktopServices.openUrl(url) - message = f"Initialization complete, opening browser at {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()) |