0

So I have created a Turtle graphics program where the user can draw many different shapes on a canvas, and have implemented the ability for the user to save the canvas with his/her own name as a Postscript (.ps) file using a file browser. The file apparently has no problem opening up in Preview on my Macintosh. I have also allowed the user to import ANY .gif image they want and set that as the canvas color of the window or even just set it to a solid color if they don't want to use an image. However, I noticed that whenever I change ONLY the canvas color of the window, save it as a postscript file, and then open it, the canvas color does NOT show up, but the rest of the colors do, including the turtle's. What's even weirder is that if I instead set an image as the canvas, it shows up in the saved postscript file along with everything else. So, why is this happening, and how would I fix it? Any help is very much appreciated! :)

P.S. I have already seen this similar question, but it apples to Python 2.x, while I have 3.5. I also don't like the solution of that question and I am hoping there is another, better way to fix this now.

Here is my save code:

def savefirst():
    cnv = getscreen().getcanvas() 
    global hel
    hel = filedialog.asksaveasfilename(defaultextension = '.ps')
    fev = cnv.postscript(file = hel, colormode = 'color')
    try:
        if open(hel, 'r'):
            savefirst.save = True
    except:
        savefirst.save = False

And here is a screenshot of the canvas itself comparing it to a screenshot of the Postscript file-

Screenshot of canvas itself: Screenshot

Screenshot of Postscript file (in Preview): Postscript file screenshot

EDIT: I have looked around a lot, but I cannot find an answer that apples to Python 3.x.

martineau
  • 119,623
  • 25
  • 170
  • 301
R. Kap
  • 599
  • 1
  • 10
  • 33
  • 1
    turtle is a wrapper for tkinter which is a wrapper for tcl/tk, which does all the drawing on the screen. Your question *is* a duplicate because the python version is irrelevant to what the tcl/tk save-to-postscript code does. – Terry Jan Reedy Jan 13 '16 at 05:54
  • @TerryJanReedy I was hoping there was a better solution than there was for that question, but I guess considering your response, there is not. – R. Kap Jan 13 '16 at 06:01
  • In my experiments with .ps output from tk on Windows, the problems were worse. There may have been a version mismatch, but when I looked at the .ps file itself, it did not seem right. When I seriously want to capture tkinter output, I will either use a screen capture program or look into the tcl/tk extension for creating modern .svg (scaled vector graphics) files. (I have never used a tcl/tk extension, but I believe there are web pages explaining them. There either are or could be SO Q and A's.) – Terry Jan Reedy Jan 13 '16 at 06:19
  • @TerryJanReedy But what I don't get is why does a background **image** appear in the Postscript file, but not a background color? – R. Kap Jan 13 '16 at 06:24
  • R.Kap: I've modified my answer to the question @TerryJanReedy said was a duplicate so now it will work in both Python 2 and 3 — so your question ***is*** a duplicate now. – martineau Feb 24 '20 at 22:15

0 Answers0