[GRASS-user] GRASS module (python, gparser): Set a tick for flag by default

Hi,

I am working on a python script which involves a g.parser module (to get the input mask for a module as for other modules in GRASS).

So far I know how a flag is produced in the beginning of the script.
E.g.:

#%Flag
#% key: f
#% description: My Flag of Interest
#%end

Is there any possibility to set the flag ticked by default? So like providing
an answer for "options".

Best regards,

Johannes
--
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a

Johannes Radinger wrote:

I am working on a python script which involves a g.parser module (to
get the input mask for a module as for other modules in GRASS).

So far I know how a flag is produced in the beginning of the script.
E.g.:

#%Flag
#% key: f
#% description: My Flag of Interest
#%end

Is there any possibility to set the flag ticked by default? So like providing
an answer for "options".

No. Unlike options, where the user can override a default by providing
an explicit value, there's no way to disable a flag which is enabled
by default, and no way to specify GUI behaviour distinct from
command-line behaviour, so flags always default to false.

The only option is to invert the sense of the flag, i.e. enable the
behaviour by default and provide a "don't ..." flag to disable the
behaviour.

--
Glynn Clements <glynn@gclements.plus.com>

Thank you.

Good to know that, so that I'll do a reverse of the meaning
of the flag as you mentioned ("...don't...").

cheers,
Johannes

-------- Original-Nachricht --------

Datum: Fri, 20 Apr 2012 11:26:55 +0100
Von: Glynn Clements <glynn@gclements.plus.com>
An: "Johannes Radinger" <JRadinger@gmx.at>
CC: grass user list <grass-user@lists.osgeo.org>
Betreff: Re: [GRASS-user] GRASS module (python, gparser): Set a tick for flag by default

Johannes Radinger wrote:

> I am working on a python script which involves a g.parser module (to
> get the input mask for a module as for other modules in GRASS).
>
> So far I know how a flag is produced in the beginning of the script.
> E.g.:
>
> #%Flag
> #% key: f
> #% description: My Flag of Interest
> #%end
>
> Is there any possibility to set the flag ticked by default? So like
providing
> an answer for "options".

No. Unlike options, where the user can override a default by providing
an explicit value, there's no way to disable a flag which is enabled
by default, and no way to specify GUI behaviour distinct from
command-line behaviour, so flags always default to false.

The only option is to invert the sense of the flag, i.e. enable the
behaviour by default and provide a "don't ..." flag to disable the
behaviour.

--
Glynn Clements <glynn@gclements.plus.com>
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

--
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a

Johannes wrote:

> I am working on a python script which involves a g.parser
> module (to get the input mask for a module as for other
> modules in GRASS).

...

> Is there any possibility to set the flag ticked by default?
> So like providing an answer for "options".

Glynn:

No. Unlike options, where the user can override a default by
providing an explicit value, there's no way to disable a flag
which is enabled by default, and no way to specify GUI
behaviour distinct from command-line behaviour, so flags always
default to false.

The only option is to invert the sense of the flag, i.e.
enable the behaviour by default and provide a "don't ..."
flag to disable the behaviour.

Hi,

fwiw here's little a trick you can use to pre-populate the module
GUI flags and options from the command line (and so from a script
or the menu if you want to hard wire something by default)

GRASS> r.circle -b max=9999 --ui

will pop up a module GUI with the "b" flag pre-ticked and the max
parameter pre-filled in as 9999. (works in both tcl/tk and
wxPython GRASS_GUI modes, 6.x-trunk)

maybe it helps,
Hamish