Active Topics

 


Reply
Thread Tools
Posts: 125 | Thanked: 77 times | Joined on Oct 2009 @ Sao Paulo, Brazil
#1
Is there a way to use LibIconIc in an Qt Python program?

This code runs ok:
Code:
#!/usr/bin/python2.5 
import conic
import gobject, dbus
from dbus.mainloop.glib import DBusGMainLoop

def connection_cb(connection, event):
    print "connection_cb(%s, %s)" % (connection, event)

    status = event.get_status()
    error = event.get_error()
    iap_id = event.get_iap_id()
    bearer = event.get_bearer_type()

    if status == conic.STATUS_CONNECTED:
        print "(CONNECTED (%s, %s, %i, %i)" % (iap_id, bearer, status, error)
    elif status == conic.STATUS_DISCONNECTED:
        print "(DISCONNECTED (%s, %s, %i, %i)" % (iap_id, bearer, status,error)
    elif status == conic.STATUS_DISCONNECTING:
        print "(DISCONNECTING (%s, %s, %i, %i)" % (iap_id, bearer, status,error)


if __name__ == "__main__":
    DBusGMainLoop(set_as_default=True)
    bus = dbus.SystemBus()
    connection = conic.Connection()
    connection.set_property("automatic-connection-events", True)
    connection.connect("connection-event", connection_cb)
    gobject.MainLoop().run()
But if I change it for Qt (using DbusQtMainLoop and QCoreApplication instead of DbusGMainLoop and gobject), I receive a segmentation fault.

Last edited by jaguilar; 2010-09-21 at 00:39. Reason: added RESOLVED to the title
 
Posts: 3,428 | Thanked: 2,856 times | Joined on Jul 2008
#2
My guess is you need to keep:

Code:
    loop = gobject.MainLoop()
    gobject.threads_init()
    context = loop.get_context()
In your app. I have the same problem with MAFW and gstreamer bindings. Because they are applications revolving around gobject you need a gobject loop or you'll segfault. I modified your code above using QCoreApplication and DbusQtMainLoop as you suggested and got it to work including the code above in the "__main__" method. Adding those three lines you start a gobject MainLoop as a thread in the background so it doesn't interfere with your app, but it's obviously kind of ugly (but necessary) having to import gobject in a QT app.
__________________
If I've helped you or you use any of my packages feel free to help me out.
-----------------------------------------------------------------------------------
Maintaining:
pyRadio - Pandora Radio on your N900, N810 or N800!
 

The Following User Says Thank You to fatalsaint For This Useful Post:
Posts: 125 | Thanked: 77 times | Joined on Oct 2009 @ Sao Paulo, Brazil
#3
It worked like a charm....despite the fact that it's a ugly workaround!
 
Posts: 6 | Thanked: 3 times | Joined on May 2010
#4
Another GStreamer + PyQt hint can be found here:

http://www.diotavelli.net/PyQtWiki/U...amer_with_PyQt

It would be good to collect these interoperability solutions somewhere. :-)
 
Reply


 
Forum Jump


All times are GMT. The time now is 00:15.