5. Label

Now we create a MainWindow containing two widgets: the familiar Pusbutton and the new Label. The basic use Prima qw(Application); is now extended into with the module use Prima qw(Application Buttons Label);. MainWindow has two new properties sizeMin and sizeMax which fix the minimal and maximal size (i.e. you cannot resize the window). We also reduced the number of border icons by borderIcons(bi::SystemMenu);. The last feature we've to mention is origin in the PushButton and Label definition: the property positions the two widgets. Notice the [0,0] represents the x-coordinate of 0 and y-coordinate of 0, i.e. the lower left corner of the window.

Clicking the Pushbutton generates a random number, that is displayed in the Label field.

mainwindow

use Prima qw(Application Buttons Label); # invoke the modules Application, Buttons and Label

$mw = Prima::MainWindow-> create(
	text    => "Random",
	sizeMin => [250, 200], # fixed minimal size
	sizeMax => [250, 200], # fixed maximal size
	skin => 'flat',
);

$mw-> borderIcons(bi::SystemMenu);  # system menu button and/or close button ( usually with icon ) is shown

$output = $mw-> insert( 
    Label => 
          origin => [110, 125],
          size   => [50, 50],	           
          text   => "",
          font   => { size => 26, },	
);

$mw-> insert( 
    Button =>
           origin  => [50, 75],
           size    => [150, 50],
           text    => "Random number!",
           default => 1,
           onClick    => sub {
		
                               $random_number = int(rand(100));
                               $output-> set(text => $random_number);

                             },
);

run Prima;
It's no problem to use the origin property to position the widgets of the MainWindow. But it can be done easier with the pack. Read the next section 6. Pack.