Activate your free membership today | Log-in

Tuesday, October 16th, 2007

IWL: A Perl widget library for the web

Category: JavaScript, Library, Perl

Viktor Kojouharov was sick of constantly having html code snippets inside his perl code. He was seeing too many projects where the code was a messy mixture of perl, html, and in some places, javascript. Since he is familiar with the Gtk+ toolkit he decided to make something similar targeted for the Web.

He ended up with IWL which is, in Viktors words:

basically a graphical toolkit, or widget library, much like Gtk+ or the ETK library for enlightenment. The main goal of this library is to create a full blown RIA, without the need to write html in your code. When I started working on it roughly a year and a half ago, there was nothing similar existed for Perl. By using the library where I work, it has so far mostly achieved its main objective (and has also proven to be an excellent subject for my diploma thesis :))

If you are a Perl developer who prefers writing apps in a toolkit style like below, then IWL may be fore you:

PERL:
  1.  
  2.     use IWL;
  3.    
  4.     # create the main container, and a few widgets
  5.     my $page = IWL::Page->new;
  6.     my $frame = IWL::Frame->new;
  7.     my $iconbox = IWL::Iconbox->new
  8.         (width => '800px', height => '600px');
  9.     my $button = IWL::Button->newFromStock
  10.         ('IWL_STOCK_CANCEL');
  11.     my %some_icon_info = ("foo.jpg" => 'foo', "bar.png" => 'bar');
  12.  
  13.     # Setting up the icons and adding them to the iconbox
  14.     foreach (keys %some_icon_info) {
  15.         my $icon = IWL::Iconbox::Icon->new;
  16.         $icon->setImage($_);
  17.         $icon->setText($some_icon_info{$_});
  18.         $icon->setDimensions('64px', '64px');
  19.         $icon->setSelected(1) if $_ == 'something';
  20.         $iconbox->appendIcon($icon);
  21.     }
  22.  
  23.     $page->appendMetaEquiv("Cache-control" => "no-cache");
  24.     $frame->setLabel("Frame label");
  25.     # Adding the children to their parents
  26.     $frame->appendChild($iconbox);
  27.     $frame->appendChild($button);
  28.     $page->appendChild($frame);
  29.  
  30.     # Finally printing the page
  31.     $page->print;
  32.  

Posted by Dion Almaer at 12:37 am

+++--
3 rating from 19 votes

2 Comments »

Comments feed TrackBack URI

Great! Now a GUI designer could be written for such - it’s much more easier to do with a toolkit-style system than a plain HTML-templating based one.

If you look at the NetCraft stats published yesterday, you can see that IIS has a serious gain, and it would be hard to say .NET and its design tools aren’t to be taken into account:

http://news.netcraft.com/archives/2007/10/overalld.gif

So, toolkit-based approach and better IDEs would probably help out some developer communities.

(Personally I never liked .NET and I still prefer to write javascript rather than generate it - but trends are clear, some will need to move)

Comment by Adam Nemeth — October 16, 2007

How about performance in larger websites? Will it scale?

Comment by Teemu Arina — October 16, 2007

Leave a comment

You must be logged in to post a comment.