2

I have created a turtle program that draws many things in many sizes based on the user input. However, I also want to include a "save" button that opens up a file dialog and allows the user to save the current canvas as a .jpeg or other file type compatible with Macintosh. What would be the most efficient and direct way to implement a file dialog and save method in the canvas that saves the canvas as a file (that can also be saved on top of afterwards if save is pressed again in the same window) on a directory the user chooses? Any help regarding this is much appreciated! :)

Note: I have tried researching around for ways to do this in Python 3.x, but what I am only getting is ways to do this for Python 2.x.

R. Kap
  • 599
  • 1
  • 10
  • 33
  • 1
    Have you seen http://stackoverflow.com/questions/9886274/how-can-i-convert-canvas-content-to-an-image? – Warren Weckesser Jan 06 '16 at 00:18
  • @WarrenWeckesser Yes, and its talking about Python 2.x based on the code in the question instead of Python 3.x, which is what I have. – R. Kap Jan 06 '16 at 00:29
  • 1
    For Python 3, change `from Tkinter import *` to `from tkinter import *`. If you want to use the somewhat cumbersome technique of mirroring all the drawing commands on a PIL image, and you use Pillow for PIL, change `import Image, ImageDraw` to `from PIL import Image, ImageDraw` – Warren Weckesser Jan 06 '16 at 00:44
  • @WarrenWeckesser I have actually tried downloading the PIL module in the answer to that question, but it is not compatible with Python 3 on my macintosh. I know this since every time I run the `setup.py` associated with the module, it doesn't install the PIL module since when I run `from PIL import Image,ImageDraw` I get the error that no such module exists. – R. Kap Jan 06 '16 at 00:47
  • 1
    @WarrenWeckesser Plus I want the most direct and efficient way to do it, so it does not really work for me anyways. – R. Kap Jan 06 '16 at 00:48
  • I'm on a Mac, but for packages that I'm not developing myself, I use anaconda packages as much as I can--saves *a lot* of time (https://www.continuum.io/downloads). I just installed Pillow in Python 3 using `conda install pillow`. – Warren Weckesser Jan 06 '16 at 00:50
  • Heh, when you find a more direct and efficient way to do it, *then* you can say that. :) – Warren Weckesser Jan 06 '16 at 00:51
  • @WarrenWeckesser Wow, thats a lot of packages with Anaconda! Thanks for telling me about this! :) – R. Kap Jan 06 '16 at 00:56

0 Answers0