[Image-SIG] Problem in storing tkinter canvas as PNG file using
suresh_vsamy at rediffmail.com
Wed Jun 25 08:07:27 EDT 2003
Iam using python2.2/tkinter/windows. I have drawn some
rectangles in my canvas. Now I want to store my canvas as a PNG
file. Iam using "ImageGrab" to grab the canvas. Iam getting the
result as i expected when the canvas size is less than
"canvas.winfo_width" and "canvas.winfo_height". But when the
larger than that, iam not getting the entire canvas image.
My coding is given below.
from Tkinter import *
canvas = Tkinter.Canvas(width=1600, height=1400)
canvas.create_line(0, 0, 1600, 1400, fill="red", width=10)
if sys.platform == "win32":
# get window location
x0 = canvas.winfo_rootx()
y0 = canvas.winfo_rooty()
x1 = x0 + canvas.winfo_reqwidth()
y1 = y0 + canvas.winfo_reqheight()
im = ImageGrab.grab((20,20, x1,y1))
print "X1 : ",x1," Y1: ",y1
root = Tk()
How can i make the entire canvas as PNG file irrespective
of its size?
Get www. mycompany .com and 5 matching email ids.
Just Rs. 1499/ year.
Click here http://www.rediffmailpro.com
More information about the Image-SIG