We kick off by writing a simple script which prints "Hello World." to the Max window. The Max window is a console for Max status and error messages; you can open it by selecting "Max Window" from the "Window" menu, or typing Command-M (Mac) or Control-M (Windows).
Since we're going to create a Python script file, we need a decent text editor, ideally one which understands the Python language and can do colour highlighting. On the Mac, I recommend the free
TextWrangler. (Recommendations for Windows would be welcome.)
This is our "Hello World" script:
'''
This is a script which prints "Hello World"
to the Max window.
'''print "Hello World."
This script has two parts. The first is the
documentation string, a comment describing what the script does (the comment is contained within triplets of single-quote characters):
'''
This is a script which prints "Hello World"
to the Max window.
'''
The second part is the the actual one-line script statement itself:
Create a file containing this script, and save it with a name like "HelloWorld.py" in the directory which contains
shado-workbench.PLACE_HOLDER. Now click the workbench button labelled "list text files". You should see
HelloWorld.py in the dropdown menu.
When you select
HelloWorld.py, two things should happen:
- The "about" text area in the workbench will show the documentation comment for the script
- The message "Hello World." will appear in the Max window
That's basically it: the script has done its job, and has now finished executing. We haven't yet communicated with the monome, or attempted to use the
shado library: that comes next.
Further Reading
There is a long and detailed Python tutorial
here. I recommend bookmarking it for future reference. (It refers to Python version 2.6; the workbench's Java-based Python interpreter is at version 2.2, but the language differences should be minor.)
There is some discussion of documentation strings
here.