Details
-
Bug
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
6.6.1
-
None
-
Ubuntu 22.04 LTS
Python 3.10.12
-
-
2c3bf4273 (dev), ead40ef99 (6.6), 8f984a8a6 (tqtc/lts-6.5), a8fcf4414 (dev)
Description
Hello,
I am trying to connect to a DBus Signal with PySide6, but don't get it to work and wonder if the signature stated in the docs is really correct.
I am trying to get a notification, when a new service name is on the system DBus...
import sysfrom PySide6 import QtDBus from PySide6.QtCore import QLibraryInfo, qVersion from PySide6.QtWidgets import QApplication, QMainWindow class MainWindow(QMainWindow): def __init__ (self, *args, **kwargs): super().__init__(*args, **kwargs) service = 'org.freedesktop.DBus' path = '/org/freedesktop/DBus' iface = 'org.freedesktop.DBus' conn = QtDBus.QDBusConnection.systemBus() #conn.connect(service, path, iface, "NameOwnerChanged", self.nameownerchangeslot, "nameownerchangeslot") #this brings up: #TypeError: 'PySide6.QtDBus.QDBusConnection.connect' called with wrong argument types: #PySide6.QtDBus.QDBusConnection.connect(str, str, str, str, method, str) conn.connect(service, path, iface, "NameOwnerChanged", self, "nameownerchangeslot") def nameownerchangeslot(self, arg:object) -> None: print(arg) pass if __name__ == '__main__': print('Python {}.{}.{} {}'.format(sys.version_info[0], sys.version_info[1], sys.version_info[2], sys.platform)) print(QLibraryInfo.build()) app = QApplication(sys.argv) window = MainWindow() window.setWindowTitle(qVersion()) window.resize(800, 480) window.show() sys.exit(app.exec())
This is the output:
Python 3.10.12 linux Qt 6.6.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 10.3.1 20210422 (Red Hat 10.3.1-1)) [Python limited API 3.10.12] qt.dbus.integration: Could not connect "org.freedesktop.DBus" to ameownerchangeslot :
The receiver is defined as QObject and the slot as a str, on a normal python signal connect, this is simply an object.
You see also if i pass the method as argument it is complaining that it is not on object, but also on a normal python signal connect, the argument is also defined as object and giving the method works...
I also tried an external package like sdbus, but this needs the asyncio package to listen for signals. I also configured PySide to use the asyncio loop, but the event class hasn't implemented the file watchers and socket connections, so this doesn't work either...
Any help and clarification is appreciated!
Best regards
Matthias Nacke
{{}}
Attachments
Gerrit Reviews
For Gerrit Dashboard: PYSIDE-2547 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
525417,6 | QDBusConnection::connnect(): Improve error handling | dev | qt/qtbase | Status: NEW | +1 | 0 |
524841,2 | Fix hang in QDBusConnection::connect() | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
525023,2 | Fix hang in QDBusConnection::connect() | 6.6 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
525233,2 | Fix hang in QDBusConnection::connect() | tqtc/lts-6.5 | pyside/tqtc-pyside-setup | Status: MERGED | +2 | 0 |
528058,4 | Improve tutorial on string-based connections | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
528494,1 | Improve tutorial on string-based connections | 6.6 | pyside/pyside-setup | Status: ABANDONED | 0 | 0 |