1.8. Displaying a Widget
You use two separate commands to create a widget and display it, although sometimes they are squished into the same line, which makes them look like the same command. In the examples so far, we've used the Button method to create the button, but nothing is displayed by using that method alone. Instead you have to use a geometry manager to cause the widget to be displayed in its parent widget or in another widget. The most commonly used geometry manager is pack, and to use it, you simply call the pack() method on the widget object like this:
$widget->pack();
For example:
$button->pack();
There are arguments that can be sent to the pack method, but we'll cover those in Chapter 2.
It is not necessary to invoke the pack method on a separate line. The ->pack can be added to the creation of the widget:
$parent->Button(-text => "Bye!", -command => sub { exit })->pack();
The other geometry managers available are grid and place. All three behave differently, and which one you use often depends on the look you are trying to get in your application. Again, look for information on the geometry managers in Chapter 2.