PyQt with embedded python in Qt App

C

cgrebeld

Is it possible for a Qt C++ application, which embeds the python
interpreter, to import and use PyQt? There can be only one
QApplication, which is created in the C++ side, so how would I use
that from the python side?
 
P

Phil Thompson

Is it possible for a Qt C++ application, which embeds the python
interpreter, to import and use PyQt? There can be only one
QApplication, which is created in the C++ side, so how would I use
that from the python side?

QtGui.QApplication.instance()

Phil
 
B

Bart.

Thursday 01 of November 2007 15:13:55 Phil Thompson napisał(a):
QtGui.QApplication.instance()

What I can do with this pointer?
It is possible to add window to application ?
It is possible to connect to application signals?

Bart.
 
P

Phil Thompson

Thursday 01 of November 2007 15:13:55 Phil Thompson napisał(a):

What I can do with this pointer?

It's not a pointer, it's a Python object that wraps the C++ pointer.
It is possible to add window to application ?
Yes.

It is possible to connect to application signals?

Yes.

Phil
 
B

Bart.

Thursday 01 of November 2007 23:32:02 Phil Thompson napisał(a):
It's not a pointer, it's a Python object that wraps the C++ pointer.

So how to pass this object into embeded python interpreter (executed script)?
Anyone know any example?
 
D

Diez B. Roggisch

Bart. said:
Thursday 01 of November 2007 23:32:02 Phil Thompson napisał(a):

So how to pass this object into embeded python interpreter (executed script)?
Anyone know any example?

You don't pass it, you _retrieve_ it in the embedded interpreter by
invoking the code given to you.

Diez
 
B

Bart.

Friday 02 of November 2007 01:06:58 Diez B. Roggisch napisał(a):
You don't pass it, you _retrieve_ it in the embedded interpreter by
invoking the code given to you.

Know any example, please?
For better understand this :) I wan't add scripting to one application wrotten
with Qt.

Bart.
 
B

BlueBird

Friday 02 of November 2007 01:06:58 Diez B. Roggisch napisa (a):



Know any example, please?
For better understand this :) I wan't add scripting to one application wrotten
with Qt.

So, you have Qt/C++ application which you want to script through
python.

But why do you need PyQt for ? If you design a script api in python
and bind it using whatever binding technology (manually, boost, sip,
pyrex, ...), you should not need to use PyQt.

Or do you mean to use PyQt as the binding technology ?

Philippe
 
B

Bart.

Friday 02 of November 2007 12:21:06 BlueBird napisał(a):
So, you have Qt/C++ application which you want to script through
python.

But why do you need PyQt for ? If you design a script api in python
and bind it using whatever binding technology (manually, boost, sip,
pyrex, ...), you should not need to use PyQt.

Or do you mean to use PyQt as the binding technology ?

Or I want to use PyQt in scripts to have similar gui for plugins written in
python
Or I want to extend application by scripts with PyQt.

Or better question:
How to easy add python scripting in Qt application and have almast all objects
of app accesible in scripts?
Kross could be good solution?

I realy need some examples :(
I'm looking for solutions.

You are proffesional programmers so that is why write on this list :)

Thanks for Your answars.

Bart.
 
C

cgrebeld

Friday 02 of November 2007 12:21:06 BlueBird napisa (a):







Or I want to use PyQt in scripts to have similar gui for plugins written in
python
Or I want to extend application by scripts with PyQt.

Or better question:
How to easy add python scripting in Qt application and have almast all objects
of app accesible in scripts?
Kross could be good solution?

I realy need some examples :(
I'm looking for solutions.

You are proffesional programmers so that is why write on this list :)

Thanks for Your answars.

Bart.

Here is an example:
http://python.pastebin.com/m18c67b3a
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top