[ltk-user] binding an event to a canvas element

Jerry Vinokurov jerryv at cmu.edu
Fri Jun 22 16:27:59 UTC 2012


On 6/22/12 11:32 AM, cage wrote:
> On Fri, Jun 22, 2012 at 05:02:43PM +0200, Peter Herth wrote:
>> If you create the canvas items with make-instance, you can just bind
>> events to them
> Great! Didn't know that!
>
> Bye.
> C.
>
Right, I understand that you can bind events to the canvas. I don't have 
any trouble doing that. What I want is to bind them to the canvas 
elements; I want to have different pie slices and track which ones 
people click on. I tried using tag-bind but it throws an error:

SB-INT:SIMPLE-READER-ERROR on #<TWO-WAY-STREAM
                                 :INPUT-STREAM #<SB-SYS:FD-STREAM
                                                 for "descriptor 9"
                                                 {10034B3BC1}>
                                 :OUTPUT-STREAM #<SB-SYS:FD-STREAM
                                                  for "descriptor 8"
                                                  {10034B3681}>>:
   illegal terminating character after a colon: #\
    [Condition of type SB-INT:SIMPLE-READER-ERROR]

This happens whether I use:

  (tag-bind pie-canvas arc1 "<ButtonPress-1>" (lambda (event)
                                     (declare (ignore event))
                                     (format t "test")))

or

  (itemconfigure pie-canvas arc1 "tags" "arc1")
  (tag-bind pie-canvas arc1 "<ButtonPress-1>" (lambda (event)
                                     (declare (ignore event))
                                     (format t "test")))

I am not really sure if I'm doing this right at all, since I'm basically 
trying to reproduce the Python functionality I'm familiar with. Is there 
any way to view the string being sent to the Tk interpreter?

-- 
Jerry Vinokurov
Research Programmer
Dept. of Psychology
Carnegie Mellon University
(412) 268-6113





More information about the ltk-user mailing list