NetBeans Python Editor
By Brian Leonard on Sep 10, 2009
NetBeans 6.7, released earlier this summer, has a pretty nifty Python editor. To give it a spin a decided to set up a project for the Image Packaging System. If you want to try it yourself, here's the steps I took:
bleonard@os200906:~$ pfexec pkg install netbeans DOWNLOAD PKGS FILES XFER (MB) Completed 19/19 5638/5638 165.54/165.54 PHASE ACTIONS Install Phase 6756/6756 Deleting content cache
Install the NetBeans Python Plugin
Start NetBeans (Applications > Developer Tools) and install the Python plugin (Tools > Plugins):
Create the IPS Project
The IPS Python sources are in /usr/lib/python2.4/vendor-packages/pkg, with the exception of the pkg script, which is in /usr/bin. To keep the NetBeans project simple, I copied the pkg script from /usr/bin to /usr/lib/python2.4/vendor-packages/pkg. I also renamed the script to pkg2.py. Adding the .py extension allows it to be recognized as a Python script by NetBeans. Changing the name to pkg2 prevents it from conflicting with the existing script in /usr/bin:
pfexec cp /usr/bin/pkg /usr/lib/python2.4/vendor-packages/pkg/pkg2.py
In NetBeans select File > New Project and then select Python Project with Existing Sources:
Give the project a name such as PKG or IPS and set the Python Platform to Python 2.4.4:
Then add /usr/lib/python2.4/vendor-packages/pkg as a source root folder:
To give the project a quick test drive, right-click it and select Properties. Then set the Main Module to pkg2.py and the Application Arguments to something like 'info netbeans':
Then select Run > Run Main Project. You'll see the result in the Output window:
Now that we've got the project set up, let's look at some of the features provided by the editor.
The code is easy to read.
Ctrl+Space to activate.
Hover Documentation and Hyperlink Navigation
Holding down the control key and hovering over Classes and methods will also show you the documentation:
And clicking on the hyper-link will take you to the class or method.
Also, the Navigator window is a quick way to find your way around a script:
Go to Type
And Go to Type (Ctrl + O) will quickly take you to any type:
And finally, one of the coolest features is the debugger. Select Debug > Debug Main Project to start it: