Aw, come-on QtDBus, just work already
Written by
on
in
Snaking,
Tuxedo.
[Update] I got it working by going down to the "connection" level and registering the callback there. The code below is updated with the working version... as of now I've got some basic "voice coding" possible, but lots more to do to make it practical and useful.
Plowing ahead with integrating Listener into Eric (my primary IDE). That seemed to be going swimmingly, got a new plugin created, set it up to notice new editors, disconnect old ones and (in theory) process new results by inserting the recognized and interpreted text at the current position. Then I tried to hook it into my signals from Listener... and ran smack into PyQt's QtDbus... documentation for which is a bit... lacking. I can see from QDBusViewer that I'm actually sending the signals, but I can't seem to get the signals registered from QtDbus inside Eric (I don't want to use the python-dbus bindings because then I'd have to rework Eric's mainloop).
The relevant bits look like this:
LISTENER_SERVICE = 'com.vrplumber.listener' LISTENER_PATH = '/com/vrplumber/listener' RESULTS_INTERFACE = '%s.results'%(LISTENER_SERVICE,) FINAL_SIGNAL = 'send_final' CONNECTED = False def dbus_connection(self): if not self.CONNECTED: _session_bus = QtDBus.QDBusConnection.sessionBus() try: self._listener_object = QtDBus.QDBusInterface( self.LISTENER_SERVICE, self.LISTENER_PATH, self.RESULTS_INTERFACE, _session_bus ) if self._listener_object.isValid(): self._listener_object.connection().connect( self.LISTENER_SERVICE, self.LISTENER_PATH, self.RESULTS_INTERFACE, self.FINAL_SIGNAL, self.on_final_dictation ) else: log.error('Unable to retrieve listener interface: %s', self._listener_object.lastError() ) except Exception as err: log.error( "Unable to get a connection to listener: %s", err) else: self.CONNECTED = True
I'm sure it is some simple, obvious thing, but I haven't figured out what that simple, obvious thing is. I can see (by setting QDBUS_DEBUG=1) that the .connect() call does *not* produce any DBUS traffic, so I have to assume that's the problem, but I don't see what I *should* do to get the messages flowing properly, the docs just say "use QObject::connect" to connect to the signals.
It is to sigh.
Pingbacks
Pingbacks are closed.
Comments
Comments are closed.