inputs
inputs copied to clipboard
EOFError when there isn't main()
I tried to run the keyboard_example.py example and it works fine but when I removed def main()
and if __name__ == "__main__"...
there was EOFError. In other words, this:
"""Simple example showing how to get keyboard events."""
from __future__ import print_function
from inputs import get_key
"""Just print out some event infomation when keys are pressed."""
while 1:
events = get_key()
if events:
for event in events:
print (event.ev_type, event.code, event.state)
results in:
Traceback (most recent call last):
File "C:/Python27/TEST_ENV/_my/inputs/test2.py", line 9, in <module>
events = get_key()
File "C:\Python27\TEST_ENV\lib\site-packages\inputs.py", line 3661, in get_key
return keyboard.read()
File "C:\Python27\TEST_ENV\lib\site-packages\inputs.py", line 2517, in read
return next(iter(self))
File "C:\Python27\TEST_ENV\lib\site-packages\inputs.py", line 2471, in __iter__
event = self._do_iter()
File "C:\Python27\TEST_ENV\lib\site-packages\inputs.py", line 2495, in _do_iter
data = self._get_data(read_size)
File "C:\Python27\TEST_ENV\lib\site-packages\inputs.py", line 2575, in _get_data
return self._pipe.recv_bytes()
EOFError