bczsalba / pytermgui

Python TUI framework with mouse support, modular widget system, customizable and rapid terminal markup language and more!
https://ptg.bczsalba.com
MIT License
2.21k stars 54 forks source link

Prevented blocking getch call on Windows #43

Closed meson800 closed 2 years ago

meson800 commented 2 years ago

Check msvcrt.kbhit() before attempting to get characters from stdin. If there are no characters available, simply return an empty string.

Fixes #42

bczsalba commented 2 years ago

So I can't really test it at the moment, have you been able to verify it works? I really ought to get some Windows-specific tests going.

meson800 commented 2 years ago

I've just started using pytermgui so not entirely sure what to check for; this change does fix the blocking-on-import problem and some of the documentation examples seem to work properly. I need to check to make sure that it's working both on Windows and Linux, so perhaps it's best to just convert this to a draft pull request/close it until I play around with it some more.

bczsalba commented 2 years ago

I can test it on MacOS in a couple of hours, but honestly as long as anything involving user input works on your end it should be fine, as this part of the code is Windows-specific.

Thank you for checking out the project, btw!

bczsalba commented 2 years ago

Alright, so it does work on my end. If it works on Windows on your side I will happily merge this.

meson800 commented 2 years ago

It appears to work on my end too!

If I get some time in the future, I might be able to contribute some further Windows work.

bczsalba commented 2 years ago

Great then! I'll merge this.

Any work on the windows side would be appreciated!