To create the MainWindow with width = 300 and height = 200 pixels, set the property 'size':use Prima qw(Application); # invoking the standard module to create the application
Prima::MainWindow-> create(# invoke the class MainWindow
);
run Prima;
use Prima qw(Application);
Prima::MainWindow-> create(
size => [300, 200],# an anonymous array of two integers assigned to the parameter or property name 'size'
);
run Prima;
All widgets have properties (which are scalars). 'size' is a property name of the Widget class and its derivations and got in the MainWindow definition some values. Properties can also get a value in other ways. But first you've to assign the MainWindow definition to a variable, e.g.
Although thisuse Prima qw(Application);
$mw = Prima::MainWindow-> create(
);
$mw-> set(
size => [300, 200],# set the MainWindow size
text => 'Hello',# set the MainWindow title
backColor => 0xFFFFFF,# background white color as heximal decimal constant (2): replace # in the hex code #FFFFFF by 0x
);
run Prima;
Of course, use theuse Prima qw(Application);
$mw = Prima::MainWindow-> create(
size => [300, 200],# set the MainWindow size
text => 'Hello',# set the MainWindow title
backColor => 0xFFFFFF,# background white color as heximal decimal constant (2): replace # in the hex code #FFFFFF by 0x
);
run Prima;
We created the MainWindow of our application, which is the mother of all widgets. The MainWindow
contains and controls other widgets like Buttons, Labels, Inputline, Listbox etc. Before we are going to study how to insert Buttons into the MainWindow, two questions remain:
1. How to give the MainWindow a custom icon?
2. How to center the MainWindow?
Study the update of our MainWindow code:
Notice the invocation of the moduleuse Prima qw(Application);
$mw = Prima::MainWindow-> create(
size => [300, 200],
backColor => 0xFFFFFF,
text => 'Hello',
icon => Prima::Icon-> load('icon.png'),# answer question 1
growMode => gm::Center,# answer question 2
);