bchao1 / bullet

🚅 Interactive prompts made simple. Build a prompt like stacking blocks.
https://pypi.org/project/bullet/
MIT License
3.55k stars 113 forks source link

No termios on windows #2

Open EvilGrinUK opened 5 years ago

EvilGrinUK commented 5 years ago

Hi,

bullet doesn't work on Windows as there is no termios module. I get the following stack trace when trying to run this example code under CPython 3.7.2 on Windows 10 v1803 Enterprise.

Traceback (most recent call last):
  File "h:\Python\Misc\bullet_test.py", line 1, in <module>
    from bullet import Bullet
  File "C:\Program Files\Python37\lib\site-packages\bullet\__init__.py", line 1, in <module>
    from .client import Bullet
  File "C:\Program Files\Python37\lib\site-packages\bullet\client.py", line 4, in <module>
    from . import utils
  File "C:\Program Files\Python37\lib\site-packages\bullet\utils.py", line 3, in <module>
    import tty, termios
  File "C:\Program Files\Python37\lib\tty.py", line 5, in <module>
    from termios import *
ModuleNotFoundError: No module named 'termios'

Confirmed from the ipython shell directly using the import command.

In [1]: import bullet
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-14022d50bf52> in <module>
----> 1 import bullet

c:\program files\python37\lib\site-packages\bullet\__init__.py in <module>
----> 1 from .client import Bullet

c:\program files\python37\lib\site-packages\bullet\client.py in <module>
      2 from .charDef import *
      3 from . import colors
----> 4 from . import utils
      5 from . import cursor
      6

c:\program files\python37\lib\site-packages\bullet\utils.py in <module>
      1 import os
      2 import sys
----> 3 import tty, termios
      4 import string
      5 from .charDef import *

c:\program files\python37\lib\tty.py in <module>
      3 # Author: Steen Lumholt.
      4
----> 5 from termios import *
      6
      7 __all__ = ["setraw", "setcbreak"]

ModuleNotFoundError: No module named 'termios'
EvilGrinUK commented 5 years ago

I believe equivalent functionality is provided by the msvcrt module on windows.

https://docs.python.org/3.7/library/msvcrt.html#console-i-o

bchao1 commented 5 years ago

Sorry for the issue.... As for now, this package works only on linux (I had the "platform" badge specified in the project readme). I will try making this package available on Windows when I have time.

bchao1 commented 5 years ago

Just tried out the msvcrt module and tested its getch() function. Seems like the getchar() function in utils.py needs to be rewritten for bullet to run on Windows. For example, the arrow keys on Windows are 224 + X, not a 3-key-combo as in Unix systems.

tdh8316 commented 5 years ago

Also, Windows CMD does not seem to apply colors with "\u001b[31m". I think This library will be helpful to print color!

williamfzc commented 5 years ago

Maybe Docker is an easier way to solve this problem? https://github.com/Mckinsey666/bullet/pull/28

tomkc commented 4 years ago

Maybe Docker is an easier way to solve this problem?

28

And why's that?

chinkung commented 4 years ago

Do we have any workaround or alternative interactive prompt module that works on all platform ?

Coder4360 commented 3 years ago

How about Msvcrt (all the Termios stuff) and os.system("cls") (allows support for ansi escape codes)

EverStarck commented 2 years ago

Any update of this?

tomkc commented 2 years ago

Any update of this?

This projects is no longer being maintained.

Likqez commented 4 months ago

Update: I published bullet including win support under: winBullet. Feel free to use it.