[GRASS-dev] new interactive rules setting for TclTk

Glynn Clements glynn at gclements.plus.com
Mon Jun 25 23:02:07 EDT 2007


Michael Barton wrote:

> I've just committed a new script (rules.tcl) for the TclTk GUI that permits
> interactive rule setting without needing an xterm for r.colors, r.reclass,
> r.recode, and v.reclass. The interface lets you select the input map and  an
> output map (except for r.colors where it is not needed), and offers a simple
> text widget where rules can be entered. There are several improvements I'd
> like to add and hope that someone can help with.
> 
> 1. I've managed to bind Control-c for copying in the text widget (Control-x
> already cuts), but can't get Control-v to paste.

Try changing:

    $rules_text tag bind <Control-v> {%W insert [selection get]}
to:
    $rules_text tag bind <Control-v> {tk_textPaste %W}

AFAICT, tk_textPaste pastes the clipboard, while "selection get" returns
the primary selection (use "selection get -selection CLIPBOARD" if you
want the contents of the clipboard).

Actually, it should probably just use the "bind" command rather than the
text widget's "tag bind" command (the latter is intended for applying
bindings to specific regions of text, e.g. for implementing hyperlinks).

Also, those bindings should probably be applied to all text widgets, not
just that one, e.g.:

    bind Text <Control-c> {tk_textCopy %W}
    bind Text <Control-v> {tk_textPaste %W}

FWIW, my version of Tk (8.4.9) already has Ctrl-C and Ctrl-V bound to
Copy/Paste.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list