I find GladeXML-based programming very refreshing, I used to churn code based on Tk, and this code was a real spaghetti, gui stuff mixed with actions mixed with logic ... horrible.

With Gtk2 and GladeXML you write your code, and seperately you draw your application, glade spews xml describing how your app should look, and you write what this app should do.

And this work equally well under UNIX oses and under windoze ( although on windoze you have to go through painfull process of installing gtk and gladexml - in my case this requires installing compilers etc... ). And the code can look like this:

use Gtk2; use Gtk2::GladeXML; #This loads description of your GUI, from file named #app.glade open (GLADE, "<", $sharedir.$execname.'.glade'); my $gladebuf; while (<GLADE>) { $gladebuf .= $_; } close (GLADE); $gladexml = Gtk2::GladeXML->new_from_buffer($gladebuf); # # This way you get the object you want to work on: my $window=$gladexml->get_widget('window'); # There's nothing stopping you from doing this on-the-fly: $gladexml->get_widget('userName')->set_text($userName); ############ sub on_something_something { my $w=$gladexml->get_widget('SomeWidget'); $w->show_all(); $w->run(); $w->hide(); } # Gtk2->main; exit 0;

And now, you can easily modify your apps look without touching the code, for example, you can take some window and turn it into a tab, or reorganize forms etc etc... This sounds like a great thing for teams with separate UI-designer, but this kind of development feels great even for single person, it's just so much easier not having to think about both functionality and looks at the same time (even if you switch from one to another every second, it's easier to work if you've got two virtual desktops dedicated - one for code, another for GUI).


In reply to Gtk2 + GladeXML by Eyck
in thread Best GUI package for Perl ? by rbutcher

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.