By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,422 Members | 1,282 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,422 IT Pros & Developers. It's quick & easy.

PyQt with embedded python in Qt App

P: n/a
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?

Nov 1 '07 #1
Share this Question
Share on Google+
9 Replies


P: n/a
On Thursday 01 November 2007, cgrebeld wrote:
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
Nov 1 '07 #2

P: n/a
Thursday 01 of November 2007 15:13:55 Phil Thompson napisał(a):
On Thursday 01 November 2007, cgrebeld wrote:
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()
What I can do with this pointer?
It is possible to add window to application ?
It is possible to connect to application signals?

Bart.
Nov 1 '07 #3

P: n/a
On Thursday 01 November 2007, Bart. wrote:
Thursday 01 of November 2007 15:13:55 Phil Thompson napisał(a):
On Thursday 01 November 2007, cgrebeld wrote:
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()

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
Nov 1 '07 #4

P: n/a
Thursday 01 of November 2007 23:32:02 Phil Thompson napisał(a):
On Thursday 01 November 2007, Bart. wrote:
Thursday 01 of November 2007 15:13:55 Phil Thompson napisał(a):
On Thursday 01 November 2007, cgrebeld wrote:
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()
What I can do with this pointer?

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?

Nov 1 '07 #5

P: n/a
Bart. schrieb:
Thursday 01 of November 2007 23:32:02 Phil Thompson napisał(a):
>On Thursday 01 November 2007, Bart. wrote:
>>Thursday 01 of November 2007 15:13:55 Phil Thompson napisał(a):
On Thursday 01 November 2007, cgrebeld wrote:
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()
What I can do with this pointer?
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?
You don't pass it, you _retrieve_ it in the embedded interpreter by
invoking the code given to you.

Diez
Nov 2 '07 #6

P: n/a
Friday 02 of November 2007 01:06:58 Diez B. Roggisch 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.
Know any example, please?
For better understand this :) I wan't add scripting to one application wrotten
with Qt.

Bart.
Nov 2 '07 #7

P: n/a
On Nov 2, 8:03 am, "Bart." <uz...@o2.plwrote:
Friday 02 of November 2007 01:06:58 Diez B. Roggisch 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.

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

Nov 2 '07 #8

P: n/a
Friday 02 of November 2007 12:21:06 BlueBird napisał(a):
On Nov 2, 8:03 am, "Bart." <uz...@o2.plwrote:
Friday 02 of November 2007 01:06:58 Diez B. Roggisch 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.
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 ?
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.
Nov 2 '07 #9

P: n/a
On Nov 2, 7:59 am, "Bart." <uz...@o2.plwrote:
Friday 02 of November 2007 12:21:06 BlueBird napisa (a):
On Nov 2, 8:03 am, "Bart." <uz...@o2.plwrote:
Friday 02 of November 2007 01:06:58 Diez B. Roggisch 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.
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 ?

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

Nov 3 '07 #10

This discussion thread is closed

Replies have been disabled for this discussion.