ProgressBar — Graphical progress indicator
ProgressBar
( | string label , |
integer maxvalue , | |
integer
progress
) ; |
maxvalue
the maximum value of the bar
progress
the current progress value of the bar
A progress bar is a horizontal bar with a label that shows a progress value. If you omit the optional parameter maxvalue
, the maximum value will be 100. If you omit the optional parameter progress
, the progress bar will set to 0 initially.
If you don't know the number of total steps you might want to use the BusyIndicator widget instead of ProgressBar.
// Simple ProgressBar example { integer max_progress = 7; integer progress = 0; UI::OpenDialog( `VBox( `ProgressBar(`id(`pr), "Sample progress bar", max_progress, progress ), `PushButton(`id(`next), "Next"), `Right(`PushButton(`id(`close), "&Close" ) ) ) ); while ( progress < max_progress ) { symbol button = (symbol) UI::UserInput(); if ( button == `next ) { progress = progress + 1; UI::ChangeWidget(`id(`pr), `Value, progress); UI::ChangeWidget(`id(`pr), `Label, sformat("Progress %1 of %2", progress, max_progress )); } else if ( button == `close ) break; } UI::CloseDialog(); }
// ProgressBar example { UI::OpenDialog( `VBox( `Heading("Adjust the volume"), `ProgressBar(`id(`vol), "Volume", 100, 50), `HBox( `PushButton(`id(`down), "<<"), `PushButton(`id(`up ), ">>"), `HStretch(), `HSpacing(3), `PushButton(`id(`cancel), "&Close" ) ) ) ); while (true) { symbol button = (symbol) UI::UserInput(); if (button == `cancel) break; else if ( button == `down || button == `up ) { integer volume = (integer) UI::QueryWidget(`id(`vol), `Value); if ( button == `down ) volume = volume - 5; if ( button == `up ) volume = volume + 5; y2milestone( "Volume: %1", volume ); UI::ChangeWidget(`id(`vol), `Value, volume ); } } UI::CloseDialog(); }