Finaly! Panda3D with autocompletion!


#1

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!! :wink:. SublimeText is absolutely amazing! (no i’m not affiliated with the makers) See steps below the images…

[size=134]Result[/size]

[size=134]Steps to complete[/size]

  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.

  1. Open a folder for your project (File > open folder) (usualy …/MyProject/src)
  2. 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.
{
	"build_systems":
	[
		{
			"cmd":
			[
				"python",
				"-u",
				"$project_path\\src\\main.py"
			],
			"name": "MyProject"
		}
	],
	"folders":
	[
		{
			"path": "src"
		}
	]
}
  1. Now we add Panda3D to the project. Rightclick on the folder name you just added to the project and click “Open Terminal here”
  2. In the terminal enter “cd …/”
  3. Add a directory called “.codeintel” (mkdir “.codeintel”)
  4. Cd in this directory and add a file called “config” (echo > config) and close the terminal
  5. Now open that file (you are almost done!)
  6. Paste this and adjust to your needs
{
    "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 ! :stuck_out_tongue:

  1. YOU ARE DONE!

Proper auto-complete IDE
#2

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 :smiley:


#3

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 sha to the fileTypes array in “OpenGL SL.tmLanguage”. That file is found inside the ShaderLanguages plugin directory.

C:\Users\<USERNAME>\AppData\Roaming\Sublime Text 2\Packages\ShaderLanguages\OpenGL SL.tmLanguage

#4

Still working on CityMania eh? :stuck_out_tongue:


#5

i use st2 as well. its great!


#6

Hah, just waited for that one :wink: Yeah kinda ! :slight_smile:


#7

i am on ubuntu… i’ve tried to follow your steps but code completition is not changed at all, some advice?


#8

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:

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?


#9

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

Still thanks for the tip with the SublimeCodeIntel add on :slight_smile:


#10

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 :smiley:


#11

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.


#12

Hi

Is there a separate thread for support questions?

Dan


#13

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.


#14

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


#15

you cant achieve good autocompletion because some of things just cant be resolved from static files. best option is using pydev autocompletion from here.