[Python] Simple turtle commands to bring turtle graphics window to the foreground? (python 3...

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

  1. Stack

    Stack Membro Participativo

    I've been trying to work through some beginner python turtle graphics turtorials in python 3.7 on Mac OS X El Capitan.

    One of the things that seems annoying is that the turtle graphics window is opening up underneath the other windows.

    I don't know if there is something wrong with my configuration, or whether it is typical of turtle graphics, but it would be nice if there an easy way to bring the window to the foreground. I have searched and found out that turtle graphics is based on tkinter, and found a couple of post on bringing tkinter windows to thr foreground.

    I was able to get the following code to work with IDLE, but it doesn't work when running the program from the terminal.

    import turtle

    # works in IDLE, but not in OS X terminal
    root = turtle.getscreen()._root
    root.attributes("-topmost", true)

    turtle.forward(100)
    turelt.left(120)


    I have tried looking through the turtle graphics documentation, but I didn't find any commands to bring a window to the foreground, and I am not fond of the idea of having to do a deep read through tkinter documentation just to be able to run a beginner turtle graphics tutorial.

    That being said, knowing the right commands to get a tkinter-able reference to the turtle window, and knowing the correct tkinter commands would seem like an acceptable workaround.

    Are there any basic turtle commands to bring the window to the foreground, or is there a way to get a reference to the root tkinter window in order to bring it to ther foreground??

    Thanks in advance for any help or suggestions!!

    Sincerely, Bryan Pierce

    Continue reading...

Compartilhe esta Página