YaST2 Developers Documentation: YCP UI Reference: Widgets



YCP UI Widget Reference

Back to the widget index

ProgressBar Graphical progress indicator

Description

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.

Arguments

string label the label describing the bar

Optional

integer maxvalue the maximum value of the bar
integer progress the current progress value of the bar

Special Properties

integer Value the current progress
string Label the label above the progress bar

Sample Usage

`ProgressBar( `id( `pb ), "17 of 42 Packages installed", 42, 17 )

Examples

Example 1: ProgressBar1.ycp

{
    UI::OpenDialog(
	       `VBox(
		     `ProgressBar(`id(`pr), "This is a progressbar", 4, 0), // 4 steps
		     `PushButton("Next")
		     )
	       );
 
    integer prog = 0;
    
    while (prog < 4) 
    {
	UI::UserInput();
	prog = prog + 1;
	UI::ChangeWidget(`id(`pr), `Value, prog);
	UI::ChangeWidget(`id(`pr), `Label, sformat("Progress %1 out of 4", prog));
    }
    
    UI::CloseDialog();
}
		

Example 2: ProgressBar2.ycp

{
    UI::OpenDialog(
	       `VBox(
		     `Heading("Adjust the volume"),
		     `ProgressBar(`id(`vol), "Volume", 100, 50),
		     `HBox(
			   `PushButton(`id(-5), "<<"),
			   `PushButton(`id( 5), ">>")
			   )
		     )
	       );
    any ret = nil;
    
    while (true) {
	ret = UI::UserInput();
	if      (ret == `cancel) break;
	else {
	    integer old_volume = (integer) UI::QueryWidget(`id(`vol), `Value);
	    y2debug(sformat("%1", old_volume));
	    UI::ChangeWidget(`id(`vol), `Value, old_volume + (integer) ret);
	}
    }
    
    UI::CloseDialog();
}
		

Back to the widget index


YaST2 Developers Documentation: YCP UI Reference: Widgets

Generated Fri May 21 12:39:01 2004