Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
colouring strings
#21
(Sep-22-2019, 09:07 AM)newbieAuggie2019 Wrote: I tried blessed and blessings (data further down). The author of blessings (last release: Jun‎ ‎21‎, ‎2018) is also the co-author of blessed (last release: Jun‎ ‎20‎, ‎2018). Blessed provides a demo program, written in some Python 2, that I managed to adapt to Python 3, but when I ran it, its output was with no formatting and with the following warning:

Error:
C:\Users\User1\AppData\Local\Programs\Python\Python37\lib\site-packages\blessed\terminal.py:32: UserWarning: One or more of the modules: 'termios', 'fcntl', and 'tty' are not found on your platform 'win32'. The following methods of Terminal are dummy/no-op unless a deriving class overrides them: setraw, cbreak, kbhit, height, width warnings.warn(_MSG_NOSUPPORT)

Hello, author of blessed here. We just merged windows support this past week, into release 1.16, so if you're still willing, please give it another try. You can do make terminal applications on windows if you are still interested. Sorry for the fork/confusion of blessings vs. blessed, I just had to make the best of having difficulty getting my changes, like keyboard support, accepted upstream into blessings, so the fork "blessed" has to continue.
Reply
#22
(Oct-22-2019, 02:28 PM)jquast Wrote:
(Sep-22-2019, 09:07 AM)newbieAuggie2019 Wrote: I tried blessed and blessings (data further down). The author of blessings (last release: Jun‎ ‎21‎, ‎2018) is also the co-author of blessed (last release: Jun‎ ‎20‎, ‎2018). Blessed provides a demo program, written in some Python 2, that I managed to adapt to Python 3, but when I ran it, its output was with no formatting and with the following warning:

Error:
C:\Users\User1\AppData\Local\Programs\Python\Python37\lib\site-packages\blessed\terminal.py:32: UserWarning: One or more of the modules: 'termios', 'fcntl', and 'tty' are not found on your platform 'win32'. The following methods of Terminal are dummy/no-op unless a deriving class overrides them: setraw, cbreak, kbhit, height, width warnings.warn(_MSG_NOSUPPORT)

Hello, author of blessed here. We just merged windows support this past week, into release 1.16, so if you're still willing, please give it another try. You can do make terminal applications on windows if you are still interested. Sorry for the fork/confusion of blessings vs. blessed, I just had to make the best of having difficulty getting my changes, like keyboard support, accepted upstream into blessings, so the fork "blessed" has to continue.

Thanks for taking the time to contribute to my thread and to keep improving blessed.

blessed 1.15.0
https://pypi.org/project/blessed/
Last release: Jun‎ ‎20‎, ‎2018.‎

has changed to:

blessed 1.16.0
https://pypi.org/project/blessed/
Last released: Oct 18, 2019.

and still has issues (no formatting at all and the error message of AttributeError: 'NoneType' object has no attribute 'fileno'
on my Python 3.7.4 Shell and the error message of C:\Users\User1\AppData\Local\Programs\Python\Python37\lib\site-packages\blessed\terminal.py:222: UserWarning: Failed to setupterm(kind='cygwin'): Could not find terminal cygwin
.format(self._kind, err)
).

All the best,



AFTER POSTING HERE THE SUPPOSED CO-AUTHOR OF BLESSED, I TOOK THE TIME TO TEST THE VERSION I THOUGHT HE WAS REFERRING TO:

blessed 1.16.0
https://pypi.org/project/blessed/
Last released: Oct 18, 2019.

[Image: blessed-1-16-0-checked-on-Oct-22-2019.png]

BUT AFTER THAT, WHILE I WAS POSTING HERE TO SHARE MY CONCLUSIONS, I CHECKED THE LINK AND SAW THAT IT WAS AGAIN CHANGED:

blessed 1.16.1
https://pypi.org/project/blessed/
Last released: 20 minutes ago.

[Image: blessed-1-16-1-checked-on-Oct-22-2019-20...-later.png]

It would have been nicer to update the package, and THEN to share it on sites where it has been mentioned, and not the other way around ...



Well, after updating AGAIN the blessed package, I used this program to check its features:
# you_are_blessed_01.py
#

from blessed import Terminal

t = Terminal()

print(t.bold('Hi there!'))
print(t.bold_red_on_bright_green('It hurts my eyes!'))

with t.location(0, t.height - 1):
    print(t.center(t.blink('press any key to continue.')))

with t.cbreak():
    inp = t.inkey()
print('You pressed ' + repr(inp))

print('I am ' + t.bold('bold') + '!')
print('All your ' + t.red('base') + t.underline(' belongs to us now!'))
print('This should be ' + t.bold(t.red('bold')) + ' and red text.')
producing this error on my Python 3.7.4 Shell:
Error:
Traceback (most recent call last): File "C:\Users\User1\AppData\Local\Programs\Python\Python37\you_are_blessed_01.py", line 25, in <module> t = Terminal() File "C:\Users\User1\AppData\Local\Programs\Python\Python37\lib\site-packages\blessed\terminal.py", line 176, in __init__ self._keyboard_fd = sys.__stdin__.fileno() AttributeError: 'NoneType' object has no attribute 'fileno'
and no formatting at all and a user warning on Cmder:

Output:
D:\new downloads 28102017\cmder λ you_are_blessed_01.py
Error:
C:\Users\User1\AppData\Local\Programs\Python\Python37\lib\site-packages\blessed\terminal.py:222: UserWarning: Failed to setupterm(kind='cygwin'): Could not find terminal cygwin .format(self._kind, err)) Hi there! It hurts my eyes! press any key to continue. You pressed 'b' I am bold! All your base belongs to us now! This should be bold and red text.
When I tried to run this other program:

# you_are_blessed_03.py
#
#

from blessed import Terminal

term = Terminal()
with term.location(0, term.height - 1):
    print('This is' + term.underline('underlined') + '!')
the same error and warning messages appeared and no formatting both on Python 3.7.4 Shell and Cmder.

All the best,
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply
#23
I don't know why your environment variable TERM is set to "cygwin", especially outside of cygwin, such as Cmdr.. change your system environment variable TERM to be "xterm", might help fix it. I would never recommend to use cygwin, it is legacy/not maintained, Windows subsystem for Linux should be used if that's what you're after. The 1.16.1 release was a minor fix made today, for python 2.7 locale issues on windows, which you can see in the release pages of github if you're interested, its a minor bugfix release that doesn't affect you... sorry if my volunteer work on FOSS troubles you so much!

Your message is very hard to read because of all the formatting, I feel you are angry about something, maybe I shouldn't have tried to help, I'm going to just wish you best of luck!
Reply
#24
(Oct-23-2019, 03:44 AM)jquast Wrote: I don't know why your environment variable TERM is set to "cygwin", especially outside of cygwin, such as Cmdr.. change your system environment variable TERM to be "xterm", might help fix it. I would never recommend to use cygwin, it is legacy/not maintained, Windows subsystem for Linux should be used if that's what you're after.
Thanks again for taking the time to answer!

As you can guess for the alias I chose, I'm a newbie to programming, and python is my first programming language, so I have no programming background, and the simplest things can be very difficult for me to achieve.

I had difficulties in installing and running packages, but fortunately with the help of some wonderful people on this site, I managed to do it, even when sometimes their technical explanations were hard for me to grasp.

I just managed to install blessed and run it. When I ran the version of blessed released on Jun 29, 2018, I got the output with no formatting and with the following warning:

Error:
C:\Users\User1\AppData\Local\Programs\Python\Python37\lib\site-packages\blessed\terminal.py:32: UserWarning: One or more of the modules: 'termios', 'fcntl', and 'tty' are not found on your platform 'win32'. The following methods of Terminal are dummy/no-op unless a deriving class overrides them: setraw, cbreak, kbhit, height, width warnings.warn(_MSG_NOSUPPORT)
When I ran the versions of blessed released on Oct 18, 2019, and on Oct 22, 2019, I got the output again with no formatting and with the following warning:

Error:
C:\Users\User1\AppData\Local\Programs\Python\Python37\lib\site-packages\blessed\terminal.py:222: UserWarning: Failed to setupterm(kind='cygwin'): Could not find terminal cygwin .format(self._kind, err)) Hi there! It hurts my eyes! press any key to continue. You pressed 'b' I am bold! All your base belongs to us now! This should be bold and red text.
So, with my lack of knowledge, I don't think I have made anything to set my environment variable TERM to "cygwin" nor I would know how to change my system environment variable TERM to be "xterm". I just installed the blessed package on three occasions and ran a couple of programs to see if it really does the formatting or not, providing the messages I received when I did it.

(Oct-23-2019, 03:44 AM)jquast Wrote: The 1.16.1 release was a minor fix made today, for python 2.7 locale issues on windows, which you can see in the release pages of github if you're interested, its a minor bugfix release that doesn't affect you... sorry if my volunteer work on FOSS troubles you so much!

[ ... ] I feel you are angry about something, maybe I shouldn't have tried to help, I'm going to just wish you best of luck!

As a newbie, I'm not really sure what a new version of a program does, nor what differs from a previous one, even after Metulburr clearly explained it to me here:

https://python-forum.io/Thread-How-shoul...0#pid94780

So after installing a second release, running a couple of programs and posting here my conclusions, I checked if the links were working and I saw that there was another release about two hours after you posted here saying that there was another release where some modifications were made to fix problems with Windows.

blessed 1.16.0
https://pypi.org/project/blessed/
Last released: Oct 18, 2019.

[Image: blessed-1-16-0-checked-on-Oct-22-2019.png]

blessed 1.16.1
https://pypi.org/project/blessed/
Last released: 20 minutes ago.

[Image: blessed-1-16-1-checked-on-Oct-22-2019-20...-later.png]

It would have been nicer to update the package, and THEN to share it on sites where it has been mentioned, saying maybe something like 'hey, guys, I just made some modifications to 'blessed' that I think solve the previous issues with Windows. Please, give it a try and give me some feedback', or something of the sort, and not the other way around ...

As the second release I had installed was still having problems, I thought that that third release of the blessed package was the fix for the second release, so I installed blessed once more and did the tests. I think it's understandable to expect from you to release a version and then ask people to test the version, and not the other way around (asking people to check a version, and then, less than 2 hours later, release another version). I just don't think it follows the basic rules of netiquette.

Please, don't think that I'm not grateful, because I AM. I just think for instance about Python, and all the people that have contributed generously to the language, modules and packages, but that doesn't change the feeling that you could have waited a couple of mere hours to update your package and then ask people to check it out.

[Image: blessed-timing-01.png]

(Oct-23-2019, 03:44 AM)jquast Wrote: Your message is very hard to read because of all the formatting [ ... ]

I'm not sure about what formatting you are speaking about.

If you are speaking about the formatting tags used on this site for code, errors, etc., I think those tags and formatting, make things look clearer. Maybe I would have added 'warning tags' to differentiate warning messages from error messages, but it has nothing to do with me. Actually, according to the rules on this site, you have to use the tags in your posts.

[Image: tags-etiquette.png]

https://python-forum.io/misc.php?action=help&hid=25

If you are otherwise, speaking about the formatting used on the programs to check blessed, it's based on the programs and formatting I took from the pypi.org site where blessed can be downloaded:

https://pypi.org/project/blessed/

(Sep-22-2019, 09:07 AM)newbieAuggie2019 Wrote: I tried blessed and blessings (data further down). The author of blessings (last release: Jun‎ ‎21‎, ‎2018) is also the co-author of blessed (last release: Jun‎ ‎20‎, ‎2018). Blessed provides a demo program, written in some Python 2, that I managed to adapt to Python 3, but when I ran it [ ... ]

(Oct-22-2019, 03:31 PM)newbieAuggie2019 Wrote: Well, after updating AGAIN the blessed package, I used this program to check its features:
# you_are_blessed_01.py
#

from blessed import Terminal

t = Terminal()

print(t.bold('Hi there!'))
print(t.bold_red_on_bright_green('It hurts my eyes!'))

with t.location(0, t.height - 1):
    print(t.center(t.blink('press any key to continue.')))

with t.cbreak():
    inp = t.inkey()
print('You pressed ' + repr(inp))

print('I am ' + t.bold('bold') + '!')
print('All your ' + t.red('base') + t.underline(' belongs to us now!'))
print('This should be ' + t.bold(t.red('bold')) + ' and red text.')

and as you can see here, it is almost identical:

https://pypi.org/project/blessed/

[Image: coding-with-blessed-01.png]

Even this little program:

(Oct-22-2019, 03:31 PM)newbieAuggie2019 Wrote: When I tried to run this other program:

# you_are_blessed_03.py
#
#

from blessed import Terminal

term = Terminal()
with term.location(0, term.height - 1):
    print('This is' + term.underline('underlined') + '!')

as you can see here:

https://pypi.org/project/blessed/

[Image: coding-with-blessed-02.png]

it has the same formatting.

I usually spent a lot of time to design a post, with images, colours, bold types and other features to make things clearer, and as I wish people would explain things to me, as I'm a bit thick.

It has just come to my mind, that maybe you are accessing this site through some kind of programmers' tools, and you are seeing lines of code, instead of seeing the actual site, which I think it would be easier to follow.

Anyway, thanks for your contributions to the python community, and I hope that my error and warning messages might help you to improve blessed.

All the best,
newbieAuggie2019

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to understand strings and lists of strings Konstantin23 2 699 Aug-06-2023, 11:42 AM
Last Post: deanhystad
  Splitting strings in list of strings jesse68 3 1,703 Mar-02-2022, 05:15 PM
Last Post: DeaD_EyE
  Finding multiple strings between the two same strings Slither 1 2,482 Jun-05-2019, 09:02 PM
Last Post: Yoriz
  lists, strings, and byte strings Skaperen 2 4,181 Mar-02-2018, 02:12 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020