Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mouse buttons problem #1

Closed
d0ob opened this issue Oct 1, 2021 · 2 comments
Closed

Mouse buttons problem #1

d0ob opened this issue Oct 1, 2021 · 2 comments

Comments

@d0ob
Copy link

d0ob commented Oct 1, 2021

Hello there !

Here the code launches, but as soon as I click with the mouse, it tells me :

File "c:\code\Python\Game_of_Life\src\main.py", line 38, in edit_automanton
if pygame.mouse.get_pressed(0):
ValueError: Number of buttons needs to be 3 or 5.

From what I found online, seems to be related to number of button in pygame ? I don’t really understand…
I have all dependencies and everything is up-to-date. And the only thing I customized in the code is assets paths.

@FranciscoCharles
Copy link
Owner

Hi d0ob, your pygame version is probably higher than 1.9.6. I ran the installation of the newest version 2.0.1 and managed to reproduce your problem. I just uploaded the fix which also works for pygame == 2.0.1.

giving the solution immediately, replace:

    if pygame.mouse.get_pressed(0):

per:

    if pygame.mouse.get_pressed()[0]:

or:

    (click, *_) = pygame.mouse.get_pressed()
    if click:

@d0ob
Copy link
Author

d0ob commented Oct 1, 2021

Amazing ! Works like a charm =3
Oh I see, didn’t think about that, the problem was kindof opposite so, «up-too-much-date» ^^
Evolution of Python’s «infrastructure» is something I’ll have in mind now.

To familiarize with Python I’ve looked online multiple people’s version of the game of life, regardless of the package, the rendering, etc… Yours is incredible ! Still mostly wizardry for me ^^ But I’m deconstructing it and customizing what I can, I love it !

Thank you so much for the sharing ! And also for the super quick answer and fix !

@d0ob d0ob closed this as completed Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants