wiploc
wiploc

Reputation: 3

How can I get my right mouse button to do things in a turtle application?

I'm trying to get my right mouse button to do something (skip the turtle to a new location without drawing a line, in this particular case) in Python.

I'm in Lambert's Python Programming for Teens, which I love because the code all works. Except now, on page 130, we have this line:

onscreenclick(skip, btn = 2) # (I'll put the full (short) program below.)

Nothing happens when I right click.

I'm running Python 3.4 on Windows 8.

The fact that there's no error message suggests that I have a logic problem rather than a syntax error. But if I change "skip" (a function I wrote) to "goto" (a built-in function that works fine with the left mouse button), I get the same behavior (no error message, but still nothing happens when I right click).

Skip works fine if I use it with left click. So the problem is assigning it to the right click.

Here's the entire (short) program:

from turtle import *

shape('circle')

def skip(x,y): up(); goto(x,y); down()

onscreenclick(goto)

onscreenclick(skip, btn = 2)

listen()

"""

Upvotes: 0

Views: 1115

Answers (1)

airwelldriller
airwelldriller

Reputation: 26

btn=2 references a scroll wheel push (not scroll).

btn=3 references a rightclick.

Upvotes: 1

Related Questions