nested progress bars...
Martin Pool
mbp at sourcefrog.net
Tue Mar 7 05:38:59 GMT 2006
On 7 Mar 2006, at 12:12 , Aaron Bentley wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Robert Collins wrote:
> | so do we have consensus on the following?
> |
> | * ui_factory.progress_bar is deprecated but continues to operate
> as it
> | does now giving a 'replace the current pb' progress bar to the
> client,
> | which does not stack and does not need to be returned to the ui
> factory.
> | * ui_factory.get_progress_bar() will produce a nested progress bar
> | which must be returned to the factory via pb.finished()
To extend this description (I think we agree on this):
Functions can take a progress bar as a parameter, but generally will
not. (Perhaps it's most useful in split-out internal methods that
don't correspond to any operation meaningful to the user.)
In general, routines that ought to display a progress bar will
construct one, use it for their operation, and then free it.
pb = ui_factory.nested_progress_bar
try:
pb.update(...)
dostuff
finally:
pb.finish()
Policy about whether/how progress bars are displayed is controlled at
the ui_factory level.
> I worry that a stack-based progress bar will wind up getting out of
> sync
> with the program stack. But I guess requiring it to be returned via
> pb.finished will probably work, and allow us to warn if we miss a
> finished() call.
If you miss a call the progress bar will be gc'd. (We could use a
__del__ method to warn there, but that seems generally considered a
bad idea.) We can detect that the enclosing pb was finalized before
its child and implicitly get rid of it or warn.
> The reason I wrote the TreeTransform one as I did was because I
> thought
> progress bars should be off unless a client declared that it wanted
> them.
That was the original concept, but for pragmatic reasons we ended up
making many methods make their own progress bar, and this evolved
into the current system where they say "I'm doing a long-running
operation ... ok ... done", and we globally establish how that should
be displayed.
--
Martin Pool
More information about the bazaar
mailing list