This is a wrapping class for using paho-mqtt(V2.x) in pyside6.
Project description
This is a wrapping class for using paho-mqtt(V2.x) in pyside6.
History
- V0.1.0
- Convert paho-mqtt callbacks to qt signal-slots
- Add wrapper method for paho-mqtt
Install
pip install PySide6-PahoMqtt
Example
from PySide6.QtWidgets import QApplication, QMainWindow
from PySide6.PahoMqtt import Client
class UI(QMainWindow):
def __init__(self):
super().__init__()
self.mqtt = Client()
self.mqtt.on_connect.connect(self.onConnect)
self.mqtt.on_connect_fail.connect(self.onConnectFail)
self.mqtt.on_disconnect.connect(self.onDisconnect)
self.mqtt.on_publish.connect(self.onPublish)
self.mqtt.on_subscribe.connect(self.onSubscribe)
self.mqtt.on_message.connect(self.onMessage)
self.mqtt.connection("mqtt.eclipseprojects.io")
def closeEvent(self, event):
print("Window is closing")
self.mqtt.disconnection()
event.accept()
def onConnect(self, connect_flags, reason_code, properties):
print(f"connect: {connect_flags}, {reason_code}, {properties}")
if reason_code == 0:
self.mqtt.subscribe("planxlabs/#")
self.mqtt.publish("planxlabs/test", {"data": "Hello World"})
else:
print("fail")
def onConnectFail(self):
print("connect fail")
def onDisconnect(self, disconnect_flags, reason_code):
print(f"disconnect: {disconnect_flags}, {reason_code}")
def onPublish(self, mid, reason_code):
print(f"publish: {mid}, {reason_code}")
def onSubscribe(self, mid, reason_code_list):
print(f"subscribe: {mid}, {reason_code_list}")
def onMessage(self, topic, payload, qos, retain, properties):
print(f"message: {topic}, {payload}, {qos}, {retain}, {properties}")
if __name__ == "__main__":
app = QApplication([])
win = UI()
win.show()
app.exec()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyside6_pahomqtt-0.1.1.tar.gz.
File metadata
- Download URL: pyside6_pahomqtt-0.1.1.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07e6f18b8cfb1357868371412f22fa389ad446033e06e3a0930ea60b2a03ed3f
|
|
| MD5 |
239f5a945c8241f0437e5d2c0ee89301
|
|
| BLAKE2b-256 |
383ccc3b6398abf0e2ee519cbd628b75dd2a61f3fea4a793a87565f73066aedd
|
File details
Details for the file PySide6_PahoMqtt-0.1.1-py3-none-any.whl.
File metadata
- Download URL: PySide6_PahoMqtt-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d347d4c4b43aa9170e3694a16b1adf25ffa0ecc9e6d1eef7ccaf030439b8365a
|
|
| MD5 |
9e75ac334915b9b3cbbcadd59d575628
|
|
| BLAKE2b-256 |
fd4f621cb382a36c38ae744f419fb34c59f4b2dc77a73654a3d959c5e0426e70
|