[ltk-user] selected text

Phil Armitage philip.armitage at gmail.com
Wed Nov 15 01:12:45 UTC 2006


Hi,

I'm starting to use LTK but there's one feature I need and have been
unable to find. Essentially I want to be able to retrieve the selected
text in a text widget. I searched through the docs and source but
couldn't find anything (I apologize if I've missed it).

I'm very new to Lisp (and Tk!) but I managed to write this:

(defmethod selected ((text text))
  (format-wish "senddatastring [~a get sel.first sel.last]" (widget-path text))
  (read-data))

...which works but causes problems if no text is selected.

Is there an obvious way around this (or, even better, an existing
function to do the job that I've just missed)?

Many thanks in advance for any help you can offer (and thanks to Peter
for writing the library!).

Phil



More information about the ltk-user mailing list