()
| 25 | |
| 26 | |
| 27 | def main(): |
| 28 | layout = [ [sg.Text('My Window')], |
| 29 | [sg.Input(key='-IN-')], |
| 30 | [sg.Input(key='-IN2-')], |
| 31 | [sg.Input(key='-IN3-')], |
| 32 | [sg.Input(key='-IN4-')], |
| 33 | [sg.Input(key='-IN5-')], |
| 34 | [sg.Input(key='-IN6-')], |
| 35 | [sg.Input(key='-IN7-')], |
| 36 | [sg.Button('Go'), sg.Button('Exit')]] |
| 37 | |
| 38 | window = sg.Window('Window Title', layout, finalize=True) |
| 39 | |
| 40 | # Bind the Left, Right and Down arrow keys to events |
| 41 | window.bind('<Right>', '-NEXT-') |
| 42 | window.bind('<Left>', '-PREV-') |
| 43 | window.bind('<Down>', 'Exit') |
| 44 | |
| 45 | while True: # Event Loop |
| 46 | event, values = window.read() |
| 47 | print(event, values) |
| 48 | if event == sg.WIN_CLOSED or event == 'Exit': |
| 49 | break |
| 50 | # Right arrow pressed, so move to the next element that should get focus |
| 51 | if event == '-NEXT-': |
| 52 | next_element = window.find_element_with_focus().get_next_focus() |
| 53 | next_element.set_focus() |
| 54 | |
| 55 | # Left arrow pressed, so move to the previous element that should get focus |
| 56 | if event == '-PREV-': |
| 57 | prev_element = window.find_element_with_focus().get_previous_focus() |
| 58 | prev_element.set_focus() |
| 59 | window.close() |
| 60 | |
| 61 | if __name__ == '__main__': |
| 62 | main() |
no test coverage detected