YaST2 Developers Documentation: YCP UI Reference: Widgets



YCP UI Widget Reference

Back to the widget index

RadioButton Clickable on/off toggle button for radio boxes

Description

A radio button is not usefull alone. Radio buttons are group such that the user can select one radio button of a group. It is much like a selection box, but radio buttons can be dispersed over the dialog. Radio buttons must be contained in a RadioButtonGroup.

Arguments

string label

Optional

boolean selected

Special Properties

boolean Value the state of the RadioButton ( on or off )
string Label the RadioButton's text

Sample Usage

`RadioButton( `id( `now ), "Crash now", true )

Examples

Example 1: RadioButton1.ycp

{
    UI::OpenDialog(
	       `RadioButtonGroup(`id(`rb), 
				 `VBox(
				       `Label("How do you want to crash?"),
				       `Left(`RadioButton(`id(0), "No&w")),
				       `Left(`RadioButton(`id(1), "&Every now an then" )),
				       `Left(`RadioButton(`id(2), "Every &five minutes", true)),
				       `Left(`RadioButton(`id(3), "Ne&ver", true )),
				       `HBox(
					     `PushButton(`id(`next), "&Next"),
					     `PushButton("&OK")
					     )
				       )
				 )
	       );
    
    while (true)
    {
	any ret = UI::UserInput();
	if (ret == `next)
	{
	    integer current = (integer) UI::QueryWidget(`id(`rb), `CurrentButton);
	    current = (current + 1) % 4;
	    UI::ChangeWidget(`id(`rb), `CurrentButton, current);
	}
	else break;
    }
    
    UI::CloseDialog();
}

					      
		

Example 2: RadioButton2.ycp

{
    UI::OpenDialog(
	       `RadioButtonGroup(`id(`rb), 
				 `VBox(
				       `Label("How do you want to crash?"),
				       `Left(`RadioButton(`id(0), `opt(`notify), "No&w")),
				       `Left(`RadioButton(`id(1), `opt(`notify), "&Every now an then" )),
				       `Left(`RadioButton(`id(2), `opt(`notify), "Every &five minutes")),
				       `Left(`RadioButton(`id(3), `opt(`notify), "Ne&ver", true )),
				       `HBox(
					     `PushButton(`id(`next),  "&Next"),
					     `PushButton(`id(`close), "&Close")
					     )
				       )
				 )
	       );
    
    while (true)
    {
	any ret = UI::UserInput();

	if ( ret == `close ) break;
	else if (ret == `next)
	{
	    y2milestone("Hit next");
	    integer current = (integer) UI::QueryWidget(`id(`rb), `CurrentButton);
	    current = (current + 1) % 4;
	    UI::ChangeWidget(`id(`rb), `CurrentButton, current);
	}
	else
	{
	    y2milestone("Hit RadioButton #%1", ret);
	}
    }

    y2milestone("Terminating.");
    
    UI::CloseDialog();
}

					      
		

Example 3: Frame2.ycp

{
    UI::OpenDialog( `VBox(
		      `Frame ( "CPU &Speed",
			       `RadioButtonGroup(
						 `VBox(
						       `Left(`RadioButton("Normal"	)),
						       `Left(`RadioButton("Overclocked"	)),
						       `Left(`RadioButton("Red Hot"	)),
						       `Left(`RadioButton("Melting", true ))
						       )
						 )
			       ),
		      `PushButton("&OK")
		      )
		);
    UI::UserInput();
    UI::CloseDialog();
}
		

Back to the widget index


YaST2 Developers Documentation: YCP UI Reference: Widgets

Generated Fri May 21 12:39:01 2004