[PyKDE] QApplication without GUI

Torsten Marek shlomme at gmx.net
Sat Nov 12 09:32:43 GMT 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Paul F. Kunz schrieb:
> Is there a reason that 
> 
>    QApplication ( int& argc, char ** argv, bool )
> 
> is not exposed to Python in PyQt.   We could use it.
> 

Hi,

if you are building PyQt for yourself, it takes only moderate effort to add it:
(I'm judging from the .sip files only, maybe Phil had a hidden agenda when he
choose not to wrap this function).

in qt/qapplication.sip, add the following code to QApplication:

QApplication(SIP_PYLIST,bool) /PostHook=__pyQtQAppHook__/ [(int &,char**,bool)];
%MethodCode
    // The Python interface is a list of argument strings that is
    // modified.

    int argc;
    char **argv;

    // Convert the list.
    if ((argv = pyArgvToC(a0,&argc)) == NULL)
        sipIsErr = 1;
    else
    {
        // Create it now the arguments are right.
        int nargc = argc;

        Py_BEGIN_ALLOW_THREADS
        sipCpp = new sipQApplication(nargc,argv,a1);
        Py_END_ALLOW_THREADS

        // Now modify the original list.
        updatePyArgv(a0,argc,argv);
    }
%End


I've not tested this code and only used my intuitions based on earlier work with
sip, so if any errors occur, please check back.

best regards

Torsten
- --
Torsten Marek <shlomme at gmx.net>
ID: A244C858 -- FP: 1902 0002 5DFC 856B F146  894C 7CC5 451E A244 C858
Keyserver: subkeys.pgp.net

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDdba7fMVFHqJEyFgRAvbPAJ0d2ciGbTJUPWDsvIYpMUbMEWubSQCfZPKe
q4yts0GaEEqEg+p6MwTH+DQ=
=pgdp
-----END PGP SIGNATURE-----




More information about the PyQt mailing list