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

Pleasant greetings!

I have the task of concocting a GUI that will rest atop C code, which rests atop Perl. This GUI must be worked up in such a way that it will return directory tree results, and display file contents, based on data selected by the user...and said users could be on any given platform.

I am entirely new to Perl, but not to coding...yet I am befuddled by the plethora of results from the mighty 'Net, and seek clarity of direction from your learned selves. Thank you.

Replies are listed 'Best First'.
Re: A quest for a GUI
by liverpole (Monsignor) on Feb 04, 2006 at 21:52 UTC
    Hello, GivingTree, and welcome to the Monastery!  I hope your experience here is an enjoyable one.

    I'm curious, first of all, as to why you are building a GUI that will rest atop C code, which rests atop Perl; are you intending to write the GUI in C, and call the C code from Perl?  Or do you mean to write the GUI in Perl? (which may be a somewhat daunting task if you're new at Perl, but I guess it's one way to "get your feet wet").

    Either way, there are solutions, but you may need to explain a little more exactly which path you're trying to take.  It will also help us to answer your question if you clarify what things you've tried already, if any, and what obstacles you've run into.


    @ARGV=split//,"/:L"; map{print substr crypt($_,ord pop),2,3}qw"PerlyouC READPIPE provides"
Re: A quest for a GUI
by GrandFather (Saint) on Feb 04, 2006 at 21:56 UTC

    You could perhaps narrow the range of replies a little by saying whether you want to generate a cross-platform result, or ar targeting for a particular platform.

    GUI on top of C - doesn't that mean you want C compatible GUI code, in which case the Perl solutions (such as Tk) are of no help. Or is the mention of C a red herring in which case Tk is an answer.

    Does the GUI have to look particuarly native? Again taking Tk as an example, it mostly does what you expect, nut there tend to be non-native behaviour in places - at least in the eyes of a Windows user.


    DWIM is Perl's answer to Gödel
Re: A quest for a GUI
by zentara (Cardinal) on Feb 05, 2006 at 11:14 UTC
    This ought to show you the basics, of course there are many,many other approaches. You need to be more specific about the C program, how it works, etc. Does it take commands on STDIN or is it a one-shot-deal, etc?
    #!/usr/bin/perl use warnings; use strict; use Tk; use IPC::Open3; $|=1; my $pid = open3(\*IN,\*OUT,0,'/bin/sh'); my $mw = new MainWindow(-title=>'Left Click->Update Right Click->Clo +se'); $mw->fontCreate('medium', -family=>'courier', -weight=>'bold', -size=>int(-14*14/10)); my $text = $mw->Scrolled('Text', -bg => 'black', -fg => 'lightsteelblue', -width => 130, -height => 30, -font => 'medium', -wrap => 'none' )->pack; $mw->fileevent(\*OUT,'readable',\&get_from); $mw->bind('<ButtonPress-1>' => sub{ $text->delete('1.0','end'); $text->update; print IN "ps auxww --forest\n"; }); $mw->bind('<ButtonPress-3>' => sub{ exit }); print IN "ps auxww --forest\n"; MainLoop; sub get_from { my $pstext = (<OUT>); $text->insert('end',$pstext); $text->see('1.0'); } __END__

    I'm not really a human, but I play one on earth. flash japh
Re: A quest for a GUI
by spiritway (Vicar) on Feb 05, 2006 at 08:29 UTC

    Hello, [id://GivingTree]. Your question was somewhat ambiguous, especially about how things needed to be atop other things. I'm not sure whether this is what you had in mind, but I've found Perl/Tk to be useful and not too difficult to get a GUI going. It's not all that versatile, but it appears to be simpler than other, fancier GUI modules.

Re: A quest for a GUI
by graff (Chancellor) on Feb 05, 2006 at 14:24 UTC
    If you are "new to Perl, but not to coding", you might get the best mileage out of Perl/Tk -- get that installed, if it isn't installed already, and then as soon as you can, run the "widgets" demo script; it will show you how to do exactly what you want to do. This is one of the cleanest and most effective demo programs I have ever seen; I used it to learn Perl/Tk myself several years ago, and it's only gotten better since then.

    Between the demo code and the perldoc man pages (for perl generally and for Tk widgets specifically), you should be able to get off to a quick start.