Results 1 to 4 of 4

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

  1. #1
    Join Date
    Jul 2011
    Location
    /Europe/Netherlands
    Beans
    384
    Distro
    Kubuntu 14.04 Trusty Tahr

    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.
    "I believe humans get a lot done, not because we're smart, but because we have thumbs so we can make coffee." --Flash Rosenberg
    formerly 'known' as Euroman

  2. #2
    Join Date
    Jul 2011
    Location
    /Europe/Netherlands
    Beans
    384
    Distro
    Kubuntu 14.04 Trusty Tahr

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

    *bump*
    "I believe humans get a lot done, not because we're smart, but because we have thumbs so we can make coffee." --Flash Rosenberg
    formerly 'known' as Euroman

  3. #3
    Join Date
    Aug 2010
    Location
    Lancs, United Kingdom
    Beans
    1,108
    Distro
    Xubuntu 14.04 Trusty Tahr

    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
    384
    Distro
    Kubuntu 14.04 Trusty Tahr

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

    Wow, that was fast And it works, so thanks.
    "I believe humans get a lot done, not because we're smart, but because we have thumbs so we can make coffee." --Flash Rosenberg
    formerly 'known' as Euroman

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
  •