[PyQt] [pykde3] Loading arbitrary kparts

jbd jbdenis at dental-on-line.fr
Fri Feb 22 10:06:27 GMT 2008


Hello,

I'm saw the following post :
http://www.riverbankcomputing.com/pipermail/pyqt/2007-October/017367.html

I'm sorry to post for the same subject again, but I still don't know how
to load an arbitraty kparts depending on the URL.

=======
import sys
from kdecore import KCmdLineArgs, KApplication, KLibLoader
from kio import KTrader
from qt import QLabel
from kparts import KParts

KCmdLineArgs.init(sys.argv, "test", "test", "test")
app = KApplication()

trader = KTrader()
offers = trader.query("text/html", "'KParts/ReadOnlyPart' in ServiceTypes")

loader  = KLibLoader()
factory = loader.factory(offers[0].library().ascii())
part = factory.create(None, offers[0].name().ascii(),
"KParts::ReadOnlyPart")

# The type of part is QObject

button = QLabel(str(part), None)
button.show()
app.setMainWidget(button)

sys.exit(app.exec_loop())
======

The type of part is QObject, so i can't do anything with it.

I'm doing things wrong here. What is the python way to achieve arbitrary
KPart ?

Regards.



More information about the PyQt mailing list