| 67 | |
| 68 | |
| 69 | class GUI(): |
| 70 | def __init__(self): |
| 71 | layout = [[sg.Text('Enter Text')], |
| 72 | [sg.Input('', size=(17, 1), key='input1')], |
| 73 | [sg.InputText('', size=(17, 1), key='input2')], |
| 74 | [sg.Button('on-screen keyboard', key='keyboard')], |
| 75 | [sg.Button('close', key='close')]] |
| 76 | |
| 77 | self.mainWindow = sg.Window('On-screen test', layout, |
| 78 | grab_anywhere=True, no_titlebar=False, finalize=True) |
| 79 | location = self.mainWindow.current_location() |
| 80 | location = location[0]-200, location[1]+200 |
| 81 | self.keyboard = keyboard(location) |
| 82 | self.focus = None |
| 83 | |
| 84 | def run(self): |
| 85 | while True: |
| 86 | cur_focus = self.mainWindow.find_element_with_focus() |
| 87 | if cur_focus is not None: |
| 88 | self.focus = cur_focus |
| 89 | event, values = self.mainWindow.read( |
| 90 | timeout=200, timeout_key='timeout') |
| 91 | if self.focus is not None: |
| 92 | self.keyboard.update(self.focus) |
| 93 | if event == 'keyboard': |
| 94 | self.keyboard.togglevis() |
| 95 | elif event == 'close' or event == sg.WIN_CLOSED: |
| 96 | break |
| 97 | self.keyboard.close() |
| 98 | self.mainWindow.Close() |
| 99 | |
| 100 | |
| 101 | if __name__ == '__main__': |
no outgoing calls
no test coverage detected