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

Error in Table style updation using box #125

Closed
SinghHrmn opened this issue Jun 26, 2020 · 8 comments
Closed

Error in Table style updation using box #125

SinghHrmn opened this issue Jun 26, 2020 · 8 comments
Labels
bug Something isn't working

Comments

@SinghHrmn
Copy link

I was using the box to edit the style to be ASCII using box=box.ASCII but even I updated box Table style didn't change.

Screenshot (54)

As you can see the table didn't change.

@willmcgugan
Copy link
Collaborator

I guess you're on Windows?

The box setting is ignored on Windows because cmd.exe doesn't render most unicode box characters. But that shouldn't apply to Jupyter, so I will change the logic there.

In the meantime, if you set legacy_windows=False on the Console constructor you should be able to change the box setting.

@willmcgugan willmcgugan added the bug Something isn't working label Jun 26, 2020
@willmcgugan
Copy link
Collaborator

Please give v2.3.1 a try.

@SinghHrmn
Copy link
Author

@willmcgugan Thanks it's working now. But I wanted to use that for windows legacy terminal but it wasn't working so I tried that on Jupyter. I want to use Table on legacy windows. Can you recommend the box style that will surely work on cmd? I guess box.ASCII can be an option but I'm open for other suggestions.

@willmcgugan
Copy link
Collaborator

Most of the unicode box characters don't render on windows legacy. Any of the heavy / double / rounded characters display as question marks. Rather than have a situation where a table looks good on OSX / Linux / Window Terminal but garbage on Windows legacy, I set the box parameter to box.SQUARE on Windows legacy.

But that does mean you can't select box.ASCII or one of the other box constants that would work on cmd.exe. So perhaps the solution would be to only substitute the box constants that are known not to work on Windows legacy.

@willmcgugan
Copy link
Collaborator

Did some more digging, and it turns out that it's not cmd.exe that doesn't support box characters, its the choice of font. The raster fonts are missing some box characters, but the truetype fonts look fine.

It's a bit of a dilemma. There is no way to detect the user's choice of font. I'll need to think about that one, but it does look like I can support a greater range of box characters on Windows in a future update.

@SinghHrmn
Copy link
Author

Actually I was testing that on github actions and clearly windows on GitHub Actions don't support unicode. My application is basically cross platform and I need to check if my build pass on both the system. But I don't want to drop the beautiful table on windows where users have terminal that support unicode. So I'm handling that with a try except block that, if I can write and I don't get UnicodeEncode error I can print the unicode table but if I can't I'll switch table to use box.ASCII which is supported by CI. Do you have any other better implementation ?

@willmcgugan
Copy link
Collaborator

Github Actions should support unicode output, but I think you will need to set the PYTHONIOENCODING environment variable to "utf-8".

As far as tests goes, you might want to set legacy_windows=False on the Console constructor, so the output is the same on all platforms.

I think perhaps the solution to box characters on windows is to set a different default for Windows, but allow that to be modified in the Table constructor.

@willmcgugan
Copy link
Collaborator

Version 3.0.0 has support for more box characters on legacy Windows. By default it will substitute any unsafe box characters, but you can override this with a new safe_box boolean.

Run the following to see how the box constants render:

python -m rich.box

Not sure if that helps your testing scenario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants