[PyQt] loading arbitrary kparts

Marcos Dione mdione at grulic.org.ar
Tue Oct 9 00:16:06 BST 2007


On Mon, Oct 08, 2007 at 09:38:21AM -0700, Jim Bublitz wrote:
> I'm using KIO.NetAccess.mimeType in a PyKDE4 application and it works fine 
> there - there could be some difference to the PyKDE 3 version. It would help 
> if you'd provide a short example program that exhibits the problem so I can 
> see if there's some other problem in the surrounding code triggering the 
> mimetype problem.

    try this:

--- begin code ---
from kdecore import *
from kio import *
from kparts import *
import sys

KCmdLineArgs.init (sys.argv, sys.argv[0], "testmime", "", "")
args= KCmdLineArgs.parsedArgs ()
app= KApplication ()
#     app.exec_loop ()

for u in ('http://api.kde.org/3.5-api/kdelibs-apidocs/kde_gear_64.png', 'http://jbailey.livejournal.com/41057.html'):
    url= KURL (u)
        
    mime= KMimeType.findByURL(url, 0, False, False)
    mimeType= mime.name ()
    if mimeType=='application/octet-stream':
        print "trying harder"
        mineType= KIO.NetAccess.mimetype (url, None);
				    
    print mimeType
---  end code  ---

> You could also try to use KRun, just as a *test* to see if it will pick up the 
> mime type correctly (it launches an application though - doesn't load a 
> part).

    will try.

> >     but I can't find the ComponentFactory namespace in pykde, and I'm
> > not sure it would fix my problem. so, what am I missing?
> 
> ComponentFactory consists of only templates, so there isn't any code to wrap, 
> unless the templates are instantiated via a typedef somewhere else in 
> kdelibs. KParts.Factory is implemented though.

    I didn't get this whole. can you explain a little more?


More information about the PyQt mailing list