tags:

views:

279

answers:

4

I have a Perl command-line script that I want to convert to a rich. cross-platform desktop GUI application. What's the best method to do it. I want to the internal and the logic code in Perl but the GUI should be rich web application.

+1  A: 

Does it need to be a rich, native-OS style GUI? Or just any old user interface? You could get something up and running very quickly with CGI::Application - it's probably the best balance between clean, maintainable code and a short learning curve. For more heavily duty work, Catalyst seems to be the weapon of choice.

If you want to make a full-featured GUI with menus and draggable dialog boxes etc. Perl is probably not the best candidate.

rjh
+9  A: 

I have been working on the Perl module XUL::Gui on CPAN which uses Firefox as a host platform to render cross platform gui's from Perl. All you need is Firefox installed on the target platforms. It is currently in development, but may be stable enough for your needs. Here is a brief example of how the syntax looks:

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' );

Since it is under development, if you have any feature requests (or find any bugs) let me know.

Also, since you are inside of Firefox, any web technologies that Firefox supports (canvas, iframes, flash...) are fully usable from Perl. For gui components, you can use any combination of HTML and XUL tags.

Eric Strom
+1 @Eric Strom I have not had an opportunity to use it for anything real, but I love `XUL::Gui`.
Sinan Ünür
@Sinan => Thanks, its been a fun project so far. A new release should be out in a few days which adds full trusted chrome support (os integrated drag/drop, native file pickers, etc.) and of course a few bug-fixes.
Eric Strom
@Eric Strom I'll keep an eye on it and give it a whirl.
Sinan Ünür
Eric I tried to run the example it seems intersting and what i want did you have a beginner tutorial of this module to start learn it?
dan
@dan => I have a few example programs in the works, which may go up with the next release. For now, the docs on CPAN for XUL::Gui and XUL::Gui::Manual should explain a bit of it. The actual XUL gui widgets are documented on developer.mozilla.com. XUL::Gui proxies everything from Javascript into Perl, so all of the documentation from Mozilla applies (modulo the Perl <=> Javascript translations which are documented in XUL::Gui::Manual). I will be sure to include a clearer tutorial in the upcoming releases. For now, the XUL Tutorial on Mozilla's site is a good starting point.
Eric Strom
Hey Eric, the email address that PAUSE has for you isn't working. Can you send me an email? I want to talk to you about this module. :)
brian d foy
@Sinan => The update for XUL::Gui (to version 0.40) is now available. @dan => this version includes a preliminary tutorial.
Eric Strom
+1  A: 

If by

the gui should be web for cross platfrom
you mean it should be written using HTML / CSS /JavaScript, one solution is to use HTTP::Server::Simple::CGI in conjunction with CGI::Application and HTML::Template. Browser::Open completes the required minimal functionality.

Sinan Ünür
+1  A: 

Mojolicious is a light but yet powerful Web framework which is particularly useful to wrap scripts into quick and well done Web apps.

We are using it extensively on the local network to let colleagues make use of the scripts we develop on our Unix boxes, whatever their platform. For simple tasks, you can even pack everything (templates and routing) in one file: check Mojolicous::Lite.

i-blis