Proper auto-complete IDE


#1

Is there ANY IDE out there that actually provides full code auto-complete for panda3d classes?
Most IDEs can’t get panda3d.core classes (or any other panda3d.* class) or pandac.PandaModules, is there any other way to properly import those so my IDE can see them?

I tried it all, PyDev, Netbeans, Komodo, PYPE, SPE. I tried searching the forums (a lot) but with no luck.

Bonus points if it also brings the documentation when using the code-complete.

Also why all the python module importing hacking present on the panda3d.py file? Couldn’t you just make one file per module? There aren’t that many modules imported this way.

This seriously hinders learning panda3d. Beginners have to rely on the autocomplete and documentation inside the IDE to learn. I get that all the python is just a wrapper over the C++ code, but why couldn’t you just make a proper wrapper for all the classes and functions? Even if it’s just a place-holder for the IDE.

So far the best I got was using PyDev with a bunch of hacking described here:
[Panda3D Eclipse / Pydev setup)
But base, render, any object of a class returned by a panda3d.core module doesn’t work like:

model= self.loader.loadModel(“models/environment”)
model. # <- nothing on auto-complete

Also no documentation for panda3d.core classes using this hack.


Only the last model's animation is active
#2

Yeah, it’s a bigger issue than that. It’s not the magic renaming in panda3d.py; even if it just imported the dll’s directly, the problem is that they’re dll’s (or pyd’s) and not pure Python modules. I don’t know any IDE’s that know how to look at the symbols inside a dll.

And symbols like base are defined in the builtins module, which again IDE’s have trouble searching.

I don’t know any way around these issues. It’s kind of a fundamental problem with Python itself.

David


#3

Is there any way to make place-holders with the classes/methods names and documentation? Pydev at least has a way to get that info. It would probably work with other IDEs too.

For me the best thing about the Java platform is how good the auto-complete works in Eclipse/Netbeans and how well documented everything is. I know this is harder dynamic typed languages, but Aptana works rather well with Javascript and python is theoretically simpler (no prototype object orientation).


#4

That sounds possible; but it sounds like a fair amount of work. Would you like to be the one to take charge of solving this problem?

David


#5

Can’t this be automated during the process to generate the Python Reference present on the website? How is it generated? The documentation is all there, although it’s C++ only for most classes in panda3d.*.

One could argue that the C++ documentation is more useful since it also shows what type your data needs to be (or will eventually be converted to).


#6

Right, that’s the way I would do it, too. Hook into the same interfaces currently used to generate the web documentation.

I’m not 100% sure which interfaces the doxygen script is using. I think it’s calling into the interrogate interface (as described in interrogate_interface.h in the Panda3D source code), but it might also just be querying the Python docstrings. Either approach would work.

David


#7

It could be used to generate a .pypredef, but that is Pydev exclusive. Any idea on how to make it work on any IDE? I mean, if you place the stubs on the pythonpath it will probably conflict with the actual panda3d.* classes


#8

I don’t know much about these various IDE’s. I guess whoever figures out the right way to do this will need to start with some Googling. :slight_smile:

David


#9

The doxygen script can be found in direct/src/directscripts/extract_docs.py, it uses the interrogate interface available through panda3d.dtoolconfig. You should be able to adapt that script to generate one of those custom files for your IDE.


#10


#11

Hey ynjh_jo, I had tried to run your IDE before making this post but it was freezing on me after selecting a file to open. I decided to give it another try today and I managed to get it working with the following changes:

1: Change the port used in IDEFileSrv.py to something lower than 65335
2: Create a IDE_pref.png in the /images/ folder
3: Create a logTextOverScene-win.png in the /images/ folder

I have to say it’s impressive, but the auto complete is not working out of me. It get method names and parameters stubs (you call them “call tips”) but only if I declare them right away like:
a= Texture()
a. #works

if the object is returned from a method it doesn’t work:
a= base.camNode.getDisplayRegion(0)
a. #nothing here

or if you try to place the object inside another object:
self.a= Texture()
a. #nothing

from pandac.PandaModules import #if you try to use ctrl+space here the program freezes for some 30s then I get an error in IDE.py

I also can’t get the documentation or I don’t know how to.

I can’t figure some stuff out like how to open a file after getting into the edit mode. I don’t know how to display the stdout of my program (ie if I put a print statement on a task that runs each frame I don’t know where to find the results).

From what I have seen I have to say that I will stick with Pydev for now. I might use it later for debugging (not needing to reload everything for each small change is pretty neat).

Unfortunately I don’t have nearly enough python or panda experience to help you out with your project. But I wish you luck.


#12

yeah I was lazy to change it.
Do you also use python 2.7 or later ?

it’s been there since v0.5.

it’s auto-generated if not exist, so there’s no need to do it manually.

My IDE already tries its best to determine the return value of the method by actually running it WITHOUT any arguments, in this case “a= base.camNode.getDisplayRegion()”, which of course fails since the method wants index argument, so the return value is not available.
I can make it executed WITH whatever arguments you specify, with the same doubt that it’ll succeed, if any of the argument is only available at runtime, such as passing a variable instead of constant value.

Actually, completing “a.” offers Texture attributes, but “self.a.” doesn’t.
I’ll deal with it later.

that’s a minor bug introduced when I added panda3d.* import completion support yesterday.
The fix is simple (IDE.py line 6652) :

if hasattr(imported,'__module__') and sys.modules[imported.__module__]==panda3d:

But really, 30 secs ? It’s < 1 sec here.

Do you mean the second panel below ?
By default, during completion, F1 toggles it.
Obviously you haven’t read the key map in Preferences window (click the icon at the lower right corner to open it).

Click “list” button to list all keymap into a new text file, so you can print it if needed.

idem

idem.
It’s called “log” in Preferences. Once it’s active, it’ll also be displayed over the scene, if you jump to your scene.

It’s OK, you’ve given enough feedback already.
Thanks !

I’ve updated the code.


#13

Watch this post for an incredible experience.