http://qs321.pair.com?node_id=372063

diggernz has asked for the wisdom of the Perl Monks concerning the following question:

I am creating a frontend to a Database running on a Windows Platfrom (XP) on the same machine. In order to use Perl do i have install apache and the related modules to run CGI programs? The system is not required to be web capable. Is there other options for creating interfaces with Perl rather than using an internet browser? Any advise or suggestions would be great. Thanks

20040706 Edit by broquaint: Changed title from 'Intefaces'

Replies are listed 'Best First'.
Re: Creating Win32 User Interfaces with Perl
by gellyfish (Monsignor) on Jul 06, 2004 at 12:21 UTC

    For building a general purpose user interface for an application CGI is probably going to be your last choice in most cases - fortunately on Windows you have some choices:


    I am sure there are others I have forgotten about.

    /J\

      I am sure there are others I have forgotten about.

      ...like the command line if there's no need for a GUI either.

      Update: See Downloading the Latest Version of Perl if you don't have perl on your computer yet.

      Cheers, Sören

Re: Creating Win32 User Interfaces with Perl
by crabbdean (Pilgrim) on Jul 06, 2004 at 14:23 UTC
    Additionally to the other posts here I've been using Tk and creating some great little apps. It finally adds a more professional looking application look to many of my scripts. Once I got use to the syntax it can be pretty quick to write a TK GUI. Using TK requires you to learn a new way of structuring your program because thinking in application windows structure is different to writing a standard script.

    Additionally, once your GUI is written compiling it into a standalone EXE I've found can be very simple but can also become a complicated mish-mash depending on what you are attempting to do. The standard TK gui runs with an corresponding console. At times I've used console this as part of the application and left it there, at other times I didn't want it to appear. I've already tackled a lot of these types of problems in my own posts to perlmonks. I won't add links to all the nodes here but check out my user node. There is a lot of links to stuff in there. Feel free to email me directly if you have any questions.

    UPDATE: This link http://theoryx5.uwinnipeg.ca/perltk/ was the first article I read on Tk, it was a great quick intro with lots of working examples. It will give you a good idea of the syntax behind Tk as well.

    Dean
    The Funkster of Mirth
    Programming these days takes more than a lone avenger with a compiler. - sam
    RFC1149: A Standard for the Transmission of IP Datagrams on Avian Carriers
Re: Creating Win32 User Interfaces with Perl
by Joost (Canon) on Jul 06, 2004 at 12:36 UTC
Re: Creating Win32 User Interfaces with Perl
by dfaure (Chaplain) on Jul 06, 2004 at 14:41 UTC

    You may use WxPerl as an alternative of Tk. Still not very well documented but the results are nice.

    ____
    HTH, Dominique
    My two favorites:
    If the only tool you have is a hammer, you will see every problem as a nail. --Abraham Maslow
    Bien faire, et le faire savoir...

      I second that wxPerl gets nice results.

      I disagree that it is not well documented. See wxPerl Downloads for the available documentation. The only difficulty is translating the documentation into wxPerl notation (which once you get the hang of it is not that hard). There are also wxPerl specific notes contained in the documentation indicating any differences in wxPerl.

      I would have no hesitation to recommend wxPerl to anyone looking to create a GUI.

        Speaking of documentation... At YAPC::NA::2004, there was a nice presentation which was an introduction to using WX with perl... Basically, if you've ever programmed in Java (shudder) with their Swing GUI (shudder), it's basically the same thing. Eg, there's an event loop, and then you create objects, and coelesce them into the same form...


        ----
        Zak - the office
      Still not very well documented but the results are nice.
      How do you figure?
      perldoc Wx
      
      NAME
          Wx - interface to the wxWidgets GUI toolkit
      
      SYNOPSIS
              use Wx;
      
      DESCRIPTION
          The Wx module is a wrapper for the wxWidgets (formerly known as
          wxWindows) GUI toolkit.
      
          This module comes with extensive documentation in HTML format; you can
          download it from http://wxperl.sourceforge.net/
      

        My apologizes, WxPerl IS in fact documented, but most of the documentation is introduction material and perl object model oddities. Samples are merely "hello world", and more elaborated samples are only available in C++. I know how it can be difficult and time consuming writing such documentation. Now most of the time is still dedicated to make it work.

        IMHO, WxPerl despite its real power, is still lacking of an accompagning book (there's here matter for a Chapter XI of the Perl In A Nutshell, even perhaps for a dedicated tome [which animal? *g*]). But don't be mistaken about my remarks, I DO prefer from far using WxPerl than Tk...

        ____
        HTH, Dominique
        My two favorites:
        If the only tool you have is a hammer, you will see every problem as a nail. --Abraham Maslow
        Bien faire, et le faire savoir...

Re: Creating Win32 User Interfaces with Perl
by JamesNC (Chaplain) on Jul 06, 2004 at 15:08 UTC
    In addition to Tk, and Win32::Gui, there is also Gtk.

    I have become a big fan of WxPerl which I am switching over to from being a long time advocate of Tk. WxPerl Home - Win32 Binaries

    I would use a CGI based app if I wanted to deploy a front-end to a database. If you wanted to run CGI apps, then you should indeed install a web service on your XP box, like Apache, MS-IIS.

    I am not a fan of using the console for tasks such as this on XP. And straight from the docs on Win32::Console::ANSI Windows NT/2000/XP does not support ANSI escape sequences in Win32 Console applications. This module emulates an ANSI console for the script which uses it. So, don't even bother going there.

    JamesNC

      I would use a CGI based app if I wanted to deploy a front-end to a database

      Why? diggemz specifically said "The system is not required to be web capable." - a web based application requires you to jump through hoops to manage state and maintain database connections, and you have a rather impoverished set of controls available. A real GUI client application will have none of the above problems and will (in a well designed program) win in usability terms.

      /J\

        Why? Lots of reasons, here are a few:
        1. Only have to change code in one place rather than many (Which is what I want when I plan to quickly deploy - and add new features in response to a end users requirements.)
        2. Easier to fix bugs and add features in one place rather than many.
        3. HTML is designed to display information across platforms.
        4. I don't have to worry about Perl being on someones machine or about building a executable or about their environment.
        5. I most likely don't have to train somone how to use the Web based application.
        6. I can more easily limit access to the information because that capability is built into most web servers.
        7. Implementation would be fast and flexible.
        Honestly, with CSS, web pages can be very sophisticated and look great.
        I simply offered my opinion based on my experiences with doing it both ways. He said it was not required, he didn't say, it was not acceptable to use the web.

        Cheers,
        JamesNC
Re: Creating Win32 User Interfaces with Perl
by jplindstrom (Monsignor) on Jul 06, 2004 at 16:58 UTC
Re: Creating Win32 User Interfaces with Perl
by KeighleHawk (Scribe) on Jul 06, 2004 at 16:31 UTC

    Another GUI Toolkit that has been on my todo list for sometime to look into is Prima. It is available for many platforms. Thier homepage is here:

    http://www.prima.eu.org/

    It looks quite nice but I do not yet have any experience with it. It does have an email list for help and discussion.

    Another one I found while scrounging aroung was Guido at:

    http://guido.sourceforge.net/

    Again, don't know much about it, but it does look like it has seen no updates in the last couple years...

Re: Creating Win32 User Interfaces with Perl
by JSchmitz (Canon) on Jul 06, 2004 at 18:53 UTC
    Is there some special reason that you need a graphical interface? I am not sure why you are talking about CGI and Apache those seem totally unrelated to what you are trying to do. If you need a GUI program in Perl you can install the Tk widget like so: "perl -MCPAN -e shell" then at the prompt type: install Tk - on a Windows system (I assume you are using ActiveState go Perl\bin and type PPM - when the prompt comes up type: install Tk

    Once the module is installed you can start out by creating simple widget like programs and progress up to what you are trying to do. Time to get up to speed depends on how much Perl you know and how much programming chops you have.

    Here is a sample of Hello World! in Tk:
    #!/usr/bin/perl -w use Tk; my $mw = MainWindow->new; $mw->Button(-text => "Hello World!", -command =>sub{exit})->pack; MainLoop;
    Perl does much more than web stuff
    Happy Coding!

    Jeffery
Re: Creating Win32 User Interfaces with Perl
by Wassercrats (Initiate) on Jul 06, 2004 at 20:38 UTC
    See Perl web browsers. It mentions ways to use CGI without a web server in a couple of the posts. Since it sounds like you're willing to do things the right way, you probably shouldn't use an interface that requires a browser, but other's have made it sound like you'd need a web server for CGI, and that's not true.

    On the other hand, I already have an HTML form-based interface for a script, and it's pretty complex, so I'm still thinking of using it for the non-web version of the interface. I think I'll be doing that by embedding VBScript in the HTML to write the form data to a file, then have the script I'm submitting to read the file since it won't be able to read the form data in the normal cgi way. But I'm still looking for free server emulators that would save me the trouble of creating something with VBScript.

Re: Creating Win32 User Interfaces with Perl
by diggernz (Sexton) on Jul 07, 2004 at 04:33 UTC
    Thankyou all for your responses (overwhelming). I have been investigating the Tk module to use as the Frontend for this database. This is a Microsoft SQL 2000 Database and I have creating a connection using the DBI and DBD::ODBC module combination. We will be using the MSDE version of Microsoft SQL as it runs on a non server windows platform (its also free). This is for my final project of my degree. I am just wanting to create an interface to do basic inserts and searches of the database. I was wanting to use Perls Chart abilities to create reports as well as the SENDMAIL module to create an ordering system.It seems like a lot of overhead required (eg installing web server) to create a CGI perl based interface. In addition, this system requires the need to create reports based on database data. Can i integrate Microsoft Office applications? Is there an alternative? Tk looks nice, but a lot of work compared to a CGI interface through a novice perl programmer eyes. Thankyou for your expertise.
      A really great way to make database reports is with the Spreadsheet::WriteExcel module. It creates .xls files that work in Excel (and some other spreadsheets). You can put bitmaps and fancy formatting in the spreadsheet. It does not have commands for drawing graphs.

      Database output is often tabular, so a set of linked worksheet tabs can be a great way to present data.

      It should work perfectly the first time! - toma

      Just an FYI about the performance of the MSDE. This quote taken from this page.

      MSDE is designed for low volume applications. There is a workload governor that will degrade performance if there are more than five concurrent batch workloads. As more workloads are added, the system will continue to slow.
Re: Creating Win32 User Interfaces with Perl
by kral (Monk) on Jul 07, 2004 at 09:10 UTC
    If you want a non-portable interface, I suggest use Win32::GUI with "The GUI Loft" for design the GUI.
    Otherwise, for portable interface, I suggest Gtk2-Perl 'cause it's easy almost like Tk and it has a variety of tools for RAD development (like Glade).
    WxPerl is a very valid framework too, maybe it's little too much OO, imho. WxPerl has a RAD tool too (WxGlade) but it is written in python (argh!).
    Negative thing of Gtk2-perl is the necessity to install the relative libraries.
    ----------
    kral
    (I apologise for my english!)
Re: Creating Win32 User Interfaces with Perl
by astroboy (Chaplain) on Jul 08, 2004 at 03:38 UTC
    As you can see, the monks have pointed out plenty of alternatives to the browser interface. However, using a CGI interface can be quite useful, especially if you roll your own web server (see Embedding Web Servers at perl.com). You can bundle the web server in your code, and I find it useful for making a simple configuration interface for my apps.