Prima
view release on metacpan or search on metacpan
pod/Prima/faq.pod view on Meta::CPAN
use POE 'Loop::Prima';
use Prima qw/Application/;
use AnyEvent;
You can call C<AnyEvent::detect> to check if the implementation is
C<'AnyEvent::Impl::POE'> if you want to use Prima's event loop or it should be
the event loop implementation you expect such as C<'AnyEvent::Impl::EV'>;
If you use L<POE::Loop::Prima> then you can continue to call C<run Prima> and
should not call L<AnyEvent>'s condition variable C<recv> function.
If you want to use another event library implementation of L<AnyEvent>, you have
to not call C<run Prima> but instead call L<AnyEvent>'s condition variable
C<recv> function.
You have to use C<$::application-E<gt>yield> in an C<AnyEvent-E<gt>timer> object to
allow for the Prima UI to update periodically, if you're not using
L<POE::Loop::Prima>.
See full example in F<examples/socket_anyevent.pl> and
F<examples/socket_anyevent_poe.pl>.
=head2 How do I post an asynchronous message?
C<Prima::Component::post_message> method posts a message through the system event dispatcher
and returns immediately; when the message is arrived, C<onPostMessage> notification is triggered:
use Prima qw(Application);
my $w = Prima::MainWindow-> create( onPostMessage => sub { shift; print "@_\n" });
$w-> post_message(1,2);
print "3 4 ";
run Prima;
output: 3 4 1 2
This technique is fine when all calls to the C<post_message> on the object are
controlled. To multiplex callbacks one can use one of the two scalars passed
to C<post_message> as callback identification. This is done by
L<Prima::Utils/post>, that internally intercepts C<$::application>'s
C<PostMessage> and provides the procedural interface to the same function:
use Prima qw(Application);
use Prima::Utils qw(post);
post( sub { print "@_\n" }, 'a');
print "b";
run Prima;
output: ba
=head2 Now to address widgets inside TabbedNotebook / TabbedScrollNotebook ?
The tabbed notebooks work as parent widgets for C<Prima::Notebook>, that
doesn't have any interface elements on its own, and provides only page flipping
function. The sub-widgets, therefore, are to be addressed as C<<
$TabbedNotebook-> Notebook-> MyButton >>.
=head2 How to compile a Prima-based module using XS?
Take a look at L<Prima::IPA>, L<Prima::OpenGL>, L<Prima::Image::Magick>, L<PDL::PrimaImage>,
and L<PDL::Drawing::Prima> . These modules compile against Prima dynamic module,
start from there. Note - it's important to include PRIMA_VERSION_BOOTCHECK in the "BOOT:"
section, to avoid binary incompatibilities, if there should be any.
=head2 How do I generate Prima executables with PAR?
You'll need some files that PAR cannot detect automatically. During the compilation
phase Makefile.PL creates utils/par.txt file that contains these files. Include them with this
command:
pp -A utils/par.txt -o a.out my_program
=head1 AUTHOR
Dmitry Karasik, E<lt>dmitry@karasik.eu.orgE<gt>.
=head1 SEE ALSO
L<Prima>
( run in 1.058 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )