2

I'm building a simple paint program in Python as a project, using Pygame it works by basically drawing a stream of circles when the mouse gets pressed and you drag it around the surface, it's got a couple other little things going on but the thing I want to ask is, is there a way to change the singular mouse input you know mouse.get_pressed to either multiple mouse inputs at one time or a multi-touch input into the point list that's streaming the circles.

running= True

while running:

if buttons[0] == True:
    x,y = pygame.mouse.get_pos()

    if x> PA+AS:
        xShift = x - PA - AS
        pygame.draw.circle(pArea,DRAW_CLR,(xShift,y),BRUSHSIZE)
        pygame.display.flip()

so this is the part of the code I really want to change more or less. Just so that instead of just one mouse, I could use my touchscreen to draw with maybe two finger.

3
  • Can you be more specific Commented Jan 22, 2015 at 4:51
  • I can try i guess so running= True while running: if buttons[0] == True: x,y = pygame.mouse.get_pos() if x> PA+AS: xShift = x - PA - AS pygame.draw.circle(pArea,DRAW_CLR,(xShift,y),BRUSHSIZE) pygame.display.flip() pArea being the subsurface i'm drawing on and PA and AS being ints relative to the size of the surface. basically instead of just drawing with one input (the mouse) i wondered if there was a way to utilize my computers touchscreen, and draw with more then one finger at a time and how to do that. Commented Jan 22, 2015 at 4:54
  • 1
    You can update your question with your code. Avoid to add it in comments. Commented Jan 22, 2015 at 4:56

2 Answers 2

2

Latest versions of pygame support multitouch input (and I believe also gestures).

The events which control it are pygame.FINGERDOWN, .FINGERUP and .FINGERMOTION. My understanding is that they work like mouse inputs, but can be multiple and can be distinguished by means of an event.finger_id property.

An example can be found here: https://www.patreon.com/posts/finger-painting-43786073?l=fr

Sign up to request clarification or add additional context in comments.

Comments

0

You're going to have a difficult time if you insist on doing this in PyGame. Your best bet for multitouch in Python is Kivy, which was a very solid framework a few years ago when I used it and appears to have only gotten better since.

The disadvantage of switching to Kivy is a more complicated API, but this tutorial seems spot-on for what you're trying to do.

2 Comments

the advice is appreciated thank you. but for the purpose of this program it would be best if i dound some way to do it in PyGame. I'll try kivy if i run out of options
last version of pygame (I think it's version 2), supports multitouch. An example can be found here patreon.com/posts/finger-painting-43786073?l=fr

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.