1

I am trying to teach my 11 year old granddaughter to program in python. Most programs recommend starting with turtle module/graphics. Lesson one is so far so good. However she has expressed the desire to print hard copies of the image that is created on her screen so she can show it around to her friends. I cannot figure out how to do that within python. I cannot figure out how to send the image to the printer. We are using Windows 10 32 bit and python 3.2. Any help would be appreciated

mike9172
  • 11
  • 3

2 Answers2

0

try :

import tempfile
import win32api
import win32print

filename = tempfile.mktemp (".txt")
open (filename, "w").write ("This is a test")
win32api.ShellExecute (0, "print", filename,  '/d:"%s"' % win32print.GetDefaultPrinter (),
  ".",
  0
)
Nagmat
  • 373
  • 4
  • 14
  • Thank you for your advice. This works real well with a text file produced by python. My issue is that I don't have a text file – mike9172 Apr 08 '21 at 06:56
  • Sorry meant to complete it. My python idle file is the following: import turtle t =turtle.Pen() t.speed(9) for x in range(100): t.fd(x) t.lt(91) #This opens a python shell window and then a window just labelled python turtle graphics which is the output that I would like to print (save to the computer) to the printer. I appreciate any further advice that you could offer – mike9172 Apr 08 '21 at 07:07
0

The easiest way would be to take a screenshot using shift + windows + 4 and then paste it into MS paint.

Python Turtle Module- Saving an image

you could also use something like this to save it as an image and then print.

10 Replies
  • 426
  • 9
  • 25