pythonclasslong-press

Long Press (python) record button and play voice


I have a button, and i am trying to fire two actions in one button. I I do not know, to use long press call a class speak

try several ways but none please help me

def speak():
tts.save(filename)
   playsound.playsound(filename)
speak()
name = driver.find_element_by_xpath(element)
TouchAction.long_press(name, duration=3000).perform().release()???

Solution

  • You could do like this:

    def do_two_things():
        do_this()
        do_that_too()
    
    def do_this():
        # do this thing
    
    def do_that_too():
        # yes, do that too!
    
    ...
    TouchAction.long_press(name, duration=3000).do_two_things()