[GRASS5] Re: bugs in 5.7's tcltkgrass

Glynn Clements glynn.clements at virgin.net
Fri Oct 15 10:10:48 EDT 2004


Radim Blazek wrote:

> > > > 3. all modules I tried in 5.7 display this instead of percents only:
> > > > Percent complete:    2%   5%   8% (...) 100%
> > >
> > > On my computer, it goes:
> > >
> > > Percent complete: 2%/b/b/b/b5%/b/b/b and so forth...most of the time.
> > > Other times, it stops after a few increments, then does nothing until
> > > 100%
> >
> > To fix this basically we need a G_is_ui() function which could be called
> > in G_percent():
> >
> >
> > printf("%3d%%", percent_done);
> > if( G_is_ui() )
> >    printf("\n");  // newline
> > else
> >    printf("\b\b\b\b");  // 4x backspaces
> >
> > easier said than done though.
> 
> I think that we should define format of messages printed 
> when module is run from GUI. For example
> PERCENT: %d
> which can be parsed by GUI and displayed in progress bar.

It wouldn't be particularly hard to parse the existing progress
output, e.g.:

	proc set_progress {percent} {
		...
	}
	
	set percent_re [subst -nocommands {([ ][ 1][ 0-9][0-9])%\b\b\b\b\b}]
	
	proc prnout {dlg fh} {
		global opt percent_re
		set outtext $opt($dlg,outtext)
	
		if [eof $fh] {
			close $fh
		} else {
			set str [read $fh]
			set val {}
			while {[regexp $percent_re $str dummy val]} {
				regsub $percent_re $str {} str
			}
			if {$val != {}} {
				set_progress $val
			}
			$outtext insert end $str
			$outtext yview end
		}
	}

The BWidget library includes a progress bar.

-- 
Glynn Clements <glynn.clements at virgin.net>




More information about the grass-dev mailing list