Solved: Re: Missing python curses functions?
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
OK, Using inch() I've written the following function:
""" 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
And it can be used like:
scr = curses.initscr()
# uncomment next line to test
atts = attr_get(scr)
if atts & cur.A_UNDERLINE:
scr.addstr("Underline is on")
scr.addstr("Underline is off")
Just in case its useful to anyone else...
Author of the Learn to Program web site
Follow my photo-blog on Flickr at: