Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,853 members, 7,956,195 topics. Date: Monday, 23 September 2024 at 07:35 AM |
Nairaland Forum / Science/Technology / Programming / PYTHON Gurus: Is There Any Way Of Saving This Turtle Session? (code) (1109 Views)
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)
PYTHON Gurus: Is There Any Way Of Saving This Turtle Session? (code) by badthinds: 9:40am On Jul 05, 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: 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: 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. 1 Like |
Re: PYTHON Gurus: Is There Any Way Of Saving This Turtle Session? (code) by badthinds: 2:44pm On Jul 06, 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? |
(1) (Reply)
Web Application Scripts Built With PHP, HTML, Jquery And CSS / [benue] Programmers, Web Developer And All Tech Enthusiasts Enter Here / Rapidpay Just Lunched Now, Make 200% Of Your Money
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 11 |