Just starting to play with Prima. Wrote the following code:
use strict;
use warnings;
use Prima qw(Application Edit Buttons);
my $window = new Prima::MainWindow( size => [ 250, 350] );
my $display_field = $window->insert( Edit =>
size => [ 200, 300],
text => '',
centered => 1,
);
my $butoon = $window->insert( Button =>
size => [ 50, 20],
text => 'Click',
place => { x => 120, y => 340 },
onClick => \&button_Click,
);
sub button_Click {
for (1..5) {
$display_field->insert_text("$_\n\n");
}
}
run Prima;
I expected the display field shows 1 2 3 4 and 5 separately in each line from top to bottom but Prima gives me 5 4 3 2 1. Things get displayed upside down.
I've noticed the x and y coordinates in Prima are different. For example, the x coordinate in Prima starts from left bottom corner of the widget, rather than the usual left top corner. I've found some seemingly relevant methods like translate, but I cant't seem to figure out how to get things displayed the expected way? Does someone have some ideas?
Thanks in advance.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.