Re: x, y coordinates in Tkinter canvas

Discussion in 'Python' started by jepler@unpythonic.net, Nov 11, 2005.

  1. Guest

    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()

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.1 (GNU/Linux)

    iD8DBQFDdS9LJd01MZaTXX0RAvNIAJ4552/g04KpSXqt2r/oqh1Z7A27jACeJSGz
    EBRFIU7j0uFQbw5pgkZFQt4=
    =wqwa
    -----END PGP SIGNATURE-----
     
    , Nov 11, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Suresh  Kumar
    Replies:
    0
    Views:
    595
    Suresh Kumar
    Jul 3, 2003
  2. Suresh  Kumar
    Replies:
    0
    Views:
    517
    Suresh Kumar
    Jul 4, 2003
  3. Askari
    Replies:
    2
    Views:
    716
    Askari
    Aug 30, 2004
  4. PhilC
    Replies:
    2
    Views:
    896
    PhilC
    Oct 25, 2004
  5. Shi Mu
    Replies:
    0
    Views:
    344
    Shi Mu
    Nov 11, 2005
Loading...

Share This Page