Gabor Szabo wrote:
I wonder how to add a simple, slightly GUI-like feeling to a command
line application.
If I distribute a script that should be execute on the linux command
line no one is surprised.
When I give the same script to a windows user in many cases he will be
afraid of the
"black DOS window".
So I think I would like to use Wx and open a real window that will behave
as if I ran my script already on the command line.
So here is what I think, I try to make it as clear as I can at this hour....
Create a Wx module that will allow the user to ceate a simple GUI for
his command-linish
application.
The user can type in something in the last line, edit the last line and once
the user presses ENTER the string in the last line is sent to the application.
The application can print to the widget line after line.
The code should then look something like this:
use Module;
Module->setup;
# This would open a window with a textbox or similar
# and connect STDOUT, STDERR and STDIN to the same textbox
print "Your name:"; # goes to the widget
my $name = <STDIN>; # reads one line from the widget
warn("something wrong"); # goes to the widget
I am not sure if it is a really good idea to connect the STDs to my application.
Maybe it would be better to have this code:
use Module;
my ($in, $out, $err) = Module->setup;
# This would open a window with a textbox or similar
# and connect STDOUT, STDERR and STDIN to the same textbox
print $out "Your name:"; # goes to the widget
my $name = <$in>; # reads one line from the widget
print $err "something wrong"; # goes to the widget
# and maybe connect $SIG{__WARN__} to $err as well.
I can imagine that maybe instead of one window there will be 2 or 3
separating the windows of STDOUT, STDERR and STDIN but that's an enhancement.
I don't think this should be too difficult to write but I wonder if
there is such a thing already?
I think you can find exactly what you need in the "old" demo. I'm not
sure why it didn't make it to the new one, probably nobody got round to
rewriting it.
Anyway, you can find the old demo (and some samples) here:
http://sourceforge.net/project/showfiles.php?group_id=15655&package_id=25903
(wxPerl-0.26-samples).
Have a look under 'Miscellaneous' -> 'Process', in particular the "I/O
redirection" bit. It runs "data/cat.pl" in a separate process and
attaches to it's IN/OUT.
If not in which name space should I upload it?
Is there a name space designated for add-on Wx widgets?
I see add-on modules on CPAN under Wx::**** and Wx::Perl::****.
My guess is that new wrappers to existing wxWidgets go under Wx::****
and custom stuff goes under Wx::Perl::****.
Maybe someone else knows what best practice is? (Mattia?)
Cheers,
Huub Peters