x, y coordinates in Tkinter canvas

jepler at unpythonic.net jepler at unpythonic.net
Sat Nov 12 00:54:51 CET 2005


Let's find out!  This program creates a series of rectangles, with the color
going from black to nearly white.  White corresponds to higher x and y
coordinate values.  So the answer to your question can be seen in the output
of the program.

import Tkinter

c = Tkinter.Canvas(width=220, height=220)
c.pack()

for i in range(0, 200, 20):
        lum = i * 255 / 200
        color = "#%02x%02x%02x" % (lum, lum, lum)
        c.create_rectangle( i, i, i+40, i+40, fill=color)

c.mainloop()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20051111/4bce692b/attachment.pgp>


More information about the Python-list mailing list