Proper auto-complete IDE

Return to General Discussion

Proper auto-complete IDE

Postby Hoffmann » Fri Feb 03, 2012 10:25 am

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:
http://www.panda3d.org/forums/viewtopic.php?t=10659
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.
Hoffmann
 
Posts: 43
Joined: Thu Feb 24, 2011 12:05 pm

Postby drwr » Fri Feb 03, 2012 1:37 pm

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
drwr
 
Posts: 11425
Joined: Fri Feb 13, 2004 12:42 pm
Location: Glendale, CA

Postby Hoffmann » Fri Feb 03, 2012 2:15 pm

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).
Hoffmann
 
Posts: 43
Joined: Thu Feb 24, 2011 12:05 pm

Postby drwr » Fri Feb 03, 2012 3:15 pm

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
drwr
 
Posts: 11425
Joined: Fri Feb 13, 2004 12:42 pm
Location: Glendale, CA

Postby Hoffmann » Fri Feb 03, 2012 3:29 pm

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).
Last edited by Hoffmann on Fri Feb 03, 2012 5:49 pm, edited 1 time in total.
Hoffmann
 
Posts: 43
Joined: Thu Feb 24, 2011 12:05 pm

Postby drwr » Fri Feb 03, 2012 5:25 pm

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
drwr
 
Posts: 11425
Joined: Fri Feb 13, 2004 12:42 pm
Location: Glendale, CA

Postby Hoffmann » Fri Feb 03, 2012 5:44 pm

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
Hoffmann
 
Posts: 43
Joined: Thu Feb 24, 2011 12:05 pm

Postby drwr » Fri Feb 03, 2012 6:42 pm

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. :)

David
drwr
 
Posts: 11425
Joined: Fri Feb 13, 2004 12:42 pm
Location: Glendale, CA

Postby rdb » Sat Feb 04, 2012 3:48 am

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.
rdb
 
Posts: 9742
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby ynjh_jo » Sun Feb 05, 2012 4:59 am

Image
Last edited by ynjh_jo on Tue Oct 29, 2013 5:13 am, edited 1 time in total.
http://ynjh.tk
Intel P4Prescott 2.8GHz HT | ATI Radeon HD4670 1GB GDDR3
User avatar
ynjh_jo
 
Posts: 1795
Joined: Tue Apr 18, 2006 12:41 am
Location: Malang, Indonesia

Postby Hoffmann » Sun Feb 05, 2012 6:28 pm

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.
Hoffmann
 
Posts: 43
Joined: Thu Feb 24, 2011 12:05 pm

Postby ynjh_jo » Mon Feb 06, 2012 6:49 am

Hoffmann wrote:1: Change the port used in IDEFileSrv.py to something lower than 65335

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

Hoffmann wrote:2: Create a IDE_pref.png in the /images/ folder

it's been there since v0.5.

Hoffmann wrote:3: Create a logTextOverScene-win.png in the /images/ folder

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

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

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.

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

Actually, completing "a." offers Texture attributes, but "self.a." doesn't.
I'll deal with it later.

Hoffmann wrote: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

that's a minor bug introduced when I added panda3d.* import completion support yesterday.
The fix is simple (IDE.py line 6652) :
Code: Select all
if hasattr(imported,'__module__') and sys.modules[imported.__module__]==panda3d:

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

Hoffmann wrote:I also can't get the documentation or I don't know how to.

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).
Image
Click "list" button to list all keymap into a new text file, so you can print it if needed.

Hoffmann wrote:I can't figure some stuff out like how to open a file after getting into the edit mode.

idem

Hoffmann wrote: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).

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.

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

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

I've updated the code.
Last edited by ynjh_jo on Sun Oct 27, 2013 4:14 am, edited 1 time in total.
http://ynjh.tk
Intel P4Prescott 2.8GHz HT | ATI Radeon HD4670 1GB GDDR3
User avatar
ynjh_jo
 
Posts: 1795
Joined: Tue Apr 18, 2006 12:41 am
Location: Malang, Indonesia

Postby Nique » Sat Apr 21, 2012 6:06 am

Watch this post for an incredible experience.

Image

Image
Nique
 
Posts: 12
Joined: Sat Jan 23, 2010 8:27 am


Return to General Discussion

Who is online

Users browsing this forum: Google [Bot] and 1 guest