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\
| [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] |
|
|
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.
| [reply] [Watch: Dir/Any] |
Re: Creating Win32 User Interfaces with Perl
by Joost (Canon) on Jul 06, 2004 at 12:36 UTC
|
In order to use Perl do i have install apache and the related modules to run CGI programs?
In order to use Perl you don't have to install apache or the CGI modules (though CGI.pm is in the core distribution).
In order to write CGI programs you will want to use the CGI module, though it's not strictly neccisary. You can run CGI programs on practically any HTTP server (like IIS on windows), it doesn't have to be apache. There's even a couple of perl-only HTTP servers.
If you want other options, well, I like Getopt::Long for command line tools and the Tk GUI. You can also check out Curses or Term::Shell or Term::ReadLine or Gtk or Win32::GUI or Qt
| [reply] [Watch: Dir/Any] |
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...
| [reply] [Watch: Dir/Any] |
|
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.
| [reply] [Watch: Dir/Any] |
|
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...
| [reply] [Watch: Dir/Any] |
|
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/
| [reply] [Watch: Dir/Any] |
|
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...
| [reply] [Watch: Dir/Any] |
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 | [reply] [Watch: Dir/Any] |
|
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\
| [reply] [Watch: Dir/Any] |
|
Why? Lots of reasons, here are a few:
- 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.)
- Easier to fix bugs and add features in one place rather than many.
- HTML is designed to display information across platforms.
- I don't have to worry about Perl being on someones machine or about building a executable or about their environment.
- I most likely don't have to train somone how to use the Web based application.
- I can more easily limit access to the information because that capability is built into most web servers.
- 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
| [reply] [Watch: Dir/Any] |
Re: Creating Win32 User Interfaces with Perl
by jplindstrom (Monsignor) on Jul 06, 2004 at 16:58 UTC
|
There is an excellent node about this: (GUI) Windows Programming FAQ
If I would do this, I'd go with Win32::GUI, The GUI Loft (which I wrote) and probably the Win32::GUI::Grid control for the database result sets (if that's the kind of thing you're after).
/J
Update: Added recommendation | [reply] [Watch: Dir/Any] |
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...
| [reply] [Watch: Dir/Any] |
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 | [reply] [Watch: Dir/Any] [d/l] |
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. | [reply] [Watch: Dir/Any] |
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. | [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] |
|
| [reply] [Watch: Dir/Any] |
Re: Creating Win32 User Interfaces with Perl
by kral (Monk) on Jul 07, 2004 at 09:10 UTC
|
| [reply] [Watch: Dir/Any] |
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. | [reply] [Watch: Dir/Any] |