in reply to Where oh where to start (looking)

Well, GTK+ seems to be a somewhat accepted standard in the *NIX world (unless you are a KDE user). There are also windows ports of the libraries, so that makes them somewhat cross-platform. So if you are indeed leaning towards a GUI frontend, i'd check out the GTK+ homepage, as well as the tutorial for the perl bindings.

There exists an O'Reilly book called Learning Perl/TK if you wish to go that route. However, the book is extremely buggy (some of the included examples don't even compile). You can find the errata online, but thats a definite hassle.

Most any GUI frontend is still going to require the backend written in good old perl, so you can go ahead and start the project/module/etc, and tie it to a GUI when you finally decide the best course of actions.

On a side note, TK/GTK+ programming is highly untrivial. You may even want to check out the Xlib Programming Manual to get an overview on how GUI's talk to eachother, themselves, and to the underlying OS.
<br< BlueLines

Disclaimer: This post may contain inaccurate information, be habit forming, cause atomic warfare between peaceful countries, speed up male pattern baldness, interfere with your cable reception, exile you from certain third world countries, ruin your marriage, and generally spoil your day. No batteries included, no strings attached, your mileage may vary.

Replies are listed 'Best First'.
The Sweat and Grime of GUI
by gryng (Hermit) on Sep 15, 2000 at 07:46 UTC
    Thank you very much BlueLines, both for your informative, and speedy response.

    I'm not sure if I really want to dig into the grime that is called GUI's. (no matter how manly that would be :) ).

    I really want to take an approach that would be something like GLADE (or at least what I know of what GLADE is). I don't mean I necessarily want a drag and drop GUI contruction kit (ala VB-sickness). Rather, I just don't want to be required to do all the low level grunt work unless I get backed into a corner without a stick.

    I don't mind having to deal with somethings, but I do not intend on making this program a drag and drop GUI jukebox where you can take your GNOME/KDE aware filebrowser program and throw mp3s at mine!

    (in fact, I'm not really enthusiastic about using GUI unless it does make my life simpler (as a programmer) or makes the UI much much much more powerful -- I'm quite happy with a TUI or even a command line-ish interface).

    But again, I would like to stress my gratitude for this response, and I am going to go look at the GTK+ site right now!

    Cheers and Thanks,
    Gryn

      While I can understand wanting to write/use a GUI for the experience, I'm of the opinion that someone has already written a helluva GUI. I call it a 'Web Browser'...

      Seriously, with the modules available, you can write a webserver in Perl for a standalone app, or you can write something that runs under Apache, with or without mod_perl. Now you've got a client/server app, so you can use your laptop in the kitchen to manage it, stream it to work (if you've got the bandwidth), and (IMHO) you've better future-proofed it (/me thinks that web apps will survive longer than platform dependant GUI apps).

      My basic take on anything I'm doing for my projects is that a web browser is going to be available on any computer I have. It's also gonna be networked, either with cable, 802.11b, or a cell modem. So, why not make it usable from everywhere/anywhere?

      I've also seen apps written in Perl/Tk, GTK+, whatever, and frankly, I think they are about as visually unappealing as you can get. And a lot more work.

      --Chris

      e-mail jcwren
        Apparently, I don't seem to have much of a life, and decided to take a few minutes to write a standalone web server app that would (more or less) simulate playing an MP3. The comments pretty much say it all.
        #!/usr/local/bin/perl -w # # Danger! Danger! Running with scissors! Carry handgrenades withou +t pins! Driving without brakes! # # This code is a super simple super stupid web-based MP3 player conce +pt program. It has *no* error # checking. It probably has security holes out the whazoo. It uses +a template system so lame, the # person who wrote it should be shot (wait a minute!). If two users +try to use it at the same time, # bad things will happen (because of the stupid HTTP::Daemon not supp +orting printing a string as a # response, not so much anything else). And worst of all, I wrote it + using Windows(tm) based tools # (VisualSlickEdit and HotMetalPro ROCK!) # # On the other hand, it does demonstrate a standalone web-based appli +cation, using all those great # little CPAN modules. I'm sure [merlyn] and [tilly] will pump dozen +s of rounds into it, saying # how there's a better way to do it. On the third hand, I wrote it h +alf an hour, it passes use strict # and -w, and I did it first. Nyah! (I also don't care that stuff go +es past column 80) # # Last, and leastly, sometimes if you control-c out of the app (or Do +g forbid, it should crash), you # may have to wait a few seconds for the socket to clear before resta +rting it. I don't know why the # socket stays allocated for a brief time after the app has exited. # use strict; use HTTP::Daemon; use HTTP::Status; use CGI; my $serverport = 2000; my %actions = ('Next' => \&mp3_next, 'Last' => \&mp3_last, 'Stop' => \&mp3_stop, 'Play' => \&mp3_play, 'Vol +10%' => \&mp3_volumeup, 'Vol -10%' => \&mp3_volumedown, 'Left 10%' => \&mp3_balanceleft, 'Right 10%' => \&mp3_balanceright, ); my @tracklist = ('Pink Floyd - Dark Side Of The Moon', 'Widespread Panic - Bombs & Butterflies', 'Allgood - Trilogy', 'Mox - Dr. Bombay', 'Soundtrack - Debbie Does Dallas', 'The Orb - Perpetual Dawn', 'Tangerine Dream - Underwater Sunlight' ); my $mode = 'Stopped'; my $curtrack = 0; my $volume = 50; my $balance = 50; # # # { my $htmltext = 0; # # Stupid HTTP::Daemon doesn't support sending a string as a respon +se, only a file. So # we generate index.html, and keep the page in $htmltext for when +we change parameters. # { local $/ = undef; $htmltext = <DATA>; } my $d = new HTTP::Daemon (LocalPort => $serverport) || die "Can't b +ind to port! ($serverport already in use?)"; print "Please contact me at: <URL:", $d->url, ">\n"; while (my $c = $d->accept) { while (my $r = $c->get_request) { if ($r->method eq 'GET') { ultralame_template_system ($htmltext); $c->send_file_response ("index.html"); } else { my $q = new CGI ($r->content); &{$actions {$q->param ('Action')}} if ($q->param ('Action' +)); ultralame_template_system ($htmltext); $c->send_file_response ("index.html"); } } $c->close; undef ($c); } } sub ultralame_template_system { my $temptext = shift; $temptext =~ s/<!--##rewrite trackname-->/@tracklist [$curtrack]/ei +; $temptext =~ s/<!--##rewrite mode-->/$mode/ei; $temptext =~ s/<!--##rewrite volume-->/$volume/ei; $temptext =~ s/<!--##rewrite balance-->/$balance/ei; open (FH, ">index.html") || die "Can't open file: $!"; print FH $temptext; close FH; } # # Normally, I don't condone oneliners like this, but for sample code, + it'll work # sub mp3_next { $curtrack = ++$curtrack % scalar @tracklist; } sub mp3_last { $curtrack = --$curtrack % scalar @tracklist; } sub mp3_stop { $mode = 'Stopped'; } sub mp3_play { $mode = 'Playing'; } sub mp3_volumeup { $volume = min (100, $volume + 10); } sub mp3_volumedown { $volume = max (0, $volume - 10); } sub mp3_balanceleft { $balance = max (10, $balance - 10); } sub mp3_balanceright { $balance = min (100, $balance + 10); } # # # sub min { return ($_[0] < $_[1] ? $_[0] : $_[1]); } sub max { return ($_[0] > $_[1] ? $_[0] : $_[1]); } __DATA__ <!DOCTYPE HTML PUBLIC "-//SoftQuad Software//DTD HoTMetaL PRO 5.0::199 +81217::extensions to HTML 4.0//EN" "hmpro5.dtd"> <HTML> <HEAD> <TITLE>Stupid Sample Code For a Pico MP3 Server</TITLE> </HEAD> <BODY> <FORM METHOD="POST"> <TABLE BORDER="0\" ALIGN="CENTER"> <TR> <TD><FONT SIZE="3" FACE="Verdana">Track Now Playing:</FONT></T +D> <TD><FONT SIZE="3" FACE="Verdana"><B><!--##rewrite trackname-- +></B></FONT></TD> </TR> </TABLE> <BR> <TABLE BORDER="0" ALIGN="CENTER"> <TR> <TD><FONT SIZE="3" FACE="Verdana">Mode:</FONT></TD> <TD><FONT SIZE="3" FACE="Verdana"><B><!--##rewrite mode--></B> +</FONT></TD> </TR> <TR> <TD><FONT SIZE="3" FACE="Verdana">Volume:</FONT></TD> <TD><FONT SIZE="3" FACE="Verdana"><B><!--##rewrite volume-->%< +/B></FONT></TD> </TR> <TR> <TD><FONT SIZE="3" FACE="Verdana">Balance:</FONT></TD> <TD><FONT SIZE="3" FACE="Verdana"><B><!--##rewrite balance-->% +</B></FONT></TD> </TR> </TABLE> <BR> <TABLE BORDER="0" ALIGN="CENTER"> <TR> <TD><INPUT TYPE="SUBMIT" NAME="Action" VALUE="Next"></TD> <TD><INPUT TYPE="SUBMIT" NAME="Action" VALUE="Last"></TD> <TD><INPUT TYPE="SUBMIT" NAME="Action" VALUE="Stop"></TD> <TD><INPUT TYPE="SUBMIT" NAME="Action" VALUE="Play"></TD> <TD><INPUT TYPE="SUBMIT" NAME="Action" VALUE="Vol +10%"></TD> <TD><INPUT TYPE="SUBMIT" NAME="Action" VALUE="Vol -10%"></TD> <TD><INPUT TYPE="SUBMIT" NAME="Action" VALUE="Left 10%"></TD> <TD><INPUT TYPE="SUBMIT" NAME="Action" VALUE="Right 10%"></TD> </TR> </TABLE> </FORM> </BODY> </HTML>


        --Chris

        e-mail jcwren
        I hadn't actually thought about using the web. It is an intriguing prospect though. In fact, I would jump on it, except for one thing.

        Slow response time. That is, unless I'm using something fancy (defined as, it doesn't work in w3m (or lynx), my main web browser), I don't know of a way to do the rapid response you get from a GUI or TUI interface.

        One of the main ideas I'm toying around is a current playlist (er, the playlist is generated by rules automatically) displayed. You could then arrow down to a point where you don't like a song, and go "BANG", and the playlist would be regenerated from that point. Of course, you may need to do this repeatedly or in sucession many times down the list (the idea is that the program gets better as guessing what you want, but you may be picky at the moment, or it just may not have learned yet).

        With a web site that would be a major hinderance in UI speed. If you used something like Java I guess you could remove that problem, but then you are also throwing out my precious w3m :) .

        But, I could be over-reacting and/or I could choose a different design. So, I'll reiterate that I like this idea and I'll give it serious consideration.

        Perhaps, even, it would be nice to simply have multiple interfaces? That is, the web server that just communicates to the mp3-server program. Similarlly a gtk or curses (or even telnet) could also talk to the mp3-server and give it commands?

        Thanks again,
        Gryn

      I don't mean I necessarily want a drag and drop GUI contruction kit (ala VB-sickness).

      VB sickness would be _fine_ by me. I'm wanting to add basic GUIs some tools written in Perl. (So as to 'wizard' them a little for neophyte users)

      The catch is that it needs to be cross platform _and_ I cannot rely on access (or permission) to an appropriate TCP/IP port. (So, AFAIK, browser+server model is out.)

      So text or TK it is (as the distro is almost standard) .

      A 3GL TK front end would be a blessing.



      Butlerian Jihad now!