From 6419a7d7cfe308ee4eebbc8f61c6bb84646ba945 Mon Sep 17 00:00:00 2001 From: Jurandy Soares Date: Thu, 27 Feb 2025 13:04:56 -0300 Subject: [PATCH] Exibe as ordena (x, y) do clique --- coords_clique.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 coords_clique.py diff --git a/coords_clique.py b/coords_clique.py new file mode 100644 index 0000000..020953b --- /dev/null +++ b/coords_clique.py @@ -0,0 +1,30 @@ +import turtle + +# Função chamada quando o mouse é clicado +def exibir_coordenadas(x, y): + # Exibe as coordenadas no console + print(f"Coordenadas do clique: x={x:0.0f}, y={y:0.0f}") + + # Exibe as coordenadas na tela com o turtle + turtle.penup() + turtle.shape('circle') + turtle.goto(x, y) + turtle.pendown() + turtle.write(f"({x:0.0f}, {y:0.0f})", font=("Arial", 12, "normal")) + turtle.stamp() + +# Configurações da tela +tela = turtle.Screen() +turtle.setup(1110, 694) +turtle.bgpic("pacote/fundos/fundo-com-degraus.png") +tela.title("Clique para ver as coordenadas do mouse") + +# Quando o clique ocorrer, a função exibir_coordenadas é chamada +tela.onclick(exibir_coordenadas) + +# Configura o turtle +turtle.speed(0) +turtle.hideturtle() + +# Inicia o loop principal +turtle.mainloop()