python module and s2disp return

6 views
Skip to first unread message

Tiago Pereira

unread,
Jul 15, 2008, 9:13:27 PM7/15/08
to S2PLOT
Hi,

First of all let me thank you for making available such a great tool
as s2plot. I've been playing with the examples and finding out about
its potential.

I have been using the python module to display a few quantities in
interactive mode (using ipython). The visualization looks good, but I
have a problem when I want to close the s2plot window. Ideally I'd
like to be able to close the s2plot window and continue working in
ipython. However, if I close the window at the OS level (or shift-Q),
then it also quits python, finishing off my ipython session (which I
don't want).

This behaviour was using s2disp(-1,1), so idelay=-1. I read the
documentation that when idelay is set to -1, then s2disp should return
when TAB is pressed -- but nothing happens when I press TAB. The only
way I can get back to ipython is to put idelay >= 0, which is not the
best behaviour, as I'd like to move the window around without a time
limit or just looking at a static image. I looked at the source code
and indeed in s2disp it should just return when it's finished (and not
exit()). I also ran examples with the C interface, and TAB does not
exit the window as well.

Is there any way to close the window and make s2disp return without
killing python or using idelay>0 ?

Many thanks,

Tiago

David Barnes

unread,
Jul 15, 2008, 9:16:51 PM7/15/08
to S2PLOT
Hi Tiago,

for the s2disp function to work, you must be using either a Mac, or a
Linux box with S2FREEGLUT set to "yes" and linking done against the
freeglut library. The reason is the Mac GLUT library, and the
freeglut library, both provide the possibility to return control to
the main program without calling the C exit function. Read
ENVIRONMENT.TXT in your S2PLOT directory, make the appropriate
changes, then rebuild your python interface to S2PLOT from source.
Hopefully this will help.

- David.

Tiago Pereira

unread,
Jul 15, 2008, 9:54:49 PM7/15/08
to S2PLOT
Hi David,

Thanks for the quick reply. I am using a Mac and the binary
distribution s2plot-darwin-gnu-i386-2.02-2008-03-14. I thought this
version had been linked against Mac GLUT. Are you saying that this
version does not support a re-entrant s2disp?

In ENVIRONMENT.txt it says that for a re-entrant s2disp one needs
freeglut > 2.2.0 in Linux, but you say that Mac GLUT also provides the
same functionality. I'd just like to confirm that if I compile in OS X
with Mac GLUT, s2disp can be 're-entrant'.

Thanks,

Tiago

David Barnes

unread,
Jul 15, 2008, 10:00:59 PM7/15/08
to S2PLOT
Hi Tiago,

That's correct, s2disp should be "re-entrant" on Mac by default.
Sounds like this is a defect in the python module. Unfortunately the
developer of the python module isn't at Swinburne anymore. If it's
critically important to you I can try to look at it in the next week
or so, otherwise please work around it as best you can.

Regards - David Barnes.

Tiago Pereira

unread,
Jul 15, 2008, 10:36:06 PM7/15/08
to S2PLOT
Hi,

I don't think the problem is with the python module. I've looked at
_s2plot.c and the python wrapper for s2disp is returning correctly. In
fact, it returns when I put idelay >= 0. The problem seems to be in
s2disp itself. Are you sure it's grabbing the TAB key to return? Or
maybe the key mapping is not right for the Mac? I noticed that some of
the key mappings don't work correctly in the Mac (eg. F11 and F12 are
grabbed by the OS).

Unfortunately I don't have the source code for s2disp, so I can't look
it up myself.

Cheers,

Tiago

David Barnes

unread,
Jul 15, 2008, 11:31:12 PM7/15/08
to S2PLOT
Good point. Try Shift-Enter ...

Tiago Pereira

unread,
Jul 15, 2008, 11:39:50 PM7/15/08
to S2PLOT
Thanks a lot, Shift-Enter worked!

David Barnes

unread,
Jul 16, 2008, 12:03:26 AM7/16/08
to S2PLOT
Ok we need to update the documentation. Chris ...?
Reply all
Reply to author
Forward
0 new messages