[Python] The 'Method' and 'Method' error. Read desc :C

Discussão em 'Python' iniciado por Stack, Março 15, 2025.

  1. Stack

    Stack Membro Participativo

    World!

    I've run into error when detecting click in some range of X and Y.

    import turtle as t

    # VARIABLES
    toggle = t.Turtle()
    pen = t.Turtle()
    x = 0
    y = 0
    tx1 = 0
    ty1 = 0
    tx2 = 0
    ty2 = 0
    active = False

    # TOGGLE BUTTON
    toggle.penup()
    toggle.speed(0)
    toggle.goto(200, -250)
    toggle.pendown()
    toggle.color("green")
    for i in range(4):
    toggle.forward(50)
    toggle.left(90)
    if i == 0:
    tx1 = toggle.xcor
    ty1 = toggle.ycor
    if i == 3:
    tx2 = toggle.xcor
    ty2 = toggle.ycor

    # PROPERTY
    pen.speed(0)

    # MAIN
    def getclick(x, y):
    print(x, y)
    x = pen.xcor
    y = pen.ycor
    if x >= tx1 and x <= tx2:
    if y >= ty1 and y <= ty2:
    if active == True:
    active = False
    else:
    active = True

    if active == True:
    pen.pendown()
    else:
    pen.penup()
    pen.goto(x, y)

    t.onscreenclick(getclick)
    t.done()


    That's the source code. Its giving error ob line 41, saying that: "TypeError: '>=' not supported between instances of 'method' and 'method'" As you can see, X, Y, TY1, TY2, TX1, TX2 isn't a methods, can someone explain why it gives error?

    Well, I've tried much tried much things so i cannot show anything here :p

    Continue reading...

Compartilhe esta Página