I'm working on a script in python,tkinter that draws a triangle and moves it around the screen. unfortunately I can't get the arrow to move. I've tried using canvas.move() but that wants an x and a y not the set of 3 coordinates I have to make it a triangle. Is there something I'm missing or maybe an easier way to move it? and help would be appreciated.

Recommended Answers

All 7 Replies

Re: python,tkinter, moving an object 80 80

Those are the coordinates you need to set for a traingle. Most graphical programs use an x,y coordinate system like so.
|-----------------x
|(0,0) (1,0) (2,0)
|(0,1) (1,1) (2,1)
|(0,2) (1,2) (2,2)
y

A triangle can be described as 3 points or this may also suprise you but possibly 4 points. If we start our triangle at (0,0), next draw a line to (0,2), then a line to (2,2), to finish we draw a line back to (0,0).

Re: python,tkinter, moving an object 80 80

thanks for the try predator but I have 3 (x,y) sets but the canvas.move() wants a move for the x axis and the y axis. I'm looking for a way to define the new location.

Re: python,tkinter, moving an object 80 80

Of course you can move the triangle up/down or left/right only as canvas is 2d surface.

Re: python,tkinter, moving an object 80 80

Well what direction do you want it to move and when? You should only have to specify an offset for your new location. For example (x+1),(y+0). Beyond that I believe we may have to take a look at your code to see what you are trying to achieve.

Re: python,tkinter, moving an object 80 80

I'm trying to get the arrow to move and turn by user actions I'll see if I can get a small working section of the code for you guys

Re: python,tkinter, moving an object 80 80

well I figured out what was wrong in my program. I was using

canvas.coords(tag,coordinates)#to move the object but I also needed
canvas.tag_raise(tag)#to make the object appear on top
commented: glad you got it working :) +3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.