Finaly! Panda3D with autocompletion!

Return to General Discussion

Finaly! Panda3D with autocompletion!

Postby Nique » Sat Apr 21, 2012 5:53 am

Hi guys, i want to share something with you. It is possible to have smart intelligence autocomplete in a new kind of Editor called Sublime Text 2.

I'm using SublimeText 2 with a couple packages installed. It is actually working!! ;). SublimeText is absolutely amazing! (no i'm not affiliated with the makers) See steps below the images..

Result
Image

Image

Steps to complete
  1. Download SublimeText 2
  2. Install the package manager
  3. Startup sublime text
  4. open package control (under preferences menu)
  5. Type "install" and press enter
  6. Now type a package name and press enter (repeat steps 4,5 and 6 this for every package)
    • Alignment
    • FileTemplates
    • Ini
    • PythonOpenModule
    • Quick File Creator
    • QuickFileMove
    • SidebarEnhancements
    • SublimeCodeIntel
    • SublimeRope
    • Terminal
    Now everything is installed you will need to configure your project.
  7. Open a folder for your project (File > open folder) (usualy ..../MyProject/src)
  8. Save your project (Project > Save Project As...) in the .../MyProject folder and edit it: (Project > Edit Project). (folders are set relative from MyProject folder as where i saved my project file here) Edit the file like this and save it.
    Code: Select all
    {
       "build_systems":
       [
          {
             "cmd":
             [
                "python",
                "-u",
                "$project_path\\src\\main.py"
             ],
             "name": "MyProject"
          }
       ],
       "folders":
       [
          {
             "path": "src"
          }
       ]
    }

  9. Now we add Panda3D to the project. Rightclick on the folder name you just added to the project and click "Open Terminal here"
  10. In the terminal enter "cd ../"
  11. Add a directory called ".codeintel" (mkdir ".codeintel")
  12. Cd in this directory and add a file called "config" (echo > config) and close the terminal
  13. Now open that file (you are almost done!)
  14. Paste this and adjust to your needs
    Code: Select all
    {
        "Python": {
            // "python": "/usr/bin/python",
            "pythonExtraPaths": [
                "D:\\Programming\\Panda3D\\1.7.2\\direct",
                "D:\\Programming\\Panda3D\\1.7.2\\pandac"
            ]
        }
    }

    Don't forget to save this idiot ! :P
  15. YOU ARE DONE!
Nique
 
Posts: 12
Joined: Sat Jan 23, 2010 8:27 am

Postby astrogee » Tue Apr 24, 2012 11:40 am

ST2 is great! Been using if for a while now for other projects and was having thoughts on creating some kind of Panda3D plugin. But it seems that will not be neccessary :D
User avatar
astrogee
 
Posts: 35
Joined: Mon Oct 25, 2010 6:27 am
Location: Stockholm, Sweden

Postby Nique » Mon Apr 30, 2012 7:03 pm

Install the shaderLanguages plugin via Package Control and you benefit from syntax highlighting in glsl files. If you want it to apply to .sha files to, just add <string>sha</string> to the fileTypes array in "OpenGL SL.tmLanguage". That file is found inside the ShaderLanguages plugin directory.

Code: Select all
C:\Users\<USERNAME>\AppData\Roaming\Sublime Text 2\Packages\ShaderLanguages\OpenGL SL.tmLanguage
Nique
 
Posts: 12
Joined: Sat Jan 23, 2010 8:27 am

Postby croxis » Sat May 05, 2012 9:38 am

Still working on CityMania eh? :P
David - Proud to be saving the world since 1984
croxis
 
Posts: 478
Joined: Thu Feb 12, 2009 4:13 pm
Location: Portland, OR

Postby Liamhausser » Mon May 07, 2012 12:26 pm

i use st2 as well. its great!
Liam
Liamhausser
 
Posts: 1
Joined: Mon May 07, 2012 12:23 pm

Postby Nique » Thu May 10, 2012 11:02 am

croxis wrote:Still working on CityMania eh? :P


Hah, just waited for that one ;) Yeah kinda ! :)
Nique
 
Posts: 12
Joined: Sat Jan 23, 2010 8:27 am

Postby nkint » Mon May 14, 2012 11:40 am

i am on ubuntu.. i've tried to follow your steps but code completition is not changed at all, some advice?
recursive: see adjective, recursive..
nkint
 
Posts: 26
Joined: Mon Sep 12, 2011 4:34 am
Location: berlin

Postby braveslice » Wed Aug 22, 2012 6:07 am

Trying to make this work.

It seems it doesn’t matter what I type to “config” file. The example you provided will work just fine without it (OnscreenImage example) but not with self.ground=self.loader.loadModel("model1)and then trying to autocomplete self.ground.??

Now when I clear data from “config” it does not matter at all.

My directory structure is:
Code: Select all
ProjectFolder
   .codeintel
   Myproject.sublime-project
   scr
         main.py (under scr – only file here)


Is this correct?

How does it know to use panda if config file is empty?

How do I know that for example that main.py is included to project? Do I have to manually “Edit project” and add files? How does sublime know that it’s supposed to read .codeintel?

Btw is this supposed to work with 1.6.2?
braveslice
 
Posts: 15
Joined: Thu Nov 04, 2010 8:24 am

Postby Nemesis#13 » Wed Aug 22, 2012 8:04 am

but not with self.ground=self.loader.loadModel("model1)and then trying to autocomplete self.ground

That's normal, because in Python a method can return virtually anything. That said it's not possible what object self.ground is until the code is executed and at that spot.

You can only do code completion for classes or objects that obviously are of a certain type - and even that is not really reliable, because in Python everything is so dynamic (you can even change the methods of a class or of an object from outside).


By the way, you don't need to set up a project, configure anything or even install the add ons from the post above. The code completion works out of the box with only SublimeCodeIntel add on installed. At least that works for me on Linux (where you don't have to worry about python paths anyway :D).

Still thanks for the tip with the SublimeCodeIntel add on :-)
User avatar
Nemesis#13
 
Posts: 1041
Joined: Mon Aug 04, 2008 8:09 pm
Location: Germany

Postby braveslice » Thu Aug 23, 2012 1:53 am

Nemesis#13 wrote:That's normal, because in Python a method can return virtually anything. That said it's not possible what object self.ground is until the code is executed and at that spot.


Thank you for telling me, this saves me many hours.

I think it might work in Windows too without anything added to config, but if one wants to do that the structure above is correct. Also if you make changes to config, only way I could be sure (Windows) that it builds the index is 1. Remove CodeIntel 2. Close Sublime 3. Instal CodeIntel 4. Close Sublime

It still remains mystery to me how to choose what python interpreter is in use and how Sublime includes Panda3D files automatically :D
braveslice
 
Posts: 15
Joined: Thu Nov 04, 2010 8:24 am

Postby zhao » Fri Aug 24, 2012 3:08 pm

Wow! Thanks for pointing out this wonderful little text editor. The codeIntel is very neat.

I did a little bit of researching and found that out that the Komodo IDE whose codeIntel Sublime is based upon, has an even richer codeIntel feature set: It can even provide calltips! Unfortunately, it's also $250 dollars more.
zhao
 
Posts: 225
Joined: Tue Nov 10, 2009 5:32 pm

Re: Finaly! Panda3D with autocompletion!

Postby digidan » Mon Apr 01, 2013 3:47 am

Hi

Is there a separate thread for support questions?

Dan
digidan
 
Posts: 10
Joined: Thu Sep 08, 2011 7:27 pm
Location: UK

Re: Finaly! Panda3D with autocompletion!

Postby Nemesis#13 » Tue Apr 02, 2013 12:55 pm

digidan wrote:Hi

Is there a separate thread for support questions?

Dan

If you're referring to help with Panda3D in conjunction with Sublime Text 2 then ask here. For other Panda3D questions please search the forums for it as it might already got answered - if not, feel free to open a new thread.
User avatar
Nemesis#13
 
Posts: 1041
Joined: Mon Aug 04, 2008 8:09 pm
Location: Germany

Re: Finaly! Panda3D with autocompletion!

Postby digidan » Sun Apr 07, 2013 5:19 am

Hi

I was wondering if I could have some help with autocomplete. I have followed the tutorial as best I can. The auto compete works but only with items in document and dose not display all options in the scope of the module.

Thanks in advance

Dan
digidan
 
Posts: 10
Joined: Thu Sep 08, 2011 7:27 pm
Location: UK

Re: Finaly! Panda3D with autocompletion!

Postby rndbit » Sun Apr 07, 2013 5:44 am

you cant achieve good autocompletion because some of things just cant be resolved from static files. best option is using pydev autocompletion from here.
rndbit
 
Posts: 92
Joined: Tue Jun 26, 2012 2:33 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

cron