Skip to content

Commit d8430fd

Browse files
committed
add flushing of stdout to update on key event
Doing this as a demo for UC Berkeley Practical Neuroimaging class on contributing to open source while getting your work done
1 parent 8ec9555 commit d8430fd

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

examples/event_handling/keypress_demo.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
Show how to connect to keypress events
55
"""
66
from __future__ import print_function
7+
import sys
78
import numpy as np
89
import matplotlib.pyplot as plt
910

1011

1112
def press(event):
1213
print('press', event.key)
14+
sys.stdout.flush()
1315
if event.key=='x':
1416
visible = xl.get_visible()
1517
xl.set_visible(not visible)

0 commit comments

Comments
 (0)