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

Implement Windows Driver #14

Closed
kilacoda-old opened this issue Jun 20, 2021 · 29 comments
Closed

Implement Windows Driver #14

kilacoda-old opened this issue Jun 20, 2021 · 29 comments
Assignees
Labels

Comments

@kilacoda-old
Copy link

Trying to run the textual.app example on Windows 10 with Python 3.9.5:

python -m textual.app
Traceback (most recent call last):
 File "C:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
   return _run_code(code, main_globals, None,
 File "C:\Program Files\Python39\lib\runpy.py", line 87, in _run_code
   exec(code, run_globals)
 File "C:\CodeProjects\Python\Manim\manimvenv\lib\site-packages\textual\app.py", line 19, in <module>
   from .driver import Driver
 File "C:\CodeProjects\Python\Manim\manimvenv\lib\site-packages\textual\driver.py", line 8, in <module>
   import curses
 File "C:\Program Files\Python39\lib\curses\__init__.py", line 13, in <module>
   from _curses import *
ModuleNotFoundError: No module named '_curses'
@willmcgugan
Copy link
Collaborator

OSX and Linux only for now I'm afraid. Thee will be a Windows version at some point.

@kilacoda-old
Copy link
Author

I see. Might be a good idea to put that in the README for now then.

@yihong0618
Copy link

Trying to run the textual.app example on Windows 10 with Python 3.9.5:

python -m textual.app
Traceback (most recent call last):
 File "C:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
   return _run_code(code, main_globals, None,
 File "C:\Program Files\Python39\lib\runpy.py", line 87, in _run_code
   exec(code, run_globals)
 File "C:\CodeProjects\Python\Manim\manimvenv\lib\site-packages\textual\app.py", line 19, in <module>
   from .driver import Driver
 File "C:\CodeProjects\Python\Manim\manimvenv\lib\site-packages\textual\driver.py", line 8, in <module>
   import curses
 File "C:\Program Files\Python39\lib\curses\__init__.py", line 13, in <module>
   from _curses import *
ModuleNotFoundError: No module named '_curses'

You can try install this https://github.com/zephyrproject-rtos/windows-curses
But a little buggy

@kilacoda-old
Copy link
Author

Thanks, but it still doesn't work:

python -m textual.app
Traceback (most recent call last):
  File "C:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\CodeProjects\Python\Manim\manimvenv\lib\site-packages\textual\app.py", line 20, in <module>
    from ._linux_driver import LinuxDriver
  File "C:\CodeProjects\Python\Manim\manimvenv\lib\site-packages\textual\_linux_driver.py", line 10, in <module>
    import termios
ModuleNotFoundError: No module named 'termios'

Looks like Textual is hardcoded to use some Unix only modules atm: https://docs.python.org/3/library/termios.html

@willmcgugan
Copy link
Collaborator

It is, yes. But at some point I will implement a Windows driver.

I’ll keep this ticket open to track that.

@willmcgugan willmcgugan changed the title [Windows] ModuleNotFoundError: No module named '_curses' No Windows driver Jun 21, 2021
@lllama
Copy link
Contributor

lllama commented Jul 4, 2021

I've just had a look at the code and I see that there are no longer any references to curses. Will curses be making a reappearance? (Crossing my fingers that it won't, or at least won't be a core dependency as it never seems to play well on Windows.)

@willmcgugan
Copy link
Collaborator

Nope, no more curses.

@lskbr
Copy link

lskbr commented Jul 9, 2021

I have some routines for Windows here:
https://github.com/lskbr/colorconsole/blob/master/colorconsole/win.py

@willmcgugan willmcgugan added this to To do in Kanban Aug 17, 2021
@willmcgugan willmcgugan changed the title No Windows driver Implement Windows Driver Aug 17, 2021
@udupa-varun
Copy link

For anyone interested, the repo examples seem to work pretty well on WSL2 (I'm using Ubuntu 20.04). I haven't explored any further.

I am seeing the "unclosed event loop" error when I run easing.py, but that is already being tracked in #127 and is probably unrelated to WSL.

@seajhawk
Copy link

I heard Will on PythonBytes talking about getting it running on Windows and decided to give textual on WSL2 a try as well.

On Windows 11 and WSL2, I didn't hit any problems with animation.py, calculator.py or even easing.py.

It looks like WSL2 is a nice workaround for folks to try textual on Windows until it's fully supported.

Cheers!

@benjaminsweetnam247
Copy link

Wsl2 is a nice workaround for the mean time but for a work perspective I would love to see it running on git bash. I'm not sure how different that is to the normal windows console.

@mhils
Copy link
Contributor

mhils commented Jan 5, 2022

Please feel free to also take inspiration from @mitmproxy's urwid Windows port: urwid/urwid#448. It's not super beautiful, but at least we've shipped it and got few complaints. 😅

I don't recall if that was specific to urwid, but one particular annoyance we ran into was that Python's default event loop on Windows (ProactorEventLoop) does not support event_loop.add_reader. Our workaround is now to make use of tornado's AddThreadSelectorEventLoop1, which could probably be vendored if you don't need the rest of tornado.

Footnotes

  1. See https://bugs.python.org/issue37373,
    https://www.tornadoweb.org/en/stable/asyncio.html#tornado.platform.asyncio.AddThreadSelectorEventLoop,
    https://github.com/mitmproxy/mitmproxy/commit/31f089cb8dae49a8cdb5d77c03088b62fcd1f910

@EpicCodeWizard
Copy link

The linux libraries used are termios and tty (excluding curses, there's windows port of that which works well). I can help out making a windows port, using msvcrt and ctypes (module replacements for windows), but don't want to do it all alone. If anyone's interested to work on it, please reply.

@USLTD
Copy link

USLTD commented Jan 17, 2022

The linux libraries used are termios and tty (excluding curses, there's windows port of that which works well). I can help out making a windows port, using msvcrt and ctypes (module replacements for windows), but don't want to do it all alone. If anyone's interested to work on it, please reply.

Do you have any C/C++ knowledge? You will need it and also knowledge of Win APIs

@EpicCodeWizard
Copy link

The linux libraries used are termios and tty (excluding curses, there's windows port of that which works well). I can help out making a windows port, using msvcrt and ctypes (module replacements for windows), but don't want to do it all alone. If anyone's interested to work on it, please reply.

Do you have any C/C++ knowledge? You will need it and also knowledge of Win APIs

Yes, I have some knowledge of them. I will start work on a windows port soon, anyone here can reply to help me out.
@willmcgugan Have you started work on a windows port already?

@willmcgugan
Copy link
Collaborator

Thanks @mhils The Urwid code was very helpful in understanding reading input in Windows!

@EpicCodeWizard
Copy link

EpicCodeWizard commented Jan 20, 2022

I have done a lot of research on python CUI/TUI libraries and realized that pywin32, ctypes, and msvcrt are windows modules that can help to receive input. I will keep researching into other solutions, but I would recommend making one function, at the top of the code, like:

import platform
if platform.system() == "Windows":
	def readkey():
		# the code
else:
	def readkey():
		# code

@sajjadhossanshimanto
Copy link

The only dam on the way to becoming famous is this windows support

@tusharsadhwani
Copy link
Contributor

Will announced on twitter that his windows solution is partially ready. Just a bit more patience :)

https://twitter.com/willmcgugan/status/1484176989145554953?t=W4A0a-Oiwb_QZY5JX_TnfQ&s=19

@thedemons
Copy link

thedemons commented Jan 23, 2022

Will announced on twitter that his windows solution is partially ready. Just a bit more patience :)

https://twitter.com/willmcgugan/status/1484176989145554953?t=W4A0a-Oiwb_QZY5JX_TnfQ&s=19

This is awesome, i wanna try it as soon as possible

@EpicCodeWizard
Copy link

Will announced on twitter that his windows solution is partially ready. Just a bit more patience :)
https://twitter.com/willmcgugan/status/1484176989145554953?t=W4A0a-Oiwb_QZY5JX_TnfQ&s=19

This is awesome, i wanna try it as soon as possible

Same, I really want to try it out :)!

@thedemons
Copy link

Will announced on twitter that his windows solution is partially ready. Just a bit more patience :)
https://twitter.com/willmcgugan/status/1484176989145554953?t=W4A0a-Oiwb_QZY5JX_TnfQ&s=19

This is awesome, i wanna try it as soon as possible

Same, I really want to try it out :)!

In case you didn't know (just like me).
Will has already created the windows branch here
It is awesome, but it didn't work in vscode terminal for me. Both windows terminal and command prompt work fine.

@EpicCodeWizard
Copy link

EpicCodeWizard commented Jan 26, 2022

In case you didn't know (just like me). Will has already created the windows branch here It is awesome, but it didn't work in vscode terminal for me. Both windows terminal and command prompt work fine.

As a side note, in no way do I mean to say this package is bad — it is an awesome package, and these are just some test results I've found. I have tested on all terminals on windows, which I have. On all terminals, a weird message is printed after every press:
=2s
VS Code and Atom built-in terminals don't have much support (Atom is worse than VS Code). Windows terminal doesn't support symbols, so add a way to disable them:
symbol glitches
Powershell and Cygwin terminals both work fine.

EDIT: On windows, animations work fine, but on MacOS/Linux, a special character must be printed, code lines. Once I removed the code in the code lines, the problem was fixed. I hope a non-breaking windows port is made soon :)!

@thedemons
Copy link

In case you didn't know (just like me). Will has already created the windows branch here It is awesome, but it didn't work in vscode terminal for me. Both windows terminal and command prompt work fine.

As a side note, in no way do I mean to say this package is bad — it is an awesome package, and these are just some test results I've found. I have tested on all terminals on windows, which I have. On all terminals, a weird message is printed after every press: =2s VS Code and Atom built-in terminals don't have much support (Atom is worse than VS Code). Windows terminal doesn't support symbols, so add a way to disable them:
Powershell and Cygwin terminals both work fine.

Windows terminal (cmd and power shell) works very well for me.
It's usable in Command Prompt but the icons and color are off. It's a disaster in vscode terminal tho, font, color, icons aren't working, neither click, hover nor scrolling works.

I hope there will be a stable version for windows soon.

windows terminal
vscode terminal
command prompt

@EpicCodeWizard
Copy link

Hey everyone! I've created an improved windows driver for textual. Link to the PR!

@thedemons
Copy link

Hey everyone! I've created an improved windows driver for textual. Link to the PR!

Great work! I'll definitely check it out

@ncwhale
Copy link

ncwhale commented Feb 13, 2022

Just FYI: This library works in Windows Terminal just fine!

@tusharsadhwani
Copy link
Contributor

@ncwhale yeah, windows driver implementation has already been done. This issue should probably be closed as of now, unless there's more improvements to be made.

@github-actions
Copy link

Did I solve your problem?

Consider sponsoring my work on Textual with a monthly donation.

Or buy me a coffee to say thanks.

Will McGugan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests