1.3. Why Use a Graphical Interface?

Hopefully, you bought this book (or are considering it in the bookstore) because you have some idea of why you might want to use a graphical interface for one or more of your scripts. Just in case you don't, read on....

Because you are familiar with writing Perl scripts, you understand the ways you can get information in and out of one. It usually involves a combination of reading/writing files, command-line options, and possibly, data in or out at application runtime (STDIN/STDOUT, using pipes (|) or <>. Certain applications can run with no input, and others, such as an installation script, require constant information fed to it from the user: Do you want to install this file? Can I overwrite this DLL? Do you want to create this directory? Do you want the help files? Sometimes you can set up a bunch of defaults so the user just has to press return to say yes, but then they are stuck sitting at the keyboard and waiting for the next question to come up. Wouldn't it be nice to gather all that information up front and then have the user press a Go button to execute all the steps after the decisions were made?

A GUI interface adds a little flair and professionalism to an application. However, there are times when it would be overkill to add a GUI to a script. If all you are doing is reading in one file, munging a bit with no user input, and spitting out another, a GUI would be silly and unnecessary. GUI interfaces work best where you require a lot ...

Get Learning Perl/Tk now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.