Skip to main content

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.2.0
    • Modity signal-slots type
    • Remote del
  • V0.1.1
    • Convert paho-mqtt callbacks to qt signal-slots
    • Add wrapper method for paho-mqtt

Install

pip install PySide6-PahoMqtt

Example

ffrom 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.connect("127.0.0.1")

    def closeEvent(self, event):
        print("Window is closing")
        self.mqtt.disconnect()
        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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyside6_pahomqtt-0.2.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyside6_pahomqtt-0.2.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file pyside6_pahomqtt-0.2.0.tar.gz.

File metadata

  • Download URL: pyside6_pahomqtt-0.2.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for pyside6_pahomqtt-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a028b0455ff0b8941dccc9959395da094bb1cfd52ab3db2698e8b2f185458d04
MD5 5e4f73f7a7dffc5c54a890a396e36a14
BLAKE2b-256 103e77271ac3a53ea97ff1a4bec07489a03c03f92db3f81038dac8b4c8a76db6

See more details on using hashes here.

File details

Details for the file pyside6_pahomqtt-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pyside6_pahomqtt-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e5ad5c14cbac26d9730706ad9fd9ef306b87df1ff7ba4cfeb0d6440cffa39be5
MD5 8bea66fe849cab4606e98d1b782127ac
BLAKE2b-256 2e29bf91cac8ef80477978f6d487ea0ece0f873d588a422c3fd41017367c62d6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page