On 16/03/06, Adam <[EMAIL PROTECTED]> wrote:
> On 15/03/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > I want to bind the cancel buttom of a ExFileSelectBox to a routine in my 
> > class,
> Here's what I got from a little experimentation and print
> box.cancel.bind.__doc__.
>
> >>> def bar(action):
> ...     print action
> >>> import Tix
> >>> root = Tix.Tk()
> >>> box = Tix.ExFileSelectBox(root)
> >>> box.pack()
> >>> box.cancel.bind("<ButtonPress-1>", bar)
> '-1212073588bar'
> >>> <Tkinter.Event instance at 0xb779c0ec>
> <Tkinter.Event instance at 0xb779c0ec>
> <Tkinter.Event instance at 0xb779c0ec>

This will bind to leftmouse-down, which is different from clicking a
button.  If you want to simulate a real button click with event
bindings, you will need to set a flag on ButtonPress-1, then in
ButtonRelease-1 check for the flag, check to see if the mouse is
within the button, and then activate your callback.

Something else you could try (which I haven't tested) --- instead of
box.cancel.bind, do box.cancel.config(command= ...).

--
John.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to