I used Tkinter to draw some lines in python and I would like to print that picture to usb connected and/or network printer in Windows. How should I do that?
Asked
Active
Viewed 1.7k times
8
-
Depends on your system. Are you on windows or another? – TheLazyScripter Apr 14 '16 at 15:59
-
thanks for pointing it out. it's Windows – BK C. Apr 14 '16 at 16:00
-
You need to first convert your graphics into an image file and then print that. Windows can print .bmp files natively, so that might be a good image file type to create. To get started see [_How can I convert canvas content to an image?_](http://stackoverflow.com/questions/9886274/how-can-i-convert-canvas-content-to-an-image) – martineau Apr 14 '16 at 16:22
-
Tim Golden has a good [_How do I print?_](http://timgolden.me.uk/python/win32_how_do_i/print.html) Python Stuff article that's Window specific. – martineau Apr 14 '16 at 16:32
1 Answers
8
try this! It uses os module to start the file in the default printer!
import os
os.startfile("YourDocument", "print")

TheLazyScripter
- 2,541
- 1
- 10
- 19
-
1This definitely works. but am curious is there a way to print the file without having to open it first – Twage Mwakajumba Jun 08 '22 at 11:59