turtle-graphics

Save turtle output as jpeg

落花浮王杯 提交于 2019-11-30 17:17:20
问题 I have a fractal image creator. It creates a random fractal tree like thing. When done, it prompts the user to save the tree. I have it saving as a .svg right now and that works BUT I want it to save to a more convenient file type, like jpeg. Any ideas? Code: import turtle import random from sys import exit from time import clock import canvasvg turtle.colormode(255) red = 125 green = 70 blue = 38 pen = 10 def saveImg(): print("Done.") save = input("Would you like to save this tree? Y/N \n")

Turtle Graphics Not Responding

北战南征 提交于 2019-11-30 13:13:09
问题 I am creating diagrams with the turtle package in Python, and it is successful to some extent, except for one problem. Once turtle generates the diagram that I have in code, it causes the program to say "Not responding" and eventually I have to end the task. I am using Windows 7. Have any of you experienced this or know the root cause? I tried reinstalling Python completely, but that didn't seem to affect the problem. Here is some example code that will make it fail to respond: import turtle

Turtle Graphics Not Responding

回眸只為那壹抹淺笑 提交于 2019-11-30 07:06:38
I am creating diagrams with the turtle package in Python, and it is successful to some extent, except for one problem. Once turtle generates the diagram that I have in code, it causes the program to say "Not responding" and eventually I have to end the task. I am using Windows 7. Have any of you experienced this or know the root cause? I tried reinstalling Python completely, but that didn't seem to affect the problem. Here is some example code that will make it fail to respond: import turtle from turtle import forward, right, left forward(50) aengelberg I had the same problem (I was on Win 7

Python Turtle Module- Saving an image

会有一股神秘感。 提交于 2019-11-30 05:52:16
I would like to figure out how to save a bitmap or vector graphics image after creating a drawing with python's turtle module. After a bit of googling I can't find an easy answer. I did find a module called canvas2svg , but I'm very new to python and I don't know how to install the module. Is there some built in way to save images of the turtle canvas? If not where do I put custom modules for python on an Ubuntu machine? KilyenOrs from Tkinter import * from turtle import * import turtle forward(100) ts = turtle.getscreen() ts.getcanvas().postscript(file="duck.eps") This will help you; I had

How to change size of turtle?

£可爱£侵袭症+ 提交于 2019-11-29 17:20:33
I am trying to double the size of the turtle in the window every time I press x on my keyboard. I tried using .turtlesize(2,2,2) , but that's not right. I need to double every time the key is pressed so if the turtle size is (1,1,1) , it will become (2,2,2) then (4,4,4) and so on each time I press x . This is what I have so far: import turtle turtle.setup(500,500) wn = turtle.Screen() wn.title("Commands") wn.bgcolor("black") tess = turtle.Turtle() tess.shape("triangle") tess.color("red") tess.left(90) def increaseSize(): size = tess.turtlesize() increase = tuple([2 * num for num in size]) tess

Python imaging, resize Turtle Graphics window

痞子三分冷 提交于 2019-11-29 14:54:02
My image is too large for the turtle window. I had to enlarge the image because the text I need at each spot overlaps. How do I Resize the window in python? NobodyReally It sounds like you have drawn an image, but it has gone outside the borders of the window, so therefore you need to make the window larger to see the entire image. To resize the window: setup( width = 200, height = 200, startx = None, starty = None) This will make your output window 200X200 (which may be too small for you so you'll need to make those numbers larger.) Here is the URL where I found this information. TurtleDocs

adding an image to the Turtle Screen

你离开我真会死。 提交于 2019-11-29 11:26:52
How can I add image to my Turtle Screen using turtle graphics? whenever I use the function addshape I keep getting errors. does turtle graphics got any other way loading/importing images? for example: import turtle screen = turtle.Screen() image = r"C:\Users\myUser\Desktop\Python\rocketship.png" screen.addshape(image) turtle.shape(image) The turtle module does have support for images, but only GIF images, not PNG or any other format. As the docs for addshape say: name is the name of a gif-file and shape is None : Install the corresponding image shape. And if you look at the source , they're

Turtle graphics - How do I control when the window closes?

試著忘記壹切 提交于 2019-11-28 19:13:30
I have a small python script which draws some turtle graphics. When my script has finished running, the turtle screen automatically closes, so to be able to see the graphics for a while I have to use time.sleep(5) at the end of the script to delay the closing. Is there any way I can make this more dynamic, i.e. tell python that I want to control the closing of the window myself? I don't mind if the script can't do anything else while waiting for my command, but I'd prefer if I didn't have to go to the console for a read() or something. Ideally, the canvas should stay open even after the script

Is there a way to save turtle's drawing as an animated GIF?

不羁的心 提交于 2019-11-28 12:58:30
I like what the turtle module does in Python and I'd like to output the entire animation of it drawing the shape. Is there a way to do this? GIF/MP4/anything that shows the animation. Note, I know that an external screen recorder will do the job, but I'm looking for a way for the turtle module to do this itself. cdlane Make an animated GIF from Python turtle using Preview on OSX 1) Start with a working program As obvious as that seems, don't be debugging your code while trying to generate the animated GIF. It should be a proper turtle program with no infinite loops that ends with mainloop() ,

Unable to understand this recursive turtle python code

我是研究僧i 提交于 2019-11-28 10:36:14
问题 this is my first time asking a question, I hope some of you will find time to answer. So my goal is to write a python script using the turtle module to code a pythagoras tree. I've spent days on it, and I really couldn't advance past a certain point, so I looked online to help me. I've found a code that does what I want but with very little lines of code: import turtle t = turtle.Pen() LIMIT =11 SCALAR = 0.5 * (2 ** 0.5) def drawTree(size, depth): drawSquare(size) if depth + 1 <= LIMIT: t