Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple-term-menu not work on Windows #5

Open
jDan735 opened this issue Jun 11, 2020 · 18 comments
Open

simple-term-menu not work on Windows #5

jDan735 opened this issue Jun 11, 2020 · 18 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@jDan735
Copy link

jDan735 commented Jun 11, 2020

System

Parameter Info
OS Win7 SP1 x86
Python Python 3.8.3
Pip Pip 20.1.1

Steps to reproduce

  1. pip install simple-term-menu
  2. run this code:
from simple_term_menu import TerminalMenu

terminal_menu = TerminalMenu(["entry 1", "entry 2", "entry 3"])
terminal_menu.show()

Output

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "H:\github\simple-term-menu\simple_term_menu.py", line 7, in <module>
    import termios
ModuleNotFoundError: No module named 'termios'
@IngoMeyer441
Copy link
Owner

Thanks for trying simple-term-menu. Currently, only Linux and macos are supported. Windows needs completely different terminal handling code. That is also the reason why termios is not available on Windows (on Unix-like systems it is part of the Python standard library).

@IngoMeyer441
Copy link
Owner

Is using Cygwin maybe an option for you?

@jDan735
Copy link
Author

jDan735 commented Jun 15, 2020

Possible. simple-term-menu started in msys32, also this must work in wsl

@IngoMeyer441
Copy link
Owner

The next release will at least throw a more descriptive exception for non-supported platforms.

@buanzo
Copy link

buanzo commented Feb 15, 2021

Just to mention it works fine on wsl as @jDan735 indicated. Check this out (WSL2 Ubuntu LTS 18.04.5)

image

@tmkkcc
Copy link

tmkkcc commented Jun 16, 2021

Will this be fixed soon? Are there alternatives to this ?

@IngoMeyer441
Copy link
Owner

Windows terminals need completely different terminal handling code so quite a lot of work has to be done first. I think it would be best to split simple-term-menu in a platform dependent and a platform independent part so the right terminal backend code can be loaded if on Unix or Windows. However:

  • I don't know if a Windows terminal supports all features simple-term-menu uses in Unix environments.
  • I definitely need help here because I am not very familiar with Windows programming.

@tmkkcc Maybe bullet could be the right choice for you. There is a open PR for adding Windows support.

@IngoMeyer441 IngoMeyer441 added help wanted Extra attention is needed enhancement New feature or request labels Jun 22, 2021
@buanzo
Copy link

buanzo commented Jun 22, 2021 via email

@wnhrt
Copy link

wnhrt commented Aug 11, 2021

I have played around a bit in the last two days and got at least the basic basic functions in 'Windows Terminal' to work:
image
image

At first sight it looks like entry selection, colors, preview and search (just couldn't get <backspace> to work as expected) could work fine without too many changes.

I have close to no knowledge about Windows Terminal and CMD handling, but I figured following key points might be quiet challenging to implement:

and most likely some other things and edge cases, which I have not considered yet. Without external dependencies, the amount of code is likely to grow a lot. I have also used some shortcuts which could benefit from a proper implementation (e.g. use of sys.stdin/out, instat of a proper stream handle).

But perhaps I have overlooked some simpler solutions.

@IngoMeyer441
Copy link
Owner

@wnhrt This is great news! 👍 I really thought that handling a windows terminal would be much trickier. Could you share your code changes? I am very curious. 😊

@wnhrt
Copy link

wnhrt commented Aug 12, 2021

Sure thing 😃
wnhrt@9f65d65
(Your recent commit about multiselect slipped with in)

I was able to get backspace to work (used the wrong key code) and enable VT100 mode in CMD.exe.
image

Variable length unicode symbols and resize of the window still cause problems and I didn't test key combinations, like Alt+X or Ctrl+X.

I reused most of your code. Design wise it might be sensible to create Windows-specific functions, e.g. for _query_terminfo_database. Also _tty_in/out and similar unix specific naming could be confusing for future contributors.

@IngoMeyer441
Copy link
Owner

If it is possible to display Unicode characters, the Unicode box characters should also work. Didn't know that the legacy terminal supports Unicode characters.

@wnhrt
Copy link

wnhrt commented Aug 13, 2021

I guess it does not. It uses Windows-1252. But you are right, it luckily supports box characters :)

I made a pull request, which also includes a fix to use them.

@IngoMeyer441
Copy link
Owner

The wcwidth module could become an optional dependency for Windows (for example, by installing it with pip install simple-term-menu[wcwidth]). If it is not installed, simple-term-menu could fall back to the len function, so people (especially Unix users) are not forced to install any dependency.

@nitsuaustin11
Copy link

not sure if this helps. but i just installed the lynux terminal and it all works fine. couldnt run anything before.

just ran "wsl --install" in my terminal. i think as admin. and then restarted pc.

peterschmidt85 added a commit to dstackai/dstack that referenced this issue Oct 12, 2022
- Show a nice error message if the user is using a non-supported AWS region. #104 (bugfix)

Bugfix related to IngoMeyer441/simple-term-menu#5
@cornradio
Copy link

is there any thing like simple-term-menu work on windows?
i just need some basic funcion like short cut and choosing item!

@cornradio
Copy link

since there is not any progress about supporting windows, i made this if any one need ! dumb_menu

@Abeautifulsnow
Copy link

Abeautifulsnow commented Aug 28, 2023

python-inquirer is also a good choice(supports cross-platform and single/multiple selection, etc). Hope it will save your life. I use it in my project - pkgu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

8 participants