Eclipse does not autocomplete function arguments for PyQt4 - python

Eclipse will not autocomplete the function parameters in the PyDev perspective for PyQt4. All other aspects of the auto complete are working.
I am able to type x = QDia and Eclipse lists of all classes/variables starting with QDia. However, I am in dire need for all having Eclipse show all of the constructors and function arguments.
I should mention that this feature does work for other Python modules. Something is different with PyQt4 and I can't figure it out.
System Details: RHEL5/RHEL6, Eclipse 4.3.1 (Kepler), PyDev 3.3 (I think), Qt 4.6

Unfortunately the way that PyQt is wrapped doesn't expose that information (PyDev mostly imports the module in a shell, does a dir() and interprets the docstring to get information to show on to the user, but PyQt4 doesn't have that info -- and I'm not sure there's any automated way to get it).
So, usually when coding on qt I use the Qt Assistant a lot to get that kind of info... (or sometimes browse it on the web)

Related

Autocomplete for Automation objects in VS Code and Python

I have the Python Extensions for Windows installed. Within the PythonWin IDE I can get autocomplete on Automation objects (specifically, objects created with win32com.client.Dispatch):
How can I get the same autocomplete in VS Code?
I am using the Microsoft Python extension.
The Python Windows Extensions has a tool called COM Makepy, which apparently generates Python representations of Automation objects, but I can't figure out how to use it.
Update
Apparently, the Microsoft Python extension uses Jedi for autocompletion.
I've filed an issue on the extension project on Github.
Note that in general I have Intellisense in Python; it's only the Intellisense on Automation objects that I am missing.
Review
I have confirmed your problem in VSCode, although it may be possible IntelliSense works fine. Note Ctrl+Space invokes suggestions for a pre-defined variable:
However, there does not appear to be public attributes available for win32com.client by default. This may be why IntelliSense does not appear to work.
Test
Having installed win32com for Python 3.6, I have confirmed the following code in Jupyter notebook, IPython console and the native Python REPL:
import win32com.client
app = win32com.client.Dispatch("Word.Application")
len(dir(app))
# 55
[x for x in dir(app) if not x.startswith("_")]
# []
This issue of hidden attributes is not a new. Please confirm this test in another environment/IDE. It may be your environment or particular version of PythonWin pre-loads certain variables in the global namespace.
Verify the following:
The Python extension is installed
A Python interpreter is selected
A Python file is selected; this starts up the Python server
References
Post by the extension's creator for troubleshooting autocompletion issues.
Thread on how autocompletion works via PyScriptor
I don't think that the example you show with PythonWin is easily reproducible in VS Code. The quick start guide of win32com itself (cited below) says, its only possible with a COM browser or the documentation of the product (Word in this case). The latter one is unlikely, so PythonWin is probably using a COM browser to find the properties. And because PythonWin and win32com come in the same package, its not that unlikely that PythonWin has a COM browser built in.
How do I know which methods and properties are available?
Good question. This is hard! You need to use the documentation with the
products, or possibly a COM browser. Note however that COM browsers
typically rely on these objects registering themselves in certain
ways, and many objects to not do this. You are just expected to know.
If you wanted the same functionality from the VS Code plugin a COM browser would have to be implemented into Jedi (IntelliSense of the VS Code plugin).
Edit: I found this suggestion, on how a auto-complete, that can find these hidden attributes, could be done:
These wrappers do various things that make static analysis difficult,
unless we were to special case them. The general solution for such
cases is to run to a breakpoint and work in the live runtime state.
The auto-completer should then include the complete list of symbols
because it inspects the runtime.
The conversation is from an mailing list of the python IDE wingwide. Here you can see, that they implemented the above mentioned approach:
I think your problem is related to defining Python interpreter.
Choose proper Python interpreter by executing python interpreter command in VS Code command palette by pressing f1 or ctrl+shift+p key.

Get Netbeans to recognize Python methods

I was just wondering if there was a way to get Python (in Netbeans) to recognize the methods that I write in a class. For example when I do self.method() I just want Netbeans to recognize it's a method in the class I am currently in. Does Netbeans 8.0 Python IDE not support that right now, or is there something I can do to make Netbeans recognize them?
There are several plugins available in netbeans plugin portal from which you can download and install them to your netbeans. Here is a link: http://plugins.netbeans.org/plugin/61688/python
These will support minimal editing, building, debugging.
These are also available in Netbeans plugin menu. You can also download it from there!

How is Python interpreted with wxPython, PyQt, PySide or Tkinter?

I got curious and have been reading about GUI development using Python for the past hour. After reading documentation of wxPython, PyQt, Nokia's Python bindings for Qt along with Tkinter a question came to my mind.
When I create a console application with Python, it runs using the embedded Python interpreter (which I assume is usually if not always in my case cpython).
So I was wondering, what's the case with these "widget toolkits"?
How is the Python code executed and what interprets it (or executed it)?
Which part of my Python code is interpreted using the Python
interpreter?
Or does the Python code get lexically analysed and then parsed by the widget's
toolkit which then interpretes and executes (or compile during build)?
I am looking forward to understanding what goes on in the background in comparison with Python applications' (a bit simpler to understand) interpretation with the Python interpreter.
Thank you.
PS. To whichever genius thinks that this question deserves to be closed;
A lot of people wonder the internals of external libraries and systems. Especially those which are not as simple as they look. There currently is not any question explaining this on SE.
This is just a really generalized high-level explanation about "GUI toolkits"...
Lets say you decide to use the Qt framework. This framework is written in C++. There are two different python bindings that can be used, allowing one to write a GUI application in python against the same API as the C++ version.
The python bindings provide a wrapping around calls into the C++ code. PyQt4 for instance uses sip, while PySide uses shiboken. These are just language wrapping tools that take specifications for how to map between the C++ objects and their intended python interface.
Ok, so you start using PyQt... All of the code you write has to pass through the python interpreter. Some of it may be pure python. Some of it will call into C++ libs to create things like your widgets. In Qt, there will be a C++ pointer associated with the python instance counterpart.
It is the C++ layer that is then communicating with the window manager of your platform, to turn platform-independent API calls into something platform specific, like how to exactly draw a button or menu.
Whether you create a console only or GUI based python application, it all goes through the python interpreter to interpret your python code. Something must interpret the python language for you.

PySide methods signature in Eclipse/WingIDE/PyCharm?

Is there any way to have the signature of the methods of PySide classes in Eclipse, WingIDE, PyCharm or any Python IDE?
Currently, it auto-completes the classes and method names, but not the parameters of the methods.
All functions are detected as functions without parameters.
I know it's a Python binding of a C++ framework so it's not that easy but is there any way to have the method signatures directly in an IDE?
I use PyDev (Eclipse plugin) and it works like a charm, also with function signatures.
EDIT:
I'm not 100% sure with C++ extensions, but it should work well if there's a Python wrapper for it. With pure C++ extensions there might be problems, but actually I haven't tried it.
Try running help(some-qt-method) in a Python console, what do you see? Exactly.
As far as I know, the only IDE that handles PyQt / PySide in depth is Eric, and only because it explicitly compiles signatures in its own format for autocompletion.

Autocompletion not working with PyQT4 and PyKDE4 in most of the IDEs

I am trying to develop a plasmoid using python. I have tried eclipse with pydev, vim with pythoncomplete, PIDA and also Komodo, but none of them could give me autocmpletion for method names or members for the classes belonging to PyQT4 or PyKDE4. I added the folders in /usr/share/pyshare in the PYTHONPATH list for the IDEs.
Do I need to do something else ?
There is a number of ways to do it, PyQt4 provides enough information about method names for any object inspecting IDE:
>>> from PyQt4 import QtGui
>>> dir(QtGui.QToolBox)
['Box', ... contextMenuPolicy', 'count', 'create', 'currentChanged'...]
All those functions are built-in. This means that you have to push some IDEs slightly to notice them. Be aware that there are no docstrings in compiled PyQt and methods have a funny signature.
Other possibility is using QScintilla2 and.api file generated during PyQt4 build process. Eric4 IDE is prepared exactly for that.
<shameless-plug>
You can also try Komodo IDE/Komodo Edit and a CIX file (download here) that I hacked together not so long ago:
and,
Edit: Installation instructions for Komodo 5:
Edit -> Preferences -> Code Intelligence
Add an API Catalog...
Select CIX file, press Open
There is no point 4.
</shameless-plug>
What about WingIDE, It's not free but it's Feature List has "auto-completion for wxPython, PyGTK, and PyQt "

Categories

Resources