peterbrittain / asciimatics

A cross platform package to do curses-like operations, plus higher level APIs and widgets to create text UIs and ASCII art animations
Apache License 2.0
3.64k stars 238 forks source link

Screen background is 'gray', not the desired 'black' #282

Closed shirishph closed 3 years ago

shirishph commented 3 years ago

Describe the bug Unable to clear_buffer such that the background is all black

To Reproduce

def duty_cycle(screen):
    ev = -1
    while True:
        response = requests.post(MY_URL, data=None).json()

        screen.clear_buffer(Screen.COLOUR_RED, Screen.COLOUR_GREEN, Screen.COLOUR_BLACK)

        """
        screen.print_at('duty_cycle: ' + response['timestamp'], 2, 2)

        for point in response['env']:
            screen.print_at(point[2], point[0], point[1])
        """

        ev = screen.get_key()
        if ev == screen.KEY_ESCAPE or ev in (ord('Q'), ord('q')):
            return
        screen.refresh()
        sleep(500/1000)

Screen.wrapper(duty_cycle)

Expected behavior clear_buffer's last param is the background colour and is given as black. When rendered the screen has a background that appears to be gray

Screenshots --none--

System details (please complete the following information):

Additional context --none--

peterbrittain commented 3 years ago

Thanks. First just a quick note that you are using the wrong parameter for the 2nd parameter on clear_buffer. It should be an attribute, not a colour. But that won't be the issue here...

These should be completely standard colour settings, however some terminals take liberties with the ansi colour scheme. I'm guessing the MacOS terminal is in that list based on this trail: https://superuser.com/questions/100281/make-the-background-black-not-white-on-linux-mac-os-x-terminal

Are you using a profile that defines the background to be a gray rather than black?

shirishph commented 3 years ago

Thanks for your response. You are right. Mac is messing the colours. It works just fine on a Raspberry Pi 4b. For the record: I had some silly Pillow errors which eventually got solved by using this answer. Basically did this sudo apt-get install libjpeg-dev zlib1g-dev before doing pip3 install asciimatics

shirishph commented 3 years ago

image iTerm on Mac interprets ANSI colours different to expectations. To reset as preferred change these settings

peterbrittain commented 3 years ago

Thanks for digging into that. Glad it now works for you.

Given that you've taken the time to explain what's needed, we should update the troubleshooting docs.

shirishph commented 3 years ago

Would be happy to do that, if you tell me how the docs are updated and what process is followed

peterbrittain commented 3 years ago

Thanks. Docs are written in restructured text and built using sphinx. All happens automatically in the travis builds, but you can run those commands and then look at the files locally when you make changes.

We should add a new section with a title like "my application colours are wrong", where you can explain the generic problem and then how to fix it for iterm.

If you could check out the existing installation advice and tweak if neede for RPi, that would be good too.

peterbrittain commented 3 years ago

Oh and the key doc is here - https://github.com/peterbrittain/asciimatics/blob/master/doc/source/troubleshooting.rst