Python Forum

Full Version: How to make curses.border() use A_BOLD atttribute?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
For a window in a curses screen for which you want a box around the window border, one uses window.border() to populate the border.

However, there is no attribute argument available in the window.border() call, nor in the similar window.box() call.

I tried setting the border characters individually using window.chgat(y, x, num, curses.A_BOLD) but that changes the graphic used for the box characters to various bold letter characters instead of VLINE, HLINE, ULCORNER, etc.

Code fragment used to set the A_BOLD attribute only in the box characters follows.

boxmaxy, boxmaxx = winbox.getmaxyx()
winbox.border(0, 0, 0, 0, 0, 0, 0, 0)                 
winbox.chgat(0, 0, -1, curses.A_BOLD)                   
winbox.chgat(boxmaxy - 1, 0, -1, curses.A_BOLD)    
for _y in range(1, boxmaxy):                            
    winbox.chgat(_y, 0, 1, curses.A_BOLD)               
    winbox.chgat(_y, boxmaxx - 1, 1, curses.A_BOLD)
Box characters look like this on screen after trying to set A_BOLD. The characters are BOLD, but they are not the right VLINE, HLINE, etc. characters.

Output:
lqqqqqqqqqqqqqqqqqqqk x x x x x x mqqqqqqqqqqqqqqqqqqqj
Is there any way to accomplish setting a bold box border?

Environment is Win10-64, Python 3.8.5, console is a CMD.EXE window.

Also tried in a WIn10 Terminal window (Version: 1.5.10271.0) with identical results.

Peter

[Edit] Never mind, I figured it out. For the record, this code will bold the border but not the text inside of it:

winbox.attron(curses.A_BOLD)
winbox.border(0, 0, 0, 0, 0, 0, 0, 0)
winbox.attron(curses.A_NORMAL)