Oct-05-2019, 05:07 PM
Is there a way to set a custom image as my turtle background on python
Turtle canvas background
|
Oct-05-2019, 05:07 PM
Is there a way to set a custom image as my turtle background on python
Oct-05-2019, 06:59 PM
(This post was last modified: Oct-07-2019, 03:14 AM by newbieAuggie2019.)
(Oct-05-2019, 05:07 PM)joshp2709 Wrote: Is there a way to set a custom image as my turtle background on python Hi! I read your post and as I'm a very visual person, I tried but haven't managed it yet. I have managed to use a custom image as a background image on my Cmder: ![]() https://python-forum.io/Thread-colouring...0#pid92380 or even on matplot: ![]() https://python-forum.io/Thread-colouring...0#pid92210 I guess the solution is in here: https://docs.python.org/3/library/turtle...rtle.bgpic but I haven't managed it yet ... All the best, I FINALLY MANAGED IT!!! I found the solution here: https://stackoverflow.com/questions/4166...ound-image So I used that program with my own images: # turtle_bg_image_01.py # # It works! # import turtle import time screen = turtle.Screen() screen.setup(600,400) screen.bgpic('D:/programmation related/Butterfly_01.png') screen.update() time.sleep(2) screen.bgpic('D:/programmation related/complex_quotations_02.PNG')so it produces this output: ![]() and this one (the program runs showing one image and then after a few seconds (sleep() function), it shows the second image): ![]() As you can see in the program on line 11: screen.bgpic('D:/programmation related/Butterfly_01.png')and on line 14: screen.bgpic('D:/programmation related/complex_quotations_02.PNG')you have to use the full direction route of the images you want to use, that are in your computer. All the best, So now, you can use images as a background on your programs, like my simple draw a poligon program: # turtle_bg_image_02.py # # It works! # import turtle from turtle import * speed(0) screen = turtle.Screen() screen.setup(400,400) screen.bgpic('D:/programmation related/Butterfly_01.png') screen.update() nsides = input("Enter the number \ (bigger than 2) of sides of your \ desired poligon.\n") ang1 = 360/int(nsides) def poligon(sidelength=100): for i in range(int(nsides)): forward(sidelength) right(ang1) poligon()that running on my Python 3.7.4 Shell: produces the following output with turtle:![]() where you can see that the hexagon has been drawn with the butterfly image as a background. All the best,
newbieAuggie2019
"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains." Steve Jobs |
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
wn = turtle.screen() AttributeError: module 'turtle' has no attribute 'screen' | Shadower | 1 | 7,147 |
Feb-06-2019, 01:25 AM Last Post: woooee |
|
Help! Turtle not working, even when we click the turtle demo in IDLE nothing happens. | BertyBee | 3 | 7,255 |
Jan-04-2019, 02:44 AM Last Post: SheeppOSU |