PYTHON Gurus: Is There Any Way Of Saving This Turtle Session? (code) - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › PYTHON Gurus: Is There Any Way Of Saving This Turtle Session? (code) (1178 Views)
| PYTHON Gurus: Is There Any Way Of Saving This Turtle Session? (code) by badthinds(op): 9:40am On Jul 05, 2016*. Modified: 12:51pm On Jul 09, 2016 |
All my time of working with python, the turtle module was something I didn't have much time for. Today someone asked me if a turtle session can be saved (ie. After doodling ). "Ehh... I can't remember ever saving one. But I'll ge back to you " I said. so for instance I have: >>> import turtle >>> turtle.color('blue', 'black') >>> def cir(rnge): . . . . . . for i in range(rnge): . . . . . . . . . turtle.right(1) . . . . . . . . . turtle.forward(1) >>> begin_fill() >>> cir(360) >>> end_fill() >>> """ So now, after the turtle finish to mumu himself, Is there any way of saving the canvas? I wonder if this may involve tkinter. """ >>> |
| Re: PYTHON Gurus: Is There Any Way Of Saving This Turtle Session? (code) by Codenister: 1:49pm On Jul 05, 2016 |
Well, I don't know exactly how it will be written in Python, But you can do it this way: Save the current state and movement details in a file, then load the info from that file anytime the program is opened. And remember to update the state afterwards |
| Re: PYTHON Gurus: Is There Any Way Of Saving This Turtle Session? (code) by Nobody: 2:19pm On Jul 05, 2016 |
You want to save the code to a file, not session. Seems you typed the code in Shell mode. Open your Idle Ide in Script/Editor mode. Type the code in a file and save it. Then run it. More instructions here On mobile now. Will find time to write a sample code when I'm back on PC. |
| Re: PYTHON Gurus: Is There Any Way Of Saving This Turtle Session? (code) by badthinds(op): 3:52pm On Jul 05, 2016 |
Thank you all. but I mean... saving the canvas as a picture. |
| Re: PYTHON Gurus: Is There Any Way Of Saving This Turtle Session? (code) by badthinds(op): 4:01pm On Jul 05, 2016 |
I don't think any thing like that is on the python doc, but, since it uses a tkinter canvas, I want to believe something a bit official / unofficial can be done. At least I learnt programming is not all about obeying the rules. Thanks for cracking your head in advanced. |
| Re: PYTHON Gurus: Is There Any Way Of Saving This Turtle Session? (code) by Nobody: 4:05pm On Jul 05, 2016 |
badthinds:My bad, I get what you mean now. A screenshot is your best option, I guess. |
| Re: PYTHON Gurus: Is There Any Way Of Saving This Turtle Session? (code) by badthinds(op): 2:44pm On Jul 06, 2016*. Modified: 12:54pm On Jul 09, 2016 |
But tkinter has a: filename = PhotoImage( file = "example.gif" ) image = canvas.create_image(50, 50, anchor=NE, image=filename) The above uses tkinter to create an image which can be an instance of BitMap also. And I discovered turtle uses the tkinter canvas. That means there is 'smoke' somewhere right? |
New To Python, Gurus Please Help Solve These Challenges. Thanks. • Python Turtle Tutorial- Do Amazing Things In Python Now. • Long Time My People. Any Way To Return URL From An IP Addr? (python) Or Others? • 2 • 3 • 4
How To Change Mac Address In Windows. • I Want To Create A Website And Buy A Domain For It... How Can I? • Whats The Use Of Java Language??..