Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Easier GUI

by meirgold (Acolyte)
on Oct 16, 2010 at 15:24 UTC ( #865676=perlquestion: print w/ replies, xml ) Need Help??
meirgold has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

As we all know, creating a GUI in perl (using TK) can be a complicated task when it comes to GUIs that are more complex than a text field with a button.

I was wondering which solutions you use for GUIs.

Do you use automatic GUI creators ? Do you combine GUIs from other languages (Java, etc.) ? Any suggestions and/or comments are welcome

Comment on Easier GUI
Re: Easier GUI
by dasgar (Deacon) on Oct 16, 2010 at 15:54 UTC

    Since I've been primarily working in the world of Windows, I've been using Win32::GUI. To help speed up the development, I've been using the GUI Loft. It allows me to quickly set up the GUI look and appearance. However, I then have the to generate the code by hand and refer back to the GUI Loft for the size and location coordinates.

    I can't advocate that Win32::GUI is "best" GUI module/method since it's the only one that I have experience with. However, if you do decide to use it, I'd definitely recommend getting the GUI Loft. Just keep in mind that the GUI Loft hasn't been updated in a long time and is using an older Win32::GUI module than what is currently available, which means that all of its options on objects don't necessarily match up with the current Win32::GUI module.

    I've been meaning to take a look into learning Tk so that I can create more cross-platform GUIs, but haven't gotten around to doing it yet.

Re: Easier GUI
by Anonymous Monk on Oct 16, 2010 at 15:55 UTC
      It seems that this link is no longer active. In any case, I was referring mostly to Linux based systems.
        There were many links, and ZooZ/Guido/TikiArtist/SpecTcl are available
Re: Easier GUI
by zentara (Archbishop) on Oct 16, 2010 at 17:15 UTC
    creating a GUI in perl (using TK) can be a complicated task

    Believe me, writing your code from scratch is alot easier than trying to decipher the boilerplate code produced by the various tools to produce easy GUIs.

    If you were going to go that route, Glade is probably your best bet.

    The problem with boilerplate code is the obtuse naming conventions needed for creating callbacks. For instance instead of a callback called "do_what_button_1_does", you might get sub 1awer4567, and that makes it harder to track down little bugs.

    In reality, the GUI creators are the ones that make it easy for simple gui's, but anything more complicated, you are better off writing it from scratch.

    It takes time to learn either way. Either you can put in a few hours to learn from scratch, or you can put in a few hours learning the easy gui system, whatever it is.

    If you are in a situation, where you are repeatedly making gui's from some simple recipe, and you want to automate it for non-experienced users, then the easy gui creators may be useful.

    Just my opinion. :-)


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: Easier GUI
by kcott (Abbot) on Oct 16, 2010 at 19:53 UTC

    I don't use GUI creators/generators for Perl/Tk. My reasons are much the same as zentara has posted above.

    I often see monolithic code that builds the entire GUI. Apart from being a poor programming technique to start with; it becomes a maintenance nightmare with anything beyond the simplest GUI. I aim for a modular approach. Here's a very rough example:

    use Tk; { my $mw = Tk::MainWindow->new(); configure_main_window($mw); build_menubar($mw); build_toolbar($mw); build_main_content($mw); build_statusbar($mw); } MainLoop; sub build_main_content { my ($mw) = @_; my $main_content_frame = $mw->Frame(); build_input_widgets($main_content_frame); build_output_widgets($main_content_frame); build_action_widgets($main_content_frame); }

    Once you have a basic skeleton, you can use this as a template for all your GUIs. Now you're starting to create your own automated tool.

    You'll find that using this method will give all your GUIs the same look and feel. It also saves a lot of time because you don't need to write every new GUI from scratch.

    If you're building many GUIs, you can write a script which further automates the process. This might be a commandline tool with options like --toolbar (a boolean switch indicating whether to include a toolbar), --title (providing the argument to $mw->title()), and so on. This tool would create the skeleton code for you based on your template.

    At the end of the day, choose whatever suits your needs best. Try to temper your choice with thoughts of: maintenance, extension, debugging, and so on.

    -- Ken

      Thanks everyone for the answers.

      Has anyone tried creating the GUI in a different language (such as Java) and have it interact with the perl script ?
Re: Easier GUI
by merrymonk (Friar) on Oct 17, 2010 at 09:44 UTC
    I have developed a method of defining the GUI in a spreadsheet and then having Perl that interprets the spreadsheet to create the GUI.
    I have used this for the past 6+ years and it works well. In does use the ‘table’ geometry manager which fits in well with a definition based on a spreadsheet table.
    The plus points are that I find it very simple to copy and paste elements from one system to another and it is easy to add more GUI widget types. One minus is that the GUIs produced do tend to look similar.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://865676]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (11)
As of 2014-10-24 10:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (131 votes), past polls