Coder Social home page Coder Social logo

Implement Windows Driver about textual HOT 29 CLOSED

textualize avatar textualize commented on May 18, 2024 4
Implement Windows Driver

from textual.

Comments (29)

willmcgugan avatar willmcgugan commented on May 18, 2024 28

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

I’ll keep this ticket open to track that.

from textual.

kilacoda-old avatar kilacoda-old commented on May 18, 2024 7

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

from textual.

willmcgugan avatar willmcgugan commented on May 18, 2024 6

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

from textual.

willmcgugan avatar willmcgugan commented on May 18, 2024 5

Nope, no more curses.

from textual.

tusharsadhwani avatar tusharsadhwani commented on May 18, 2024 3

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

from textual.

lskbr avatar lskbr commented on May 18, 2024 2

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

from textual.

seajhawk avatar seajhawk commented on May 18, 2024 2

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!

from textual.

willmcgugan avatar willmcgugan commented on May 18, 2024 2

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

from textual.

EpicCodeWizard avatar EpicCodeWizard commented on May 18, 2024 2

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

from textual.

kilacoda-old avatar kilacoda-old commented on May 18, 2024 1

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

from textual.

benjaminsweetnam247 avatar benjaminsweetnam247 commented on May 18, 2024 1

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.

from textual.

sajjadhossanshimanto avatar sajjadhossanshimanto commented on May 18, 2024 1

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

from textual.

ncwhale avatar ncwhale commented on May 18, 2024 1

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

from textual.

yihong0618 avatar yihong0618 commented on May 18, 2024

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

from textual.

lllama avatar lllama commented on May 18, 2024

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.)

from textual.

udupa-varun avatar udupa-varun commented on May 18, 2024

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.

from textual.

mhils avatar mhils commented on May 18, 2024

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

from textual.

EpicCodeWizard avatar EpicCodeWizard commented on May 18, 2024

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.

from textual.

USLTD avatar USLTD commented on May 18, 2024

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

from textual.

EpicCodeWizard avatar EpicCodeWizard commented on May 18, 2024

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?

from textual.

EpicCodeWizard avatar EpicCodeWizard commented on May 18, 2024

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

from textual.

thedemons avatar thedemons commented on May 18, 2024

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

from textual.

EpicCodeWizard avatar EpicCodeWizard commented on May 18, 2024

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 :)!

from textual.

thedemons avatar thedemons commented on May 18, 2024

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.

from textual.

EpicCodeWizard avatar EpicCodeWizard commented on May 18, 2024

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 :)!

from textual.

thedemons avatar thedemons commented on May 18, 2024

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

from textual.

thedemons avatar thedemons commented on May 18, 2024

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

Great work! I'll definitely check it out

from textual.

tusharsadhwani avatar tusharsadhwani commented on May 18, 2024

@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.

from textual.

github-actions avatar github-actions commented on May 18, 2024

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

from textual.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.