Welcome to the CSC Q&A.
Get help and give help!
Write great code!
It is our choices... that show what we truly are, far more than our abilities.


+3 votes

I created a list of buttons in my graphics window and I'm trying to get the buttons to activate, but no matter where I click in my window, Python says that I'm not clicking inside any buttons and they won't activate.

while not ready:
clickPt = win.getMouse()
for button in buttonList:
    if button.isClicked(clickPt):
asked in CSC201 Spring 2021 by (798 points)

2 Answers

+2 votes

You should try to activate the button after you created it rather than after you click on it

answered by (132 points)
0 votes

The button should be activated right after you make and draw the button, and before getting a click from the mouse.


button = Button(Point(10,10),10,10,"Button")
ready = False
while not ready:
    clickPt = win.getMouse()
    if button.isClicked(clickPt):
       ready = True

Hope this helps!

answered by (244 points)