Created
May 23, 2019 05:23
Revisions
-
ijkilchenko created this gist
May 23, 2019 .There are no files selected for viewing
This file contains 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,59 @@ import keyboard import time if __name__ == '__main__': frames = [0] def forward(): global last_frame_index while True: if not is_paused: last_frame = frames[-1] new_frame = last_frame + 1 frames.append(new_frame) last_frame_index = len(frames) - 1 print('Forward\t[%d]' % new_frame) time.sleep(0.01) def resume(*args): global hook keyboard.unhook(hook) hook = keyboard.on_press_key('k', pause) global is_paused is_paused = False def pause(*args): global hook keyboard.unhook(hook) hook = keyboard.on_press_key('k', resume) global is_paused is_paused = True def rewind(*args): global last_frame_index last_frame_index += -1 try: print('Rewind\t[%d]' % frames[last_frame_index]) except IndexError: last_frame_index = 0 pause() def fastforward(*args): global last_frame_index last_frame_index += 1 try: print('FastForward\t[%d]' % frames[last_frame_index]) except IndexError: last_frame_index = len(frames) pause() global hook hook = keyboard.on_press_key('k', pause) keyboard.on_press_key('j', rewind) keyboard.on_press_key('l', fastforward) is_paused = False forward()