Reputation: 43
I'm trying to write a bit of code that will show me a picture of a map but when I run the code it's not returning the image or any sort of error. After doing a bit of research I don't think I need any other code but any help would be greatly appreciated.
import turtle
screen = turtle.Screen()
screen.setup(720,360)
screen.setworldcoordinates(-180, -90, 180, 90)
screen.bgpic('map.gif')
Upvotes: 2
Views: 937
Reputation: 1185
To make the window stay open, you need screen.mainloop()
. What this does is to keep the window open and run any code that is necessary such as key presses. You simply place this at the end of the code and the final code looks like this...
import turtle
screen = turtle.Screen()
screen.setup(720,360)
screen.setworldcoordinates(-180, -90, 180, 90)
screen.bgpic('map.gif')
screen.mainloop()
Note: You need screen.mainloop()
or turtle.mainloop()
(if you haven't created a screen object) at the end of all turtle projects if you want them to run.
Upvotes: 2
Reputation: 21
Is it flash back?Maybe you need suspend the program because end of execution or add
screen.mainloop()
as one solution
Upvotes: 2