Maybe you should raise a bug (bugs.python.org) and flag that this function is missing.

It could be that it can be introduced by whoever is maintaining the existing code.

On 20/05/2020 08:31, Alan Gauld via Python-list wrote:
On 19/05/2020 20:53, Alan Gauld via Python-list wrote:

One of the functions discussed that does not appear to have
a Python equivalent is attr_get() which gets the current
attributes.
OK, Using inch() I've written the following function:


def attr_get(win):
     """ return current window attributes.
     If a character exists at the bottom right position it will be lost!
     """
     y,x = win.getmaxyx() # how many lines in the window?
     win.insch(y-1,0,' ') # insert a space at bottom left
     ch = win.inch(y-1,0) # now read the char (including attributes)
     win.delch(y-1,0)     # remove the char from window
     return ch

And it can be used like:

import curses
scr = curses.initscr()
# uncomment next line to test
# scr.attrset(curses.A_UNDERLINE)

atts = attr_get(scr)
if atts & cur.A_UNDERLINE:
     scr.addstr("Underline is on")
else:
     scr.addstr("Underline is off")

scr.refresh()
scr.getch()
curses.endwin()

Just in case its useful to anyone else...
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to