Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

tutorial for text widget...

181 views
Skip to first unread message

Steve Allen

unread,
Jun 3, 2004, 10:20:04 PM6/3/04
to
I'm relearning tcl, which is going fine. But I am also trying to learn
TK. I having a hard time with the text widget.

I can load it with text, search it, add tags for colors, etc, all sorts
of goodies but I just can't seem to find the magic cookies for:

1. moving the cursor to a index - i.e. making that index the current
(seems like I should say something like .textarea index set current 1.0)

2. I can find my current cursor, but how do I get the selection? I.E. a
start and end index from a dragged selection..

Also, I've found documentation on the web, and a few small tutorials.
But does any have anything they recommend (web page, book, etc)...

Many thanks....

Steve

Bruce Hartweg

unread,
Jun 3, 2004, 10:50:17 PM6/3/04
to
Steve Allen wrote:
> I'm relearning tcl, which is going fine. But I am also trying to learn
> TK. I having a hard time with the text widget.
>
> I can load it with text, search it, add tags for colors, etc, all sorts
> of goodies but I just can't seem to find the magic cookies for:
>
> 1. moving the cursor to a index - i.e. making that index the current
> (seems like I should say something like .textarea index set current 1.0)
>
there is a special mark named insert that is used that monitors/controls
where the insertion cursor is

.txtarea mark set insert 1.0

> 2. I can find my current cursor, but how do I get the selection? I.E. a
> start and end index from a dragged selection..
>

there is a special tag called sel that is the current selection

.textarea tag ranges sel

> Also, I've found documentation on the web, and a few small tutorials.
> But does any have anything they recommend (web page, book, etc)...
>

Check out
http://wiki.tcl.tk
it has many good examples/discussions/links/etc on tcl
For hard copy books I would recommend http://wiki.tcl.tk/8449
but there are others - see http://wiki.tcl.tk/57
or http://wiki.tcl.tk/references/3334

Bruce

Bryan Oakley

unread,
Jun 3, 2004, 10:53:05 PM6/3/04
to
Steve Allen wrote:
> I'm relearning tcl, which is going fine. But I am also trying to learn
> TK. I having a hard time with the text widget.
>
> I can load it with text, search it, add tags for colors, etc, all sorts
> of goodies but I just can't seem to find the magic cookies for:
>
> 1. moving the cursor to a index - i.e. making that index the current
> (seems like I should say something like .textarea index set current 1.0)

.textarea mark set insert 1.0

>
> 2. I can find my current cursor, but how do I get the selection? I.E. a
> start and end index from a dragged selection..
>

set start [.textarea index sel.first]
set end [.textarea index sel.last]
# or...
set range [.textarea tag ranges sel]


Look again at the text widget man page and you'll see mention of the
special marks "insert" and "sel".

Arjen Markus

unread,
Jun 4, 2004, 3:18:32 AM6/4/04
to

You may have a look at my article from the EuroTcl conference 2003.
It describes a number of uses of the text widget and the code fragments
should give you an idea about how things are done.

Follow the links at: <http://wiki.tcl.tk/6273>

Regards,

Arjen

0 new messages