[Tkinter-discuss] tkinter coordinates, conversion
fredrik at pythonware.com
Sun Mar 30 15:37:35 CEST 2008
Ron Provost wrote:
> Is there any way in tkinter to convert between coordinate systems?
> Specifically, I'm refering to the canvas. I'm getting x and y's back in
> mouse events and I would like to convert them back to inches 'i',
> centemeters 'c', millimeters 'm' or points 'p'.
use winfo_screenheight() and winfo_screenmmheight() to determine the
pixel size, and use that to calculate "real-life" values. e.g.
pixel_size = w.winfo_screenmmheight() / w.winfo_screenheight()
x = x * pixel_size
print x, "mm"
print x/10.0, "cm"
print x/25.4, "inches"
print 72*x/25.4, "points"
More information about the Tkinter-discuss