[Tutor] Help with the following code..
bgailer at alum.rpi.edu
Thu Nov 23 23:29:26 CET 2006
Asrarahmed Kadri wrote:
> Hi all,
> Trying to draw a simple bar chart on canvas of Tkinter.
> Here is code:
> from Tkinter import *
> root = Tk()
> frame = Frame(root)
> canvas = Canvas(frame,height=400,width=400)
> canvas.create_line(50,350,350,350,width=2) # draws the X-axis
> canvas.create_line(50,350,50,50,width=2) # draws teh Y-axis
> canvas.create_rectangle(50,340,250,330) # this is the first
> HORIZONTAL BAR
> canvas.pack ()
> I am not able to understand why two pairs of co-ordinates are
> supplied?? The rectangle requires 4 co-ordinate pairs, Isnt it??
Don't you have any Tkinter documentation? One reference I have says:
"6.9. The canvas rectangle object - Each rectangle is specified as two
points: (x0, y0) is the top left corner, and (x1, y1) is the bottom right
I highly advise you get a reference. The Tkinter module document under
the Python Manuals - Global Module Index lists several. BTW how can you
write code without a reference? Are you copying examples?
More information about the Tutor