Prima provides of course a message box. By default, there are some fixed defaults. I needed a flexible solution:
Load this file withsub mcMessage { # This subroutine is called with 5 arguments, which are passed to a list. # The last one can be left out: $mcTextalign will have the default value ta::Center ($myWidth, $myHeight, $myTitle, $myMessage, $mcTextalign) = @_; $mcTextalign ||= ta::Center; $popup = Prima::Dialog->create( size => [$myWidth, $myHeight], text => $myTitle,# if 1, the widget is centered centered => 1, icon => Prima::Icon-> load('icon.png'), ); $popup-> insert( Label => pack => { fill => 'x', side => 'top', pad => 20 }, size => [$myWidth, 30],# default is ta::Center: all the text is centered; ta = text align; other options: ta::Left and ta::Right alignment => $mcTextalign,# if 1, the label height is automatically changed as text extensions change. autoHeight => 1, text => $myMessage, color => cl::Yellow, ); $popup-> insert( Button => pack => { fill => 'none', side => 'top', pad => 15 }, size => [50, 30], text => "Ok", onClick => sub { $popup-> destroy; } );# execute brings the widget in a modal state $popup-> execute(); }# return a true value to the interpreter 1;
use Prima qw(Application Themes Buttons Label); # including the subroutine mcMessage require "/home/reinier/mcMessage.pl"; $mw = Prima::MainWindow-> create( text => "Demo messagewindow", sizeMin => [325, 200], sizeMax => [325, 200], icon => Prima::Icon-> load('icon.png'), ); $mw-> insert( Prima::Button => size => [100, 50], text => 'Message', onClick => sub {# invoking the subroutine mcMessage mcMessage(200, 100, "Demo", "This is a demo text!") }, ); run Prima;