9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] Limbo Tk FAQ?
@ 2001-05-25 12:10 rog
  2001-05-25 12:42 ` Lucio De Re
  0 siblings, 1 reply; 23+ messages in thread
From: rog @ 2001-05-25 12:10 UTC (permalink / raw)
  To: 9fans

> 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.



^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: [9fans] Limbo Tk FAQ?
@ 2001-05-25  9:59 rog
  2001-05-25 10:45 ` Lucio De Re
  0 siblings, 1 reply; 23+ messages in thread
From: rog @ 2001-05-25  9:59 UTC (permalink / raw)
  To: 9fans

> > graphics programming still
> > reminds me of assembler programming: way too much attention
> > to way too much irrelevant detail.
>
> I'm pleased to discover I am not alone in this, although I couldn't
> have phrased it as succintly or as accurately as you did.  And I
> enjoy assembly programming, but I find graphics programming far
> too tedious.

i think that's because you've got multi-dimensional inputs, often with
associated state, which are much harder to deal with than the
unidimensional, stateless input stream of a command-line program, for
example.

at least with limbo/tk, the language is decently multi-threaded, so
it's often possible to carve a program into logically independent
threads, each of which is quite simple, rather than the age old "one
big state machine" paradigm which is the only way of doing things in
many GUI programming interfaces. despite its superficial simplicity,
i'll bet that Visual Basic falls into that category too.

where GUI programming is inevitably tedious is when you're dealing with
input forms (buttons, entry widgets, sliders, tickboxes, etc, etc), as
there are so many possible states to think about and deal with in the
program. i think that this is going to be the case regardless of
language. the key is probably to minimise (eliminate?) instances of
this kind of interface.

i've found limbo/tk to be a very productive environment, compared to
others i've used (principally the NeXTStep interface (now MacOS X),
which i believe is well regarded).  the first-class strings in limbo
sit very well with the string-based nature of tk. strings nicely
represent a generic tk object.

for instance, the following code animates an arbitrary object smoothly
across a tk canvas at constant velocity. it doesn't matter what the
object is (it might be a composite of many); and there can be any
number of animations happening concurrently.

animproc(a: ref Animation)
{
	SPEED: con 1.5;			# animation speed in pixels/millisec
	dstpt := a.dst.pos.add(a.dst.delta.mul(a.index));
	srcpt := a.srcpt;
	d := dstpt.sub(srcpt);
	if (!d.eq((0, 0))) {
		mag := math->sqrt(real(d.x * d.x + d.y * d.y));
		(vx, vy) := (real d.x / mag, real d.y / mag);
		currpt := a.srcpt;		# current position of object
		t0 := sys->millisec();
		dt := int (mag / SPEED);
		t := 0;
		tk->cmd(win, ".c raise " + a.tag);
		while (t < dt) {
			s := real t * SPEED;
			p := Point(srcpt.x + int (s * vx), srcpt.y + int (s * vy));
			dp := p.sub(currpt);
			tk->cmd(win, ".c move " + a.tag + " " + string dp.x + " " + string dp.y + ";update");
			currpt = p;
			yield();
			t = sys->millisec() - t0;
		}
	}
	a.waitch <-= a;
}

i wouldn't like to do this sort of stuff in tcl.  limbo just makes it
so simple.

that said, i think there is room for some sort of expandability in
limbo/tk, not via tcl, i think but perhaps via some sort of
channel/module/device interface.

i'm sorry, i'm off topic.

  rog.



^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: [9fans] Limbo Tk FAQ?
@ 2001-05-24 19:04 geoff
  0 siblings, 0 replies; 23+ messages in thread
From: geoff @ 2001-05-24 19:04 UTC (permalink / raw)
  To: 9fans

Sorry; my last message was meant to be private mail.


^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: [9fans] Limbo Tk FAQ?
@ 2001-05-24 18:50 geoff
  2001-05-25  4:58 ` Lucio De Re
  0 siblings, 1 reply; 23+ messages in thread
From: geoff @ 2001-05-24 18:50 UTC (permalink / raw)
  To: 9fans

The philw put tk into Inferno.  He botched it (of course).
I still haven't seen any reasonably pleasant way to
write GUIs and am becoming convinced that it's just
inherently painful.  limbo/tk is probably less painful
than some other ways, but graphics programming still
reminds me of assembler programming: way too much attention
to way too much irrelevant detail.


^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: [9fans] Limbo Tk FAQ?
@ 2001-05-24 18:17 forsyth
  0 siblings, 0 replies; 23+ messages in thread
From: forsyth @ 2001-05-24 18:17 UTC (permalink / raw)
  To: 9fans; +Cc: inferno

>>The Inferno manual (volume 2, the papers) has a very good document on the
>>Limbo/Tk. I do not think it is available on the web on its own, but it
>>might be included in the download distribution. I'm quite certain if you
>>asked the fine folk at Vitanuova for a Postscript copy, they would oblige.

http://www.vitanuova.com/inferno/papers/tk.html		# the overview mentioned
http://www.vitanuova.com/inferno/papers/descent.html	# some more interesting examples
http://www.vitanuova.com/inferno/man/9/INDEX.html		# the Tk reference manual pages for Inferno



^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: [9fans] Limbo Tk FAQ?
@ 2001-05-24 12:29 forsyth
  2001-05-24 13:04 ` Lucio De Re
  0 siblings, 1 reply; 23+ messages in thread
From: forsyth @ 2001-05-24 12:29 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 586 bytes --]

i looked at porting Ousterhout's Tk to Plan 9 several years ago,
but became discouraged.  i'd like to be more helpful but apart
from its size, i can't remember what ultimately discouraged me
from continuing.  there's a version for Windows so i suppose
X11 dependencies weren't the main problem, but perhaps
that was it.

the Inferno implementation was completely new,
and i think about 1/4 of the number of lines of Ousterhout's Tk at the time
(allow for Inferno's Tk being an extended subset of that Tk),
excluding Tcl.

i thought the Inferno implementation was tidier.


[-- Attachment #2: Type: message/rfc822, Size: 1595 bytes --]

To: cse.psu.edu!9fans
Cc: cd.chalmers.se!lac
Subject: Re: [9fans] Limbo Tk FAQ?
Date: Thu, 24 May 2001 14:08:24 +0200 (MET DST)
Message-ID: <200105241208.OAA13721@boris.cd.chalmers.se>

Who did the port to inferno? How hard would it be to port Tk to plan 9? 

Laura Creighton

^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: [9fans] Limbo Tk FAQ?
@ 2001-05-24 12:13 nigel
  0 siblings, 0 replies; 23+ messages in thread
From: nigel @ 2001-05-24 12:13 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 118 bytes --]

It's not a port to Inferno. It's a reimplementation.
Also, it's Limbo/Tk, not Tcl/Tk, i.e. it has Limbo
binding.


[-- Attachment #2: Type: message/rfc822, Size: 1417 bytes --]

From: Laura Creighton <lac@cd.chalmers.se>
To: 9fans@cse.psu.edu
Cc: lac@cd.chalmers.se
Subject: Re: [9fans] Limbo Tk FAQ?
Date: Thu, 24 May 2001 14:08:24 +0200 (MET DST)
Message-ID: <200105241208.OAA13721@boris.cd.chalmers.se>

Who did the port to inferno? How hard would it be to port Tk to plan 9? 

Laura Creighton

^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: [9fans] Limbo Tk FAQ?
@ 2001-05-24 12:08 Laura Creighton
  0 siblings, 0 replies; 23+ messages in thread
From: Laura Creighton @ 2001-05-24 12:08 UTC (permalink / raw)
  To: 9fans; +Cc: lac

Who did the port to inferno? How hard would it be to port Tk to plan 9? 

Laura Creighton


^ permalink raw reply	[flat|nested] 23+ messages in thread
* [9fans] Limbo Tk FAQ?
@ 2001-05-24  9:20 Richard Elberger
  2001-05-24 11:09 ` suspect
  0 siblings, 1 reply; 23+ messages in thread
From: Richard Elberger @ 2001-05-24  9:20 UTC (permalink / raw)
  To: 9fans

Hi folks,

Is there a faq somewhere about the tcl/tk use in Limbo and how it differs
from tcl/tk in other systems?

thanks in advance --

-- rich




^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2001-06-08 10:16 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-25 12:10 [9fans] Limbo Tk FAQ? rog
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

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).