[GRASS-dev] Re: [GRASS GIS] #254: wxpython Layer Manager: higher raster hides the lower (GRASS GIS)

Glynn Clements glynn at gclements.plus.com
Fri Aug 15 11:12:46 EDT 2008


Martin Landa wrote:

> >> BTW, when I start g.gui without arguments the dialog is launched
> >> instead of the GUI. This behaviour is not right I guess, the 'gui'
> >> parameter has already defined default value. Now you are forced to run
> >> `g.gui gui=wxpython`.
> >
> > That's becasue the gui= option is marked as required:
> >
> >    type = G_define_option();
> >    type->key = "gui";
> >        ...
> >    type->required = YES;
> >
> > even though it always has a default value:
> >
> >    gui_type_env = G__getenv("GRASS_GUI");
> >    if (gui_type_env && strcmp(gui_type_env, "text")) {
> >        type->answer = G_store(gui_type_env);
> >    }
> >    else {
> >        type->answer = "tcltk";
> >    }
> > If you remove the ->required setting, the dialog shouldn't appear.
> 
> well, I think the 'gui' parameter should stay required. Maybe I am
> missing something, but what is wrong on the required parameter with
> defined default value?

You are misunderstanding the meaning of the ->required field.

The ->required field indicates that the option must be provided *by
the program's arguments*. Given that any value which is provided by
the program's arguments will override any default value, there is no
point in both setting the ->required field and providing a default
value, as the ->required setting ensures that the default will always
be overriden.

> > In r32756, I removed all of the "argc > 1" hacks, and always call
> > G_parser(). It only generates the dialog if no arguments are given and
> > there is at least one required option.
> 
> I see, I think also default value(s) should be checked here, i.e.
> don't generate the dialog if there is required option with defined
> default value?

See above.

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


More information about the grass-dev mailing list