[GRASSGUI] Re: python question - waiting for a variable to change

Michael Barton michael.barton at asu.edu
Mon Mar 19 12:41:47 EDT 2007


Jachym,

It looks like you are doing with menuform and gismutils exactly what I've
been messing with in my local copy. Maybe you can do this better than I at
this point, so I'll mention a couple of items.

There is a section in menuform (near where you asked " Michael, we have the
command here, what to do?") that is set up for d.* commands. I thought it
should just return the command.

    if errors:
    
        self.OnError(errStr)

    else:
         
        if cmd[0:2] == "d.":

                # Send GRASS display command(s)with arguments
                # to the display processor.
                # Display with focus receives display command(s).

##                  self.console_output.write(cmd+"\n----------\n")
                return cmd


The idea is to get this d.* command back to the layer manager (where it is
called in gismutils.LayerTree.onActivate) so that it can send it on to
render.py with the rest the information for each layer.


The second thing for anyone wanting to upgrade menuform is to implement the
new select.Select class. This will create a nice dropdown combo box for
selecting maps or any other gis element in response to the "Prompt"
parameter in task-description. I started messing with it and have it
working, but working incorrectly.

Let me know how the new changes work.

Michael


On 3/19/07 9:20 AM, "Jachym Cepicky" <jachym.cepicky at gmail.com> wrote:

> Hi,
> 
> today, I would like introduce few changes to mapdisp.py, which will
> 
> a) make it possible to use special p.* command set (e.g. p.rast soils)
> b) use exactly what you are desribing here: timer, which is regulary
> checking, if something is happening..
> 
> on the other hand, I do not think, we should use this kind of code
> only there, where it is really needed, because messes the code a bit.
> 
> looking at the menuform.py code, we just need to integrate it a little bit
> more.
> 
> I updated menuform.py, see line 342 and in gismutils.py lines 200 and 204
> 
> jachym
> 
> 2007/3/19, Michael Barton <michael.barton at asu.edu>:
>> 
>>  I've run into a little problem that is taxing my neophyte Python
>> programming abilities. However we do a popup panel for setting display layer
>> options, I think it is necessary to do something along the lines of the
>> following....
>> 
>>  1. Start the options popup. This is currently done with a double click on
>> the layer, which calls the onActivate even handler. For a raster, the event
>> handler uses...
>>          drastcmd = menuform.GUI().parseCommand('d.rast', gmpath)
>>      ...to start the autogenerated GUI.
>> 
>>  2. When you press the "run" button for this d.* command, the assembled
>> command (d.rast + options) is simply returned.
>> 
>>  3. Now drastcmd should contain a complete d.rast command string.
>> 
>>  So, how do I wait in onActivate until the "run" button is pressed on the
>> popup and the information is returned to drastcmd (i.e., the value of
>> drastcmd is changed). Or, alternatively, how can a change in the value of
>> drastcmd generate an event that I can capture and process? I messed around
>> with wait() (thinking about tk_wait in TclTk), but couldn't get it to do
>> what I wanted.
>> 
>> 
>>  Michael
>>  __________________________________________
>>  Michael Barton, Professor of Anthropology
>>  School of Human Evolution & Social Change
>>  Center for Social Dynamics & Complexity
>>  Arizona State University
>> 
>>  phone: 480-965-6213
>>  fax: 480-965-7671
>>  www: http://www.public.asu.edu/~cmbarton
>> 
>> 
> 

__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton





More information about the grass-gui mailing list