[comp.windows.x] GUI Perl

throop@aurs01.UUCP (Wayne Throop) (02/19/91)

> cluther@supernet.dallas.haus.com (Clay Luther)
>> allbery@NCoast.ORG (Brandon S. Allbery KB8JRR)

>>(Perl with a GUI interface... the mind boggles.  ;-)
> Actually...we have been tinkering with the idea of writing self-contained X
> widgets and code resources for calling by Perl in order to do just that.

In fact, I am amazed that this has not already been done for Unix, so
that shell scripts can intelligently interact via gadgets, before now.
Even if each gadget needs to be/create/whatever a separate window,
it's still better than almost nothing.

For now, I use a workaround of using "xterm" to create menus,
selection boxes, and so on and on.  Consider, for example, this simple
popup dialog box, in bourne-shell-ese:

    popup_text=`xterm -g 40x2+100+100 -e sh -c 'echo -n "Query: " >/dev/tty
                read answer;echo $answer 1>&3' 3>&1`

I'll leave it as an excersize to interested readers how to hook three
xterms, two awks, and a shell together to give a simple
point-and-shoot interface to the Unix filesystem (that is, select a
file or files upon which to operate in one window (conceptual pane or
gadget), then select a verb (such as "delete" or "display") in a
second, and view output in a third).  I assure one and all it can be
fairly easily done.

The problem, of course, is that the mouse motions needed to use xterms
as selection and/or menu gadgets aren't very optimal... but at least they
are workable for the short term.

Over the longer term, I'm most interested in the upcoming X version of
tooltool by Chuck Musciano (chuck@trantor.harris-atd.com).

( And, of course, if there are other unix-based, shell-programmable
  interfaces to X lurking out there, I'd be interested in hearing
  about them. )

Wayne Throop       ...!mcnc!aurgate!throop

rlh2@ukc.ac.uk (R.L.Hesketh) (02/19/91)

In article <59585@aurs01.UUCP> throop@aurs01.UUCP (Wayne Throop) writes:
>> cluther@supernet.dallas.haus.com (Clay Luther)
>>> allbery@NCoast.ORG (Brandon S. Allbery KB8JRR)
>
>>>(Perl with a GUI interface... the mind boggles.  ;-)
>> Actually...we have been tinkering with the idea of writing self-contained X
>> widgets and code resources for calling by Perl in order to do just that.
>
>In fact, I am amazed that this has not already been done for Unix, so
>that shell scripts can intelligently interact via gadgets, before now.

Now its funny you should mention this 8-).  I have on my screen a collection
of "Perly" buttons.  Each button has an associated interpreted script, be it
perl, sh, csh, ksh or bash (you get the idea).   When a button is pressed the
associated script is executed.  All the buttons are tailorable, you can
change the names, colours, font or add bitmaps.  I got the original idea
from Xerox's Buttons as described in:

	"User-Tailorable Systems: Pressing the Issues with Buttons"
	by Allan Maclean, Kathleen Carter, Lennart Lovstrand
	    and Thomas Moran
	in Proceedings of CHI'90, ACM SIGCHI

The scripts can contain anything.  Along with the buttons themselves there are
a collection of small GUI tools that are used within the scripts to create
simple user interfaces to existing UNIX tools or produce completely new
tools.  A lot of these tools are already publically available:

   xmessage	- on the R4 contrib tape (I have a slightly improved version)
		  "display messages with optional buttons"

   xmenu	- posted to comp.sources.x and also on expo.lcs.mit.edu
		  "single level popup menus"

   xselection	- posted to comp.sources.x and also on expo.lcs.mit.edu
		  "set or retrieve X selections or cut buffers"

   ifc		- InterViews File Chooser (on R4 contrib tape under InterViews)
		  "mac like selection of a filename"

   xprompt	- posted to comp.sources.x (I think .. I got it from somewhere!)
		  by thoth@cis.ufl.edu and mjm@cis.ufl.edu
		  "opens an X window and accepts single lines of input"

   xfields	- not yet available.
		  "forms-entry type dialog boxes for setting of shell variables"

If anybody else has anymore useful tools that are designed for use with shell
scripts or even just ideas then I would like to hear from you!

These tools can be combined in shell scripts to produce some really useful
on-screen utilities and the Perly buttons can also act task accelerators for
iterative tasks such as compiling or document preparation.  For example I
have a "talk" button that provides a windowed version of UNIX talk and all in
80 lines of Bourne shell.

Here's a useful small example script:

#!/bin/sh
ifc -static | while true
do
        read path
        if [ "$path" = "" ]; then
                exit
        fi
        xselection PRIMARY $path
done
--

This displays the "ifc" tool and allows users to select a filename.  When the
name has been double-clicked the fullpath name is set in the PRIMARY
selection which means you can paste it into an xterm or use it by another
script that does a "file=`xselection PRIMARY`" etc.


Richard Hesketh
Computing Officer, Computing Lab., University of Kent at Canterbury,
Canterbury, Kent, CT2 7NF, United Kingdom.
        Tel: +44 227 764000 ext 7620/7590      Fax: +44 227 762811

vladimir@Eng.Sun.COM (Vladimir G. Ivanovic) (02/20/91)

John Ousterhout of Berkeley has Tcl and Tk which implement many (all?) of the
ideas mentioned in this thread.  Tcl and the USENIX paper on tcl is ftp'able
from ucbvax.berkeley.edu in ~/pub and a version (pre-release?) of tk is on
sprite.berkeley.edu.  There is a paper on tk.

-- Vladimir
--
===============================================================================
Vladimir G. Ivanovic                            Sun Microsystems, Inc
(415) 336-2315                                  MTV12-33
vladimir@Sun.COM                                2550 Garcia Ave.
{decwrl,hplabs,ucbvax}!sun!Eng!vladimir         Mountain View, CA 94043-1100
                         Disclaimer: I speak for myself.
===============================================================================

marc@athena.mit.EDU (Marc Horowitz) (02/20/91)

>> >>(Perl with a GUI interface... the mind boggles.  ;-)
>> > Actually...we have been tinkering with the idea of writing self-contained X
>> > widgets and code resources for calling by Perl in order to do just that.
>> 
>> In fact, I am amazed that this has not already been done for Unix, so
>> that shell scripts can intelligently interact via gadgets, before now.
>> Even if each gadget needs to be/create/whatever a separate window,
>> it's still better than almost nothing.
>> 
>> For now, I use a workaround of using "xterm" to create menus,
>> selection boxes, and so on and on.  Consider, for example, this simple
>> popup dialog box, in bourne-shell-ese:
>> 
>>     popup_text=`xterm -g 40x2+100+100 -e sh -c 'echo -n "Query: " >/dev/tty
>>                 read answer;echo $answer 1>&3' 3>&1`
>> 
>> I'll leave it as an excersize to interested readers how to hook three
>> xterms, two awks, and a shell together to give a simple
>> point-and-shoot interface to the Unix filesystem (that is, select a
>> file or files upon which to operate in one window (conceptual pane or
>> gadget), then select a verb (such as "delete" or "display") in a
>> second, and view output in a third).  I assure one and all it can be
>> fairly easily done.

Here we go, off subject again :-)

What kind of machine are you using, a Cray?  Forking xterms to create
menus is, ahh, hardly efficient.  If I tried to get away with that my
users would have me shot in both kneecaps and dropped off the nearest
20-story building onto a bed of rusty nails.  We still have VS2's and
MicroVAX II's around here (try getting money to replace > 300 machines
which "still work") and this would be a dandy way to make sure that
they are even less useable then they are now.

>> If anybody else has anymore useful tools that are designed for use
>> with shell scripts or even just ideas then I would like to hear from
>> you!

anonymous ftp from allspice.berkeley.edu:~ftp/tk.tar.Z is a great
toolkit for simple X programs which are built using scripts at runtime
(despite what you may think, it's still really fast).  tk is
implemented on top of tcl, which is the same system expect is
implemented in.  (tclUsenix90.ps and tkUsenix91.ps on allspice are the
Usenix papers about tcl and tk, respectively.)

		Marc

throop@aurs01.UUCP (Wayne Throop) (02/22/91)

> marc@athena.mit.edu (Marc Horowitz)
>> throop@aurs01.UUCP (Wayne Throop)

>> For now, I use a workaround of using "xterm" to create menus,
>> selection boxes, and so on and on.
> What kind of machine are you using, a Cray?  Forking xterms to create
> menus is, ahh, hardly efficient.

Gosh, I hope nobody thought I was saying it was efficent, or even
reasonable to do this.  All I was saying was that this is what I
was driven to do in desperation.

Several people (including Marc) have included posted or mailed
pointers to better alternatives, and these pointers are most appreciated.

Wayne Throop       ...!mcnc!aurgate!throop