[PyQt] QtDBus: Calling a method with an Array of Strings signature with Python 3
Phil Thompson
phil at riverbankcomputing.com
Mon Dec 5 08:44:00 GMT 2011
On Sun, 04 Dec 2011 20:17:52 +0000, Chris Mayo
<cjmayo at users.sourceforge.net> wrote:
> With Python 2 I can do (where /dev/sr0 is a cdrom):
>
> bus = QtDBus.QDBusConnection.systemBus()
> device_iface = QtDBus.QDBusInterface('org.freedesktop.UDisks',
> '/org/freedesktop/UDisks/devices/sr0', 'org.freedesktop.UDisks.Device',
> bus)
> reply = device_iface.call("DriveEject", QStringList())
>
>
> But with Python 3 this won't work because of QStringList. If I modify it
> with:
>
> reply = device_iface.call("DriveEject", ["", ])
> print(reply.errorMessage())
>
> I get:
>
> Method "DriveEject" with signature "av" on interface
> "org.freedesktop.UDisks.Device" doesn't exist
>
> Chris
>
> PyQt-x11-gpl-snapshot-4.9-65564eb2fcf4
Try this...
arg = QDBusArgument()
arg.beginArray(QMetaType.QString)
arg.add("")
arg.endArray()
...and pass arg to call().
If that works I'll change QDBusArgument so that you can do...
call("DeviceEject", QDBusArgument([""], QMetaType.QStringList))
Phil
More information about the PyQt
mailing list