Created
February 28, 2025 13:47
-
-
Save jurandysoares/ac59d97dc91ec8652df8d29606f0b075 to your computer and use it in GitHub Desktop.
Coordenadas de uma imagem de plano de fundo da biblioteca turtle do Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment