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

Peter Herth herth at peter-herth.de
Fri Jun 22 15:02:43 UTC 2012


If you create the canvas items with make-instance, you can just bind
events to them

Peter

On Fri, Jun 22, 2012 at 5:03 PM, cage <cage at katamail.com> wrote:
> On Thu, Jun 21, 2012 at 05:38:27PM -0400, Jerry Vinokurov wrote:
>>
>> Hi all,
>>
>> I'm trying to bind an event to a canvas element, in this case an
>> arc. I create the arc using something like
>>
>> (let* ((pie-canvas (make-instance 'canvas
>>                       :height 200
>>                       :width 200))
>>         (arc1 (create-arc pie-canvas 0 0 200 200 :start 0 :extent 45)))
>>
>> and then later inside the let, I would like to bind a button click
>> event to the arc. I have no problem binding to the canvas itself
>> using (bind), and in Python, I can use the tag_bind method of the
>> Canvas class to achieve this. However, I can't figure out the Ltk
>> equivalent, if there is one. Any suggestions would be appreciated.
>
> Not sure this answer your question but ltk have a tagbind (never used it actually).
>
> (ltk:tagbind pie-canvas tag "<ButtonPress-1>" function)
>
> Or you can bind the whole canvas:
>
> (ltk:bind pie-canvas "<ButtonPress-1>" function)
>
> But You should  figure out how "function" could  search and manage for
> the clicked arc of course.
>
> Bye.
> C.
>
> _______________________________________________
> ltk-user site list
> ltk-user at common-lisp.net
> http://common-lisp.net/mailman/listinfo/ltk-user




More information about the ltk-user mailing list