PyQT4

939 views
Skip to first unread message

Marsouin

unread,
Nov 12, 2010, 10:05:45 AM11/12/10
to PyScripter
Hello,

I just discover PyScripter and its a very wonderfull tool, fast with
very good features. Love It !

The only thing that is missing is the way to have code completion with
pyQt4 module.

Does anyone know how to have it?

I would really like this see it in PyScripter.

Thanks

Marsouin

PyScripter

unread,
Nov 12, 2010, 1:45:08 PM11/12/10
to PyScripter
It takes a bit of effort.

a) Go to Tools, Options, IDE Options, Special packages and add PyQt4
to the list
b) Tools, Edit Startup Scripts. Add to the end of pyscripter_init.py
the following:
from PyQt4 import QtCore, QtGui
c) Save and restart PyScripter, go to a new editor and type
from PyQt4 import QtCore, QtGui
QtGui.

and voila. Code completion is available.

Explanation:
Special packages are imported to the namespace of the internal
interpreter to improve code completion in the editor.
The second step is required because QtCore etc are not part of the
namespace of PyQt4 after the initial import i.e. If you open a python
shell and you do
>>> import PyQt4
>>> dir(PyQt4)

you do not see the QtCore etc. So in step b we are pre-importing PyQt4
and QtGui, QtCore in the internal interpreter which is used for code
completion of special packages. You could have done this manually by
switching to the internal interpreter, importing the units, switch
back to the remote interpreter to carry on working. But you would
have to do this every time you start PyScripter.

Make sure you use the remote interpreter (Run, Python Engine, Remote)
for running PyQt4 scripts and reinitialize before each run. (this is
the default),

Marsouin

unread,
Nov 12, 2010, 3:41:31 PM11/12/10
to PyScripter
I just want to say, you are a genius !

Its works perfectly, many thanks to take time for all those precious
explanations.

One last question, did you planed to integrate shortcuts to tool such
as QtDesigner for designing UI ?

Bravo et merci beaucoup !

Marsouin

PyScripter

unread,
Nov 12, 2010, 4:30:30 PM11/12/10
to PyScripter
It should be easy to create such integration using External Tools.
Look it up in the help file (It is under the heading "Extending the
IDE") and see the example External Tools provided (see also the help
topic on parameters). You can even place External Tools on
Toolbars.
If you come up with something useful generally post a message here.
Reply all
Reply to author
Forward
0 new messages