I am new to python and pygame. Can somebody help me in this please. Thanks in advance
Asked
Active
Viewed 300 times
-2
-
1Possible duplicate of [How can I detect if the user has double-clicked in pygame?](http://stackoverflow.com/questions/9918808/how-can-i-detect-if-the-user-has-double-clicked-in-pygame) – skrx Mar 09 '17 at 08:55
-
I've added another answer to the linked question. – skrx Mar 09 '17 at 10:21
2 Answers
0
This uses tkinter
, but you can try this:
from tkinter import *
tk = Tk()
def helloworld(event):
print('Hello world!')
tk.bind_all('<Double-Button-1>', helloworld)
Sorry this uses Left Click, but I hope it answers. You can do any code in the function, just make sure you don't use parentheses.

codecrafter_123
- 15
- 5
-1
This code worked for me.
global clock, double_click_event, timer
double_click_event = pygame.USEREVENT + 1
timer = 0
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key==pygame.K_SPACE:
if timer == 0:
pygame.time.set_timer(double_click_event, 500)
timerset = True
x, y = pyautogui.position()
pyautogui.click(x, y, button='left')
else:
if timer == 1:
pygame.time.set_timer(double_click_event, 0)
double_click()
timerset = False
if timerset:
timer = 1
else:
timer = 0

dc_flash
- 1
-
The code doesn't seem to work correctly. I can still double click after an arbitrary amount time. Also, what's pyautogui? – skrx Mar 09 '17 at 09:41
-