1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

external editor

Posted by John on Feb 07, 2008

Is there an easy way to use an external editor and then just call it to execute. ie I would love to be able to just call run in Textmate and have it execute in NodeBox without a manual copy and paste.


 
Posted by fdb on Feb 07, 2008

Hi,

Actually an external developer just asked about it, and I believe he just started working on this. I would love to have this supported in NodeBox, but currently I don't have a concrete idea how to check for external changes.

If you could provide me with some AppKit pointers, I would love to incorporate this into NodeBox.



Posted by blondinet on Feb 07, 2008

Maybe you can try to customize Textmate with a key binding to make it launch NodeBox in command line with corresponding script file.
I would do this simply with Emacs or VI, but I do not know about Textmate ...



Posted by John on Feb 08, 2008

On a related note, I see the examples under tutorial for console access, to run a standalone version inside cocoa, but is there a method for incorporating the libraries to build with py2app or py2exe, especially with the now integrated nature of pyobjc in Leopard. Has anyone taken the time to bundle an example of doing this?



Posted by John on Feb 08, 2008

To explain with analogy what I am looking for is something similar to the way we now all build processing applications with eclipse rather than with the processing ide. Because, while the processing ide does exactly what it set out to do, a robust development environment has its benefits for more complex projects, while still giving you the convenience classes and methodologies of the processing framework.



Posted by fdb on Feb 11, 2008

Integration of the core renderer/framework into another environment, like a Processing applet, is something I would be interested in having as well.

Rendering to a canvas isn'tdifficult. Having a NodeBox animation running from another Python app is another matter; it's not unsolvable, but is not very easy to untangle the code yet.

A quick "export to application" button is not something I'm working on right now, but if you have some time free, I'll be happy to accept any patches -- this is open-source after all :)

Again, if you just want to integrate the canvas in your project, that's not very difficult. Look in console.py for a demonstration.

All the best,

Frederik



Posted by Joel on Aug 05, 2008

In Textmate I just added a run from Nodebox command to the Python Bundle. Using the following code that I found for running Processing sketches from Textmate.

osascript



Posted by Joel on Aug 05, 2008

osascript



Posted by Joel on Aug 05, 2008

osascript



Posted by Joel on Aug 05, 2008

osascript  
tell application "Nodebox" to run  
tell application "Nodebox" to activate  
tell application "Nodebox" to open POSIX file "${TM_FILEPATH}"  
delay 1  
tell application "System Events" to tell process "Nodebox"  
  
keystroke "r" using command down  
end tell



Posted by Nortis on Aug 16, 2008

Emacs was mentioned...

Does anyone have a solution for that? It would be much appreciated!



Posted by Josh Caswell on Jul 08, 2009

Regarding emacs. . .

After hacking away on this for about four hours (it's my first venture into elisp), I've come up with the following function, using Joel's Applescript above as a base, and the information found in these three places: http://d.hatena.ne.jp/CortYuming/20081018/p1 http://emacs.wordpress.com/2007/06/15/emacsy-os-x/ http://evenmere.org/users/bts/Software/elisp/omnifocus-capture.el.

I'm using Aquamacs, and I put this in my Preferences.el file (which Aquamacs prefers over ~/.emacs.el):

(defun run-in-nodebox()
  (interactive)
  (let ((file (make-temp-file "Nodebox" nil ".py")))
    (write-region nil nil file nil nil)
    (do-applescript 
     (concat "tell application "Nodebox" to activate\n"
	     "tell application "Nodebox" to open \("" 
	     (expand-file-name file) "" as POSIX file\)\n"
	     "delay 1\n"
	     "tell application "System Events" to tell process "Nodebox"\n"
	     "\tkeystroke "r" using command down\n"
	     "end tell"))))
(global-set-key "\C-x\C-n" 'run-in-nodebox)
It will create a temporary file, put whatever's in your current buffer in that file, then have Nodebox open and run the file.

Like I said, it's my first elisp work (and I'm also not very good at Applescript), so any pointers or improvements are more than welcome. Hope it's helpful to someone!



Posted by Josh Caswell on Jul 08, 2009

Hmmm, looks like some escapes were lost in the code above. . .

The quotes around Nodebox, System Events, r, the quote mark after 'open \(', and the quote mark just before 'as POSIX file' all need to be escaped when you copy this code.



Posted by Josh Caswell on Jul 11, 2009

After a little more research, I have discovered that users are supposed to attach new commands to the key combo Control-c, followed by any single character. The combo I used above (Control-x Control-n), was just the first thing I tried that worked without giving me errors. I recommend changing the last line of the code above to:

(global-set-key (kbd "\C-c n") 'run-in-nodebox)