[ltk-user] Using tags on canvas items?

Josef Wolf jw at raven.inka.de
Wed Nov 21 12:26:54 UTC 2012


Hello again,

activating *debug-tk* reveals the root of the problem. It looks to me as if
there are _two_ problems:

    (itemconfigure canvas polygon :tags '(FOO BAR baz))
    (itemconfigure canvas 'bar    :fill 'yellow) ; doesn't work

is sent to wish as

    bt ".wc.wf itemconfigure 1 -tags {(foo bar baz)}"
    bt ".wc.wf itemconfigure BAR -fill {yellow}"

The first problem is that the symbols are forced to lower case for the first
command while they are forced to UPPER CASE for the second command.

The second problem is revealed by the following command, which (unexpectedly)
happen to work:

    (itemconfigure canvas '|(foo| :fill 'yellow)  ; works!

Please note the parenthesis! This clearly shows that wish interprets the
surrounding parens as part of the tag!

On Wed, Nov 21, 2012 at 12:41:29PM +0100, Josef Wolf wrote:
>
> I am trying to use the tags feature of the canvas. So I am trying to attach a
> list of tags to an item and use those tags later to identify items. Here's an
> example:
> 
>  (with-ltk ()
>    (let* ((sc (make-instance 'scrolled-canvas))
>           (canvas (canvas sc))
>           (polygon (create-polygon canvas '(10 20 30 40 60 50))))
>  
>      (pack sc)
>      (configure canvas :width 100 :height 100)
> 
>      (itemconfigure canvas polygon :tags '(foo bar baz))
>      (itemconfigure canvas polygon :fill 'red)
>      (itemconfigure canvas 'foo    :fill 'yellow)))
> 
> But it somehow doesn't work the way I expected it to work. The polygon stays
> red instead of being re-configured to yellow.
> 
> It also won't work if I use strings instead of symbols. It only works if I use
> a _single_ string. But this is not how the tags feature is intended to work.
> 
> Any ideas?




More information about the ltk-user mailing list