in reply to The Sweat and Grime of GUI
in thread Where oh where to start (looking)

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
  • Comment on (jcwren) RE: The Sweat and Grime of GUI

Replies are listed 'Best First'.
(jcwren) RE: (2) The Sweat and Grime of GUI
by jcwren (Prior) on Sep 16, 2000 at 00:59 UTC
    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
Web-it? (Re: (jcwren) RE: The Sweat and Grime of GUI)
by gryng (Hermit) on Sep 15, 2000 at 09:12 UTC
    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