Created
August 28, 2019 17:29
-
-
Save rbricheno/e9782a26ffa45c1d8c75807a4d4fbd60 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from threading import Thread | |
class HoldDownOrchestrator(): | |
def __init__(self): | |
self.call = None | |
hold_down_singleton = HoldDownOrchestrator() | |
def hold_down(a_function, timer, *args, **kwargs): | |
global hold_down_singleton | |
hold_down_singleton.call = None | |
a_function(*args, **kwargs) | |
time.sleep(timer) | |
hold_down_singleton.call = hold_down | |
hold_down_singleton.call = hold_down | |
def function_to_hold_down(*args, **kwargs): | |
print("Hello!") | |
while True: | |
print("Pressing!") | |
thread1 = Thread(target=hold_down_singleton.call, args=[function_to_hold_down, 5]) | |
thread1.start() | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment