如何在Perl中创建富Web应用程序?

dan*_*dan 3 perl user-interface

我有一个Perl命令行脚本,我想转换为富.跨平台桌面GUI应用程序.什么是最好的方法.我想要Perl中的内部和逻辑代码,但GUI应该是丰富的Web应用程序.

Eri*_*rom 12

我一直在研究CPAN 上的Perl模块XUL :: Gui,它使用Firefox作为主机平台来渲染来自Perl的跨平台gui.您只需在目标平台上安装Firefox即可.它目前正在开发中,但可能足够稳定以满足您的需求.以下是语法外观的简要示例:

use XUL::Gui;

display Window title => 'Foo Processor',
    Hbox(
        (map {
            my $id = $_;
            CheckBox id => $id,
                label   => "use $id",
                option  => sub {shift->checked eq 'true' ? " -$id" : ()}
          } qw/foo bar baz/
        ),
        TextBox( id => 'num', 
             type   => 'number', 
             option => sub {' -num ' . shift->value}
        ),
        Button( label => 'run', oncommand => sub {
            my @opts = map {$ID{$_}->option} qw/foo bar baz num/;
            $ID{txt}->value = `fooproc @opts`;
        }),
    ),
    TextBox( FILL, id => 'txt' );
Run Code Online (Sandbox Code Playgroud)

由于它正在开发中,如果您有任何功能请求(或发现任何错误),请告诉我.

此外,由于您在Firefox中,因此Firefox支持的任何Web技术(canvas,iframe,flash ...)都可以从Perl中完全使用.对于gui组件,您可以使用HTML和XUL标记的任意组合.