Results 1 to 4 of 4

Thread: Python: set multiple 'style' attributes in curses

  1. #1
    Join Date
    Jul 2011
    Location
    /Europe/Netherlands
    Beans
    378
    Distro
    Kubuntu 22.04 Jammy Jellyfish

    Python: set multiple 'style' attributes in curses

    How to apply more than one attribute to a printed string in the python curses library? So for example to apply both a curses.color_pair(n) and curses.A_BOLD or curses.A_REVERSE to a given string.

    One attribute can be applied like this example
    Code:
    window.addstr(y,x,text,curses.A_REVERSE)
    to reverse fore and background color.

    But it's not clear to me from the documentation docs.python.org/library/curses.html how to combine two or more attributes and apply them to an addstr command. I've tried to just add it as an extra argument but that's not accepted.

  2. #2
    Join Date
    Jul 2011
    Location
    /Europe/Netherlands
    Beans
    378
    Distro
    Kubuntu 22.04 Jammy Jellyfish

    Re: Python: set multiple 'style' attributes in curses

    *bump*

  3. #3
    Join Date
    Aug 2010
    Location
    Lancs, United Kingdom
    Beans
    1,588
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: Python: set multiple 'style' attributes in curses

    I'd expect it to be similar to C where you use bitwise-or on the flags. So:
    Code:
    window.addstr(y,x,text,curses.A_REVERSE | curses.A_BOLD)
    I haven't tried it though.

  4. #4
    Join Date
    Jul 2011
    Location
    /Europe/Netherlands
    Beans
    378
    Distro
    Kubuntu 22.04 Jammy Jellyfish

    Re: Python: set multiple 'style' attributes in curses

    Wow, that was fast And it works, so thanks.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •