1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
Hello, world!
As it is good practice to say "Hello, world!" in the first example, let's
discuss how to do that in PyX.
At first we import the PyX modules. Most PyX programs will start with a line
like that. In order to produce some output we create a canvas instance `c`.
Such an instance provides some useful methods to output some text at a certain
position and for directly stroking a path, for which we use a `line` instance
from the `path` module here. Once this is done, we write an EPS file and a PDF
file containing all items inserted into the canvas instance. Since we did not
pass a filename as argument to the write methods, the resulting files will just
be named as the Python script - minus the extension, of course.
This rather minimal example is quite useful for debugging your setup. In case
of problems with your installation, you can add a `pyxinfo()` call immediately
after the import. PyX will then write various information to `stderr`, which is
quite helpful for yourself or when asking for help on the mailing list.
|