Tuesday, October 16th, 2007

IWL: A Perl widget library for the web

Category: JavaScript, Library, Perl

<p>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:

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

Related Content:

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.