[Tutor] Needs urgent solution................
Suresh Kumar
Suresh Kumar" <suresh_vsamy@rediffmail.com
Wed Jun 25 13:16:52 2003
Hi Alfred,
Thanks for your timing reply. I tried the program that is
posted in the link given by you. It is working fine. Still i
have
a problem. In your program you limited the canvas size to
600,600.
Since it is less than a normal screen iam getting the entire
line
wihich is drawn on the canvas. But if i increase the size of
canvas to 2 pages, say casvas size is (1600,1500), i am not
getting the entire canvas as a PNG file.
My coding is given below.
import sys
from Tkinter import *
import Tkinter
import ImageGrab
canvas = Tkinter.Canvas(width=1600, height=1400)
canvas.create_line(0, 0, 1600, 1400, fill="red", width=10)
canvas.pack()
canvas.update()
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
else:
raise NotYetImplemented("oops!")
im.show()
im.save("c:\\outfile.png", "PNG")
root = Tk()
root.mainloop()
The above code is not capturing the canvas of size
(1600,1400).
How can i make the entire canvas as PNG file irrespective
of its size?
With Regards,
V.Suresh Kumar
On Wed, 25 Jun 2003 Alfred Milgrom wrote :
>At 01:04 PM 24/06/03 +0000, Suresh Kumar wrote:
>>Hi,
>>
>> I am using python/tkinter/windows. How to store tkinter
>>canvas screen as a PNG file? I have drawn some rectangles in
>>my
>>canvas and i want to store it as a PNG file so that i can use
>>it
>>for further processing. How can i do it?
>>
>>Thanx.
>
>Hi:
>
>I was asking a similar question just a short while ago, got
>very
>good advice from Magnus Lycka, and I posted my research on
>specifically grabbing Tkinter canvas on 19/6:
>http://mail.python.org/pipermail/tutor/2003-June/023456.html
>
>Basically the answer lies in the ImageGrab module available in
>the PIL library. PIL is available from
>http://www.pythonware.com/products/pil/index.htm#pil114
>
>Info on Tkinter grabbing is available at
>http://mail.python.org/pipermail/image-sig/2003-May/002292.html
>
>All the best,
>Fred Milgrom
>
___________________________________________________
Get www. mycompany .com and 5 matching email ids.
Just Rs. 1499/ year.
Click here http://www.rediffmailpro.com