Bottom Page

• 0 Vote(s) - 0 Average
• 1
• 2
• 3
• 4
• 5
 Moving with objects in tkinter dan789 Not Blown Up Yet Posts: 66 Threads: 19 Joined: Nov 2018 Reputation: 0 Likes received: 0 #1 Dec-14-2018, 07:06 PM Hi all, can anybody tell me, how to find out if some object is currently located at specific coordinates? Let´s consider object1 at x=100,y=100 and I want to know, if object2 is located somewhere near to this object1, let´s say up to 50px. How to write it and what´s the syntax of this? I already know that I can change coordinates by canvas.coords(object, xy) or change some parameters of that object by canvas.itemconfig(object, parameters). Thanks a lot. Gribouillis Posts: 1,571 Threads: 12 Joined: Jan 2018 Reputation: 146 Likes received: 375 #2 Dec-15-2018, 08:28 AM (This post was last modified: Dec-15-2018, 08:29 AM by Gribouillis. Edited 1 time in total.) There are several ways to measure the distance between two points in the plane ```def distA(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2) def distB(x1, y1, x2, y2): return ((x1 - x2)**2 + abs(y1 - y2)**2)**0.5 def distC(x1, y1, x2, y2): return max(abs(x1 - x2), abs(y1 - y2)) ``` dan789 Not Blown Up Yet Posts: 66 Threads: 19 Joined: Nov 2018 Reputation: 0 Likes received: 0 #3 Dec-15-2018, 01:04 PM Well but I need to know how to write a coordinates for specific objects. Let´s say object1 is 100,50. How can I write this without specific numbers? Just something like object1_x ? « Next Oldest | Next Newest »

Top Page

 Possibly Related Threads... Thread Author Replies Views Last Post [Turtle]Need help with moving a square on key press GalaxyCoyote 2 179 May-18-2019, 05:31 PM Last Post: Yoriz moving from os to subprocess Barrowman 10 2,305 Dec-20-2017, 09:08 AM Last Post: Barrowman [PyQt] how to dynamically add objects to pyqt window LavaCreeperKing 1 5,549 Apr-26-2017, 09:15 PM Last Post: joe_anonimist

Forum Jump:

Users browsing this thread: 1 Guest(s)