Python Forum
[Tkinter] Tkinter/Turtle Stopping and Starting Timers Cleanly
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Tkinter/Turtle Stopping and Starting Timers Cleanly
#3
Hey thanks @deanhystad that was super-useful. I've been pulling my hair out over this for a while now!

@deanhystad I've just noticed that with your insight, I can now go back to using plain old Turtle methods:

def start_bomb_drop():
    # Prevent further key presses until drop is finished tp prevent event stacking.
    screen.onkey(None, "space")  #
    bomb.goto(plane.xcor(), plane.ycor())
    bomb.showturtle()
    __continue_bomb_drop()
    
    
def __continue_bomb_drop():
    bomb.goto(bomb.xcor(), bomb.ycor() - 12)
    if bomb.ycor() < - height // 2 or bomb_collision():
        stop_bomb_drop()
    else:
        turtle.ontimer(__continue_bomb_drop, BOMB_DELAY)
    
    
def stop_bomb_drop():
    bomb.hideturtle()
    # It's now safe to allow another bomb drop, so rebind keyboard event.
    screen.onkey(start_bomb_drop, "space")
Big Grin
Reply


Messages In This Thread
RE: Tkinter/Turtle Stopping and Starting Timers Cleanly - by robin73 - Apr-01-2020, 07:31 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Turtle / turtle question DPaul 2 2,158 Oct-04-2020, 09:23 AM
Last Post: DPaul
  [Tkinter] Tkinter/turtle doevents DPaul 0 1,811 Sep-24-2020, 07:59 AM
Last Post: DPaul
  tkinter window and turtle window error 1885 3 6,715 Nov-02-2019, 12:18 PM
Last Post: 1885
  [Tkinter] Is there a way to sleep without stopping user input? GalaxyCoyote 2 2,136 Oct-23-2019, 06:23 PM
Last Post: Denni

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020