Hello,

I would like to save the drawings I have made on a Canvas with the Tkinter Module.

Is it possible to make a .jpg or .gif or .bmp from a Tkinter window ?

Thank you!

Ok i've found the response on www.developpez.net
It uses the .postscript method from canvas and the ImageGrab module

Bonjour,
Il y a la méthode '.postscript', qui génère ... du postscript.
Sous MS windows, tu peux utiliser ImageGrab (PIL). Je ne crois pas que cela fonctionne sous Linux.
x = canvas.winfo_rootx()
y = canvas.winfo_rooty()
w = canvas.winfo_width()
h = canvas.winfo_height()
img= ImageGrab.grab((x+2, y+2, x+w-2, y+h-2)).save("tmp.bmp")

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.