binding - python
John McMonagle
johnmc at velseis.com.au
Thu Apr 6 20:30:15 EDT 2006
On Thu, 2006-04-06 at 16:39 -0700, beta wrote:
> Hi John,
>
> It works! thank you vey much.
>
> I have another question. I would very appreciated if you have any clue.
>
> I want the ball STOP whenever mouse is clicked anywhere, then ball KEEP
> MOVING when next mouse click is applied. Thanks.
>
I do have a clue. Simply bind a mouse click to the entire canvas widget
rather than the canvas item.
Add the following line after you create the canvas widget:
self.draw.bind('<Button-1>', self.toggleBallMotion)
where toggleBallMotion stops the ball movement if it is moving and
starts the movement if it is stopped. It is a function of the form:
def toggleBallMotion(self, event):
if self.speed.get() != 0:
self.oldspeed = self.speed.get()
self.speed.set(0)
else:
self.speed.set(self.oldspeed)
You will also need to initialise the self.oldspeed variable when you
first create the Scale widget.
John McMonagle
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
More information about the Python-list
mailing list