Code complete in Pydev and Eclipse with Panda3D

Return to General Discussion

Code complete in Pydev and Eclipse with Panda3D

Postby Edwood Grant » Fri Jul 04, 2008 10:02 pm

Greetings everyone

It's been a while since I've touched Panda3D so I'm starting again to get the grip of it. Lets see if I can get up to it again :P

Not sure if this has been posted already... but there it goes anyway...

Ok I've been tinkering with Pydev searching for a way to enable code completition, and I've found this might work for many people and prove to be useful for learning panda:

1. Go to Window -> Preferences
2. Head to Pydev -> Interpreter - Python

I suppose you added the ppython installation from panda, (not sure if it works with other python installations... but with the ppython, python, or wpython from panda works fine)

3. In the python path window, you have to add the main Panda3D installation folder (e.g c:\panda.1.x.x) and the bin diretory (e.g c:\panda.1.x.x\bin for example) as new folders, in addition to the other panda folders

4. Go to the "forced builtin libs" window, click on "New..." and add the keyword direct, repeat the process but instead add the pandac keyword.

5. Click on Apply and then and after the code analysis click Ok... as far as I know this enables auto complete with panda...

However at this point it won't recognize all panda libraries, (no idea why, it will recognize some like gui or fsm), but you can fix it if you copy all the folders that are in your direct\scr folder (e.g c:\panda.1.x.x.\direct\src) to the direct folder (c:\panda.1.x.x\direct)

That's too bad :( since I did not want to hack the panda installation to make it work... maybe its something I am not doing?


What works:

* Code completion from pandac modules and direct modules are correctly identified, included inherited ones like DirectObject (Ctrl-Space for code completition)

*The code completition shows documentation with parameters and reutrn value, if any

*Pydev will import libraries if not found (Ctrl-1 to fix the error will show Import..."specific library")

What doesn't work:

* Certain variables like base, render and render2d can't be identified

* Some imports wont be recognized (Examples like DirectObject and Actor) when instantiated (Example: act = Actor.Actor() and DirectObject.DirectObject) BUT after that their variables will detect their methods without trouble (act will recognize code completition for example).
You can export directly the modules apparently, but I recommend to use the panda standard

Problems

*Importing import direct.directbase.DirectStart with code completition will make a panda instance to run

*It takes time to search all libraries and Eclipse freezes for like 6 seconds roughly the frs time it looks for something (like Actor class methods)
-----

And done and done, this was what I wanted to say for now :P

Couldn't believe it was so simple (well not that simple)... the forced built ins in Pydev exist because many modules (not just panda) have their imports generated at runtime... quoting from the Pydev FAQ

Code completion is not working correctly for some library

Well, code completion works by default by analyzing the source code, but, sometimes, most information is only really available at runtime (the os module and wxPython are good examples here). So, you can specify that you want to treat those as builtin libraries. For that, go to the python interpreters and add it as a 'forced builtin lib'. More information may be found at the faq:

'What is that 'Forced builtin libs' in the Python Interpreters preferences?'


What is that 'Forced builtin libs' in the Python Interpreters preferences?

Well, some libraries once installed do not really show in code completion because they do not have a corresponding module (such as __builtin__ and datetime) or they do have a corresponding module but it cannot be really used in code completion because most of its information is only gotten at runtime (such as sys and os), so, in order for code completion to get its information, you have to manually add it to those libs (and by doing so, its information is gotten with a python shell).


However I might have done something else that I did not notice, so I you can't auto complete yet please tell me, so I'll keep searching if I have done something else...

Later everyone,

PD: It seems this is pretty standard for many python modules (like wxPython) for this to happen... so I suppose there might be an equivalent in other Python editors?

Italo F. Capasso B.
AKA "Edwood Grant"
Last edited by Edwood Grant on Sat Jul 05, 2008 4:24 am, edited 3 times in total.
"Oh, im just too good for my own bad self"
Shwang Shwing

"Vengeance is cold and sweet... just like an ice cream!"
User avatar
Edwood Grant
 
Posts: 19
Joined: Sun Jun 06, 2004 12:41 pm
Location: Bogota, Colombia

Postby ynjh_jo » Fri Jul 04, 2008 11:48 pm

I'm wondering, can you get completion on all functions/methods return value ?
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 Edwood Grant » Sat Jul 05, 2008 4:16 am

Hmmm no code complete for function/method return value I'm afraid...

As far as I know only the functions/methods that are documented will tell you information about the method, including return value (if it is documented) otherwise it wont show anything (sometimes it shows method parameters withouth documentation, but sometimes not. Maybe something related to the documentation itself and not code completing issues?)
"Oh, im just too good for my own bad self"
Shwang Shwing

"Vengeance is cold and sweet... just like an ice cream!"
User avatar
Edwood Grant
 
Posts: 19
Joined: Sun Jun 06, 2004 12:41 pm
Location: Bogota, Colombia

Postby treeform » Sat Jul 05, 2008 10:46 pm

one possible it creating a facke python library thats generated form that is avaliable at run time. This fake lib is only used for code completion though.
User avatar
treeform
 
Posts: 2106
Joined: Sat May 05, 2007 5:15 pm
Location: SF, CA

Postby Robbson » Mon Apr 06, 2009 6:45 pm

treeform wrote:one possible it creating a facke python library thats generated form that is avaliable at run time. This fake lib is only used for code completion though.


If this topic is not forgotten...
So how can I create a faked python library?

Robbson.
Robbson
 
Posts: 5
Joined: Sun Apr 05, 2009 11:47 am

Postby somada141 » Thu May 13, 2010 12:59 am

Tried your instructions on MacOSX but it did not work. PyDev isn't even recognizing the pandac modules imports...

Any other ideas on how to get auto-completion?
somada141
 
Posts: 24
Joined: Thu Apr 29, 2010 2:33 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest