New question #661793 on Sikuli:
https://answers.launchpad.net/sikuli/+question/661793

In your docs, I suggest you updtae the pattern for hotkey debouncing. The old 
pattern ends up creating a variable and an "IF" check for every single new 
hotkey added, and is somewhat tedious. I suggest using a clever python trick of 
function passing and lambdas. Here is a better pattern. With this pattern, to 
add a new hotkey, you simply add a function and addHotKey() and DONE:


doing = None
def do(command):
    global doing
    doing = command


def helloWorld(): 
    popup("Hello World")

running = True
def quitSikuli(e):
    global running
    popup("Exiting")
    running = False
            
Env.addHotkey("x", KeyModifier.ALT+KeyModifier.SHIFT+KeyModifier.CTRL, 
quitSikuli)
Env.addHotkey("c", KeyModifier.ALT+KeyModifier.SHIFT+KeyModifier.CTRL, lambda 
e: do(helloWorld))


while running:
    if doing:
        doing()
        doing = None
    wait(1)

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.

_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to     : sikuli-driver@lists.launchpad.net
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to