Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Windows, PyCharm, Python, tkinter, Canvas, program question There are three circles in the tkinter Canvas code with different colors. I want it to call the recolor method when I click on a circle. Unfortunately, I just can’t specify the If else conditions. I want to click with the same mouse button. The first round is ok, but the rest of the rounds are not! How should I write the code so that when I click on any circle with the same mouse button, the circle turns blue?
import tkinter as tk
class CanvasEvents(tk.Tk):
def __init__(self):
super().__init__()
self.geometry('510x510+700+100')
self.title("Event")
self.canvas = tk.Canvas(self, bg='grey', width=500, height=500)
self.canvas.pack(pady=5)
kor1 = self.canvas.create_oval(20, 20, 100, 100, width=2, fill="orange")
kor2 = self.canvas.create_oval(220, 20, 300, 100, width=2, fill="red")
kor3 = self.canvas.create_oval(420, 20, 500, 100, width=2, fill="green")
self.canvas.tag_bind(kor1, '<Button-1>', self.object_click_event)
self.canvas.tag_bind(kor2, '<Button-1>', self.object_click_event)
self.canvas.tag_bind(kor3, '<Button-1>', self.object_click_event)
def object_click_event(self, event):
# If else ?????????????????????
self.canvas.itemconfigure(event.num, fill="blue")
print('Clicked object at: ', self.canvas.coords(event.num), event.num)
if __name__ == "__main__":
ablak = CanvasEvents()
ablak.mainloop()
4e4da0fb6ddc47698d38708ef00582
Olaoluwa Aina
1fd6b9d2a2b94ee4b3e8ee6d5e2587
10a048f2c39c400085f753558df5b6
mr.tarik098
52e29d3d61b842f683ad25e5ff72f6
Priyankeshu Parihar
Lea Cards
marioAngler
Arbee4ever
DaveT