-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathDemo_Hotkey.py
More file actions
32 lines (22 loc) · 914 Bytes
/
Copy pathDemo_Hotkey.py
File metadata and controls
32 lines (22 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import PySimpleGUI as sg
"""
Demo Hotkey
Want a keyboard hotkey to cause your program to take some action
that's identical to a button being clicked?
Well... that's 1 line of code that's needed.
This line binds the F10 keybaord key to the window. It produces a "Go" event:
window.bind('<F10>', 'Go')
Copyright 2018-2026 PySimpleGUI. All rights reserved.
"""
layout = [ [sg.Text('Press F10 to get same result as clicking "Go" button')],
[sg.Input(key='-IN-')],
[sg.Output(size=(30,8))],
[sg.Button('Go'), sg.Button('Exit')] ]
window = sg.Window('Window Title', layout, finalize=True)
window.bind('<F10>', 'Go') # Make sure your window is finalized first
while True: # Event Loop
event, values = window.read()
print(event, values)
if event in (sg.WIN_CLOSED, 'Exit'):
break
window.close()