[Tutor] Printing Bold Text

Alan Gauld alan.gauld at yahoo.co.uk
Sat Feb 1 09:26:20 EST 2020


On 31/01/2020 18:30, Adam Slowley wrote:

I was bored so I built this demo of how to do
what you want using curses.

######### bold_input.py  #####

import curses

def getInput(win, prompt):
    cur.echo()   # turn echo on, just in case...

    win.addstr(prompt)
    win.refresh()
    win.attrset(cur.A_BOLD)
    value = win.getstr().decode('utf-8')
    win.attrset(cur.A_NORMAL)

    return value


def test_bold(scr):
    name = getInput(scr,"What is your name? ")
    scr.addstr(4,2,"Hello " + name)
    scr.refresh()
    scr.getkey()   # pause to view screen

if __name__ == "__main__":
    cur.wrapper(test_bold)

#################################

You can import the module and use getInput()
-  but you need to use curses for the rest of your app.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list