<HTML>
<HEAD>
<TITLE>Wxpython gui update</TITLE>
</HEAD>
<BODY>
<FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'>I just put up new files (mapdisc.py, gism.py, and render.py) on my website.<BR>
<BR>
I rewrote the display as a double buffered dc drawing. I <B>HOPE</B> this solves the display issues with Linux. Thuban seems to use a somewhat more primitive version of this, so I’m keeping my fingers crossed. Please let me know. If it works, I’ll package it all up for the last time and note it on the WIKI. Then I hope to move it to the cvs so all you can work on it.<BR>
<BR>
I also added a couple new bells and whistles. By redoing the display to use a bufferedDC, it is easy to make graphic file output. Using a simply example from the wxPython cookbook, I added output to PNG files. It is easy to add other formats.<BR>
<BR>
With regards to the discussion about postscript, wxPython has a wx.PrinterDC and wx.PostScriptDC, that will output to postscript.<BR>
<BR>
I also have set it so that you can specify the pen for mouse drawing in the event handler for a display control button. As example, zooming in and out have different colored zoom-rectangles. <BR>
<BR>
Currently, the little command line shell allow you to chain display commands. It simply puts them in a list and processes them in the order of the chain. You could make something more sophisticated like having add [command] and delete [command] to add them to a list, but this soon gets complicated (e.g., rearranging display commands in the list to control how they are rendered may be simpler by just cutting and pasting them in a chain rather than trying to remember where they are and doing a move or insert). You also have to watch out for possible conflicts with ‘real’ shell commands.<BR>
<BR>
It’s still not clear to me what is gained by starting in a Bash shell, starting the python app, and have it listen for special commands coming from the shell that it can recognize and parse. Why not simply start in a python shell that can send any shell commands to the shell (whatever shell you want; this too can be set by a command or a default from a config file) and trap the 350 or so GRASS commands? Same effect and easier to code and control. Maybe I’m missing something.<BR>
<BR>
Michael<BR>
__________________________________________<BR>
Michael Barton, Professor of Anthropology<BR>
School of Human Evolution & Social Change <BR>
Center for Social Dynamics & Complexity<BR>
Arizona State University<BR>
<BR>
phone: 480-965-6213<BR>
fax: 480-965-7671<BR>
www: <a href="http://www.public.asu.edu/~cmbarton">http://www.public.asu.edu/~cmbarton</a> <BR>
<BR>
<BR>
<BR>
<HR ALIGN=CENTER SIZE="3" WIDTH="95%"><B>From: </B>David Finlayson <david.p.finlayson@gmail.com><BR>
<B>Date: </B>Sun, 13 Aug 2006 21:47:16 -0700<BR>
<B>To: </B>Glynn Clements <glynn@gclements.plus.com><BR>
<B>Cc: </B>Trevor Wiens <twiens@interbaun.com>, Michael Barton <michael.barton@asu.edu>, <grass-dev@grass.itc.it>, <William@grass.itc.it>, Kyngesburye <kyngchaos@kyngchaos.com>, <woklist@kyngchaos.com><BR>
<B>Subject: </B>Re: [GRASS-dev] grass and python<BR>
<BR>
The Python interpreter is interactive, but it is not a general purpose shell. You would need to wrap external programs in an os.system or os.popen call. One attractive way of getting around this is to pre-wrap each program in a python object. For example: <BR>
<BR>
class Display:<BR>
<BR>
def rast(self, rastername):<BR>
os.system("d.rast %s" % rastername)<BR>
<BR>
Then the syntax in the Python interpreter would be:<BR>
<BR>
> import Display<BR>
> d = Display.display ()<BR>
> d.rast(rastername)<BR>
<BR>
Which isn't so bad. This is what things would look like in PyShell (or PyCrust) which is a wxWindows-compatible python interpreter that you can use in wxWindows GUI's.<BR>
<BR>
The most advanced Python interpreter is IPython. This has been tweaked for interactive use by the Scipy (numeric programming) folks so that some of the Python decorations can be dropped in the above example: <BR>
<BR>
> import Display<BR>
> d = Display.display()<BR>
> d.rast rastername<BR>
<BR>
No more parenthesis needed. Also, IPython has "magic" operators that allow you to "shell-out" to the underlying shell. Simply prepend a command with a % and it will bypass the python interpreter and send it to the shell: <BR>
<BR>
> %ls<BR>
<BR>
or<BR>
<BR>
>%dir<BR>
<BR>
The IPython interpreter is designed for interactive use. It is the Scipy answer to Matlab's interactive prompt. It has a lot of nice shell-like features and can be extended for use by GRASS (I think). Unfortunately, I don't think IPython is as well integrated with Windows as Unix. At least on my casual observations. <BR>
<BR>
David<BR>
<BR>
On 8/13/06, <B>David Finlayson</B> <david.p.finlayson@gmail.com> wrote:<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'>The Python interpreter is interactive, but it is not a general purpose shell. You would need to wrap external programs in an os.system or os.popen call. One attractive way of getting around this is to pre-wrap each program in a python object. For example: <BR>
<BR>
class Display:<BR>
<BR>
def rast(self, rastername):<BR>
<BR>
<BR>
<BR>
<BR>
On 8/12/06, <B>Glynn Clements</B> < glynn@gclements.plus.com <a href="mailto:glynn@gclements.plus.com"><mailto:glynn@gclements.plus.com></a> > wrote:<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'><BR>
Trevor Wiens wrote:<BR>
<BR>
> > If anyone can find a real language which is "good enough" on all of <BR>
> > Unix, Windows (Cygwin and native) and OSX, I'll quite happily rewrite<BR>
> > all of GRASS' shell scripts.<BR>
><BR>
> Python is easy to install on Windows. So with an offer like that, I<BR>
> can't help asking if any of the interactive Python shells are to your <BR>
> knowledge good enough. Or perhaps what in you mind defines an<BR>
> interactive shell environment that is good enough to replace bash?<BR>
<BR>
The main issue is the ability to have scripts which can be run as e.g .<BR>
"d.save", and not having to use "d.save.py <a href="http://d.save.py"><http://d.save.py></a> ". This needs to work both<BR>
from a shell and from system/exec/popen/spawn/etc functions provided <BR>
by various languages. <BR>
<BR>
--<BR>
Glynn Clements <glynn@gclements.plus.com><BR>
</SPAN></FONT></BLOCKQUOTE><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'><BR>
<BR>
<BR>
-- <BR>
David Finlayson <BR>
</SPAN></FONT></BLOCKQUOTE><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:12.0px'><BR>
<BR>
<BR>
-- <BR>
David Finlayson<BR>
</SPAN></FONT>
</BODY>
</HTML>