ANN: pyspread 0.0.8

mmanns at gmx.net mmanns at gmx.net
Sun Aug 3 01:54:15 CEST 2008


On Sat, 02 Aug 2008 13:39:25 -0400
"Colin J. Williams" <cjw at ncf.ca> wrote:

> mmanns at gmx.net wrote:
> > pyspread 0.0.8 has been released.

> Are you planning any documentation?

Actually, yes.
0.0.10 will feature some docs.
Any help writing and doing the layout is highly appreciated ;-)

> I've tried:
> # tpySpread.py
> print 'start'
> import pyspread
> print pyspread.__doc__

Just launch it with

$ pyspread.py

or when in Windows double click on the pyspread.py file in the Scripts
folder that is in your Python folder.

Alternatively, when in python type:

>>> import pyspread
>>> pyspread.main()

Then the main window should come up.

To make things easier, I post a preliminary tutorial:


--- Tutorial ---

1) One python expression per cell.

In the top left cell (row 0, column 0, table 0) type:

> 2 + 2 <Enter>

The cell text changes to:
4
which is the string representation of the result.

Select the top left cell again. 2 + 2 is displayed in the text field
above the grid. Double-clicking on the cell also changes the content
back to 2 + 2.

From any other cell, the cell result (that is the resulting object) can
be accessed by entering

> S[0, 0, 0]

This is also possible for other tables. Change to Table 1 in the
icon bar choicebox. and enter S[0,0,0] somewhere.

A value can also be assigned to a global variable. Change back to Table
0 and type into cell 1,0,0: 

> myfancystring = " ".join(str(i) for i in xrange(100))

myfancystring can now be accessed from any other cell as a global
variable.

In each cell, upper case X, Y, and Z refer to the cell's position in
the grid. So if you type into the cell directly below the top-left cell

> S[X-1, Y, Z]

The result is identical to S[0, 0, 0]

However, when copying the input with Crtl-C and Ctrl-V, the link stays
relative while the other link is absolute.

2) Python batteries

Library import can be done as follows:

> decimal = __import__("decimal")

in one cell and

> decimal.Decimal(1)

in the next cell. The calculations will be done with the object while
the string representation is displayed in the grid.

Since some functionality should not be done in one-line expression,
functions can be defined in the Macro list.

In the menu, select Macro -> Macro list.
On the lower right side, a code window can be uncovered, in which one
and only one function can be entered, e.g.:

> def mysandwich(spam, eggs, bacon):
>     """Add spam, eggs, and bacon."""
>     return spam + eggs + bacon

After clicking on Add in the top left of the dialog, the function is
accessible from each cell. The macro form (middle right) allows filling
in the parameters and Ok inserts the function into the selected cell.

When doing changes to the code, Apply alters the current function
including the function name while Add lets you create a new function by
changing the function name.

3) Spreading data

Often, a cell may return a list or a matrix, which is nice for
calculations but bad for export and presentation. Therefore, arrays and
matrices can be spread out into cells using the grid's spread method.

In cell 2,0,0 type:

> [1, 2, 3]

In cell 3,0,0 type:

> S.spread(4, 0, 0, S[2,0,0])

Then in the cells 4,0,0 - 6,0,0, the array will be displayed.

---

I hope that this helps as a quick start.


Best Regards

Martin




More information about the Python-list mailing list