9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: rog@vitanuova.com
To: 9fans@cse.psu.edu
Subject: Re: [9fans] Limbo Tk FAQ?
Date: Fri, 25 May 2001 13:10:55 +0100	[thread overview]
Message-ID: <20010525120255.399BF199ED@mail.cse.psu.edu> (raw)

> Tcl with channels would do well, too :-)  (Oops, I hope I'm not
> speaking through my nose here, I've only given the code a brief
> glimpse, looking forward to look at it in more detail later).

i added a loadable module for the inferno shell to give shell access to
tk; this also includes channels (as they're an inextricable part of the
inferno tk interface).

some will turn up their noses, but i've found it quite nice for
knocking up simple graphical demo scripts written in shell script. part
of the reason is that the shell is multi-process, so channels sit quite
nicely with it.

	load tk
	wid := ${tk window 'Test window'}
	while {} {
		tk winctl $wid ${recv $wid}
	} &

the first line loads the tk module; the second creates a new tk window,
and returns an identifier for it, which is also the name of a channel
on which window events can be received. the third starts a background
process looping forever receiving from the channel and processing the
event that it got.

the only part not familiar from rc is the ${...} notation which yields
the result of a loadable-module-defined command (sort of like `{...}
but without the uncertainty of the usual stdout tokenization)

once you've defined a function to execute tk commands:

	fn x {
		tk $wid $*
	}

one can execute tk commands quite simply:

	x button .b -text {Hello world} -command {send cmd hello, world}
	x pack .b
	x update
	chan cmd
	tk namechan $wid cmd
	while {} {
		echo ${recv cmd}
	}

i guess this feels somewhat like tcl; it's certainly nice for hacking
up simple graphical interfaces to shell commands.



             reply	other threads:[~2001-05-25 12:10 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-25 12:10 rog [this message]
2001-05-25 12:42 ` Lucio De Re
  -- strict thread matches above, loose matches on Subject: below --
2001-05-25  9:59 rog
2001-05-25 10:45 ` Lucio De Re
2001-05-24 19:04 geoff
2001-05-24 18:50 geoff
2001-05-25  4:58 ` Lucio De Re
2001-05-25  7:44   ` Re[2]: " Matt H
2001-05-25  8:45     ` Lucio De Re
2001-05-25 12:44   ` Boyd Roberts
2001-05-25 13:28     ` Lucio De Re
2001-05-25 13:31     ` splite
2001-05-25 13:50       ` Boyd Roberts
2001-05-25 14:16   ` Douglas A. Gwyn
2001-05-29  9:16   ` Randolph Fritz
2001-06-08 10:16   ` Barry Kelly
2001-05-24 18:17 forsyth
2001-05-24 12:29 forsyth
2001-05-24 13:04 ` Lucio De Re
2001-05-26 17:25   ` Berry Kercheval
2001-05-24 12:13 nigel
2001-05-24 12:08 Laura Creighton
2001-05-24  9:20 Richard Elberger
2001-05-24 11:09 ` suspect

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010525120255.399BF199ED@mail.cse.psu.edu \
    --to=rog@vitanuova.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).