[GRASS-dev] Python module gui inputs

Hi all,

This is my first foray into grass scripting. I'm working on a GRASS 7
python module to create a local relief model from a lidar derived
surface. The code works, but for some reason in the auto generated gui
for the tool, the field to enter a neighborhood size to use for the
low pass filter doesn't appear. my module code is below. Any
assistance would be greatly appreciated.

Thanks,
Eric

#%module
#% description: Creates a Local Relief Model from input raster.
#% keywords: lrm
#% keywords: lidar
#% overwrite: yes
#%end
#%option G_OPT_R_INPUT
#% key:input_map
#% description: Select input raster
#% required: yes
#%end
#%option
#% key: output_map
#% type: string
#% description: Name for output LRM raster
#% required: yes
#%end
#%option
#% key: neighbor_size
#% type: double
#% description: The neighborhood size to be used in the low pass
filter. Default is 25.
#% required: no
#% answer: 25
#%end

2013/2/27 Eric Goddard <egoddard1010@gmail.com>:

Hi all,

Hi Eric,

Thanks,
Eric

#%module
#% description: Creates a Local Relief Model from input raster.
#% keywords: lrm
#% keywords: lidar
#% overwrite: yes
#%end
#%option G_OPT_R_INPUT
#% key:input_map
#% description: Select input raster
#% required: yes
#%end
#%option
#% key: output_map
#% type: string
#% description: Name for output LRM raster
#% required: yes
#%end
#%option
#% key: neighbor_size
#% type: double
#% description: The neighborhood size to be used in the low pass
filter. Default is 25.
#% required: no
#% answer: 25
#%end

I would like to change the description of module as following, for a
more compliant GRASS description.
I think this should work. Otherwise could you paste you entire code
(better in a external site as pastebin)

#%module
#% description: Creates a Local Relief Model from input raster.
#% keywords: lrm
#% keywords: lidar
#% overwrite: yes
#%end
#%option G_OPT_R_INPUT
#%end
#%option G_OPT_R_OUTPUT
#%end
#%option
#% key: neighbor_size
#% type: double
#% description: The neighborhood size to be used in the low pass
filter. Default is 25.
#% required: no
#% answer: 25
#%end

--
ciao
Luca

http://gis.cri.fmach.it/delucchi/
www.lucadelu.org

Thanks for the response, Luca. I've made the change to the output
option, but the neighbor_size option still isn't appearing in the gui.
The descriptions will become more verbose once the code and everything
is working; what is in the script now is just the bare minimum for it
to run. and generate a gui. I've pasted the full code at
http://pastebin.com/4PCJ0xeG.

On Wed, Feb 27, 2013 at 4:46 PM, Luca Delucchi <lucadeluge@gmail.com> wrote:

2013/2/27 Eric Goddard <egoddard1010@gmail.com>:

Hi all,

Hi Eric,

Thanks,
Eric

#%module
#% description: Creates a Local Relief Model from input raster.
#% keywords: lrm
#% keywords: lidar
#% overwrite: yes
#%end
#%option G_OPT_R_INPUT
#% key:input_map
#% description: Select input raster
#% required: yes
#%end
#%option
#% key: output_map
#% type: string
#% description: Name for output LRM raster
#% required: yes
#%end
#%option
#% key: neighbor_size
#% type: double
#% description: The neighborhood size to be used in the low pass
filter. Default is 25.
#% required: no
#% answer: 25
#%end

I would like to change the description of module as following, for a
more compliant GRASS description.
I think this should work. Otherwise could you paste you entire code
(better in a external site as pastebin)

#%module
#% description: Creates a Local Relief Model from input raster.
#% keywords: lrm
#% keywords: lidar
#% overwrite: yes
#%end
#%option G_OPT_R_INPUT
#%end
#%option G_OPT_R_OUTPUT
#%end
#%option
#% key: neighbor_size
#% type: double
#% description: The neighborhood size to be used in the low pass
filter. Default is 25.
#% required: no
#% answer: 25
#%end

--
ciao
Luca

http://gis.cri.fmach.it/delucchi/
www.lucadelu.org

Hi Eric, for me it works (with code from paste bin). GUI shows and
neighbor_size is in the Optional tab.

Another suggestions about options: If the "description" is long, you
can use "label" which will be shown in the gui and description will
become a tooltip. There is usually no need to write default value into
the description since default value is already in the gui or in
y.our.module --help.

I'm afraid that the programming manual does not list these practices.
http://grass.osgeo.org/programming7/gislib.html#Command_Line_Parsing

Vaclav

On 28 February 2013 01:03, Eric Goddard <egoddard1010@gmail.com> wrote:

Thanks for the response, Luca. I've made the change to the output
option, but the neighbor_size option still isn't appearing in the gui.
The descriptions will become more verbose once the code and everything
is working; what is in the script now is just the bare minimum for it
to run. and generate a gui. I've pasted the full code at
http://pastebin.com/4PCJ0xeG.

On Wed, Feb 27, 2013 at 4:46 PM, Luca Delucchi <lucadeluge@gmail.com> wrote:

2013/2/27 Eric Goddard <egoddard1010@gmail.com>:

Hi all,

Hi Eric,

Thanks,
Eric

#%module
#% description: Creates a Local Relief Model from input raster.
#% keywords: lrm
#% keywords: lidar
#% overwrite: yes
#%end
#%option G_OPT_R_INPUT
#% key:input_map
#% description: Select input raster
#% required: yes
#%end
#%option
#% key: output_map
#% type: string
#% description: Name for output LRM raster
#% required: yes
#%end
#%option
#% key: neighbor_size
#% type: double
#% description: The neighborhood size to be used in the low pass
filter. Default is 25.
#% required: no
#% answer: 25
#%end

I would like to change the description of module as following, for a
more compliant GRASS description.
I think this should work. Otherwise could you paste you entire code
(better in a external site as pastebin)

#%module
#% description: Creates a Local Relief Model from input raster.
#% keywords: lrm
#% keywords: lidar
#% overwrite: yes
#%end
#%option G_OPT_R_INPUT
#%end
#%option G_OPT_R_OUTPUT
#%end
#%option
#% key: neighbor_size
#% type: double
#% description: The neighborhood size to be used in the low pass
filter. Default is 25.
#% required: no
#% answer: 25
#%end

--
ciao
Luca

http://gis.cri.fmach.it/delucchi/
www.lucadelu.org

_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

Thanks for the suggestions. I figured out the problem – somehow an older version of my code was getting built and I wasn’t following all the steps correctly on the grass and python wiki. The GUI works now, but my code logic still needs some work.

Eric

On Feb 28, 2013 3:03 AM, “Vaclav Petras” <wenzeslaus@gmail.com> wrote:

Hi Eric, for me it works (with code from paste bin). GUI shows and
neighbor_size is in the Optional tab.

Another suggestions about options: If the “description” is long, you
can use “label” which will be shown in the gui and description will
become a tooltip. There is usually no need to write default value into
the description since default value is already in the gui or in
y.our.module --help.

I’m afraid that the programming manual does not list these practices.
http://grass.osgeo.org/programming7/gislib.html#Command_Line_Parsing

Vaclav

On 28 February 2013 01:03, Eric Goddard <egoddard1010@gmail.com> wrote:

Thanks for the response, Luca. I’ve made the change to the output
option, but the neighbor_size option still isn’t appearing in the gui.
The descriptions will become more verbose once the code and everything
is working; what is in the script now is just the bare minimum for it
to run. and generate a gui. I’ve pasted the full code at
http://pastebin.com/4PCJ0xeG.

On Wed, Feb 27, 2013 at 4:46 PM, Luca Delucchi <lucadeluge@gmail.com> wrote:

2013/2/27 Eric Goddard <egoddard1010@gmail.com>:

Hi all,

Hi Eric,

Thanks,
Eric

#%module
#% description: Creates a Local Relief Model from input raster.
#% keywords: lrm
#% keywords: lidar
#% overwrite: yes
#%end
#%option G_OPT_R_INPUT
#% key:input_map
#% description: Select input raster
#% required: yes
#%end
#%option
#% key: output_map
#% type: string
#% description: Name for output LRM raster
#% required: yes
#%end
#%option
#% key: neighbor_size
#% type: double
#% description: The neighborhood size to be used in the low pass
filter. Default is 25.
#% required: no
#% answer: 25
#%end

I would like to change the description of module as following, for a
more compliant GRASS description.
I think this should work. Otherwise could you paste you entire code
(better in a external site as pastebin)

#%module
#% description: Creates a Local Relief Model from input raster.
#% keywords: lrm
#% keywords: lidar
#% overwrite: yes
#%end
#%option G_OPT_R_INPUT
#%end
#%option G_OPT_R_OUTPUT
#%end
#%option
#% key: neighbor_size
#% type: double
#% description: The neighborhood size to be used in the low pass
filter. Default is 25.
#% required: no
#% answer: 25
#%end


ciao
Luca

http://gis.cri.fmach.it/delucchi/
www.lucadelu.org


grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev