python - I'm having trouble calling up a value inside a class -


I am having trouble calling this value in class and I do not understand what is wrong with this implementation May be

  click the square image: def image_clicked (auto, event): self.x = event.x self.y = event.y userClick = imageClick () print userClick.image_clicked. X    

imageClick Should be an introductory method for location:

  click the square image: def __init __ ( Auto): self.x = None at all self.y = any def image_comic (self, event): self.x = event.x self.y = Event.y   

now Try it:

  userClick = imageClick () userClick.image_clicked (someEvent) Print userClick.x   

Note that imageClick 'S image_clicked () method is expected to have an event as a parameter - and that is where the coordinates are obtained from x and y Are done.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -