Project info from Python macro?

Posted by shanec on 2007-01-31 09:14
OS: All / Any | Product: Komodo | tags: komodo python macro
Question: 

How do I get information on which files that are highlighted within the Project pane, via a Python macro?

Answer: 

Right now you have to do this in JavaScript, since the only way to access some of the UI is through JS. Eventually that will change, work has been done in the Firefox 3.0 branch to make Python work in the UI layer. In JavaScript do this:

var selectedItems = gProjectManager.viewMgr.getSelectedItems();

"selectedItems" is now an array of koIPart instances (XPCOM objects). If you want file information, you can to the following:

var f = selectedItems[0].getFile(); // f is a koIFileEx instance
dump(f.URI);
dump(f.path);

There are a number of other members on the file instance as well.