Remove canvas shapes by tag?

Matthew Stickney mtstickney at gmail.com
Wed Oct 12 20:02:30 UTC 2016


Based on a cursory check, there doesn't seem to be a way to do
directly. The tk command you want is "<widget> delete <tag>"[0], but
ltk has only got methods to use integer IDs with the delete command.
It's pretty easy to write your own function for it, though:

(defun delete-tagged (canvas tag)
  (check-type tag string)
  (format-wish "~a delete {~a}" (wish-pathname canvas) tag)
  canvas)

will probably do the trick.

As a general pattern, the best way I've found to get around the ltk
libs are to 1) consult the docs, and then failing that, 2) find the tk
command you want (the manual pages for tk are pretty thorough), then
open up the tk source and search around for strings that could be that
command (usually in a call to FORMAT-WISH). It helps a lot to have a
(very) basic working knowledge of tcl, so you might try to find a
quick hello-world sort of tutorial for it. That should make reading
the command definitions much easier.

-Matt Stickney

[0]  https://www.tcl.tk/man/tcl8.4/TkCmd/canvas.htm#M49

On Wed, Oct 12, 2016 at 12:27 PM, cage <cage at katamail.com> wrote:
> On Mon, Oct 10, 2016 at 09:47:39PM -0600, Ryan wrote:
>> Hello all,
>
> Hello!
>
>> new to the list (hopefully this has not been asked)
>> I've created a global canvas called *main-canvas* and have attached a few
>> shapes to it.
>> (create-line* *main-canvas*  `(,x ,y ,x2 ,y2) :tags "line")
>>
>> Am I specifying the tag correctly for the new line instance or does it need
>> to be in a list?
>
> Never tried this way (does it actually works), i usually use itemconfigure for that:
>
> (itemconfigure canvas object "tag" "tag-name")
>
> Bye!
> C.
>



More information about the ltk-user mailing list