0

I am making a project using pygame, and in order to debug, I need to know the name of the rectangle I am clicking on. They are all instances of the class "button".

I declared it as tl = button(screen_width/10,screen_height/10,5,5)

I tried print(f"{self} was clicked"), but that outputs : <rect(30, 30, 60, 60)> was clicked.

I want it to output tl was clicked

How do I make it output the name of the variable / object?

My temporary solution is : print(int(((self[0]/30)//3)+1),int(((self[1]/30)//3)+1))

0 Answers0