3. MainWindow

The MainWindow is a widget (1) and is derived from class Window. The class Window is in turn derived from the class Widget. To create the MainWindow, write:
use Prima qw(Application); # invoking the standard module to create the application
Prima::MainWindow-> create( # invoke the class MainWindow
);
run Prima;
To create the MainWindow with width = 300 and height = 200 pixels, set the property 'size':
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. $mw (mainwindow), which calls the method 'set':

use 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;
Although this 'set' command makes clear what it it will do, I do not recommend it. It's not wrong to use the 'set' method, but add as much parameters into create() or new(), at the very least to avoid excessive resize of the window and its initial flickering on the screen. So:
use 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;
Of course, use the 'set' command to change the value of a property at a later moment.

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:

use 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
);
Notice the invocation of the module Prima::Icon. It is necessary to invoke the load function, which is not part, i.e. property, of Prima::MainWindow.

The result:

mainwindow

Footnotes
(1) The word Widget is composed of Window and Gadget and can be best translated as DialogObject. In other languages it is called component or control
(2) https://www.color-hex.com