diff options
| author | Andrew M. Kuchling <amk@amk.ca> | 2004-10-19 19:21:20 +0000 |
|---|---|---|
| committer | Andrew M. Kuchling <amk@amk.ca> | 2004-10-19 19:21:20 +0000 |
| commit | 0434edcb3b6739688f5520efce7ef9efd5c51da9 (patch) | |
| tree | 46bb0d15cde1df65a8b1f6b393f60e3a6f8b7f0f /Lib/curses | |
| parent | a562168f4c7ab21fcfaa2fc3af4de2a1c524b614 (diff) | |
| download | cpython-0434edcb3b6739688f5520efce7ef9efd5c51da9.tar.gz | |
Make magic coordinates more readable
Diffstat (limited to 'Lib/curses')
| -rw-r--r-- | Lib/curses/textpad.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/curses/textpad.py b/Lib/curses/textpad.py index bfc270addb..cd4813bdfe 100644 --- a/Lib/curses/textpad.py +++ b/Lib/curses/textpad.py @@ -3,7 +3,9 @@ import curses, ascii def rectangle(win, uly, ulx, lry, lrx): - "Draw a rectangle." + """Draw a rectangle with corners at the provided upper-left + and lower-right coordinates. + """ win.vline(uly+1, ulx, curses.ACS_VLINE, lry - uly - 1) win.hline(uly, ulx+1, curses.ACS_HLINE, lrx - ulx - 1) win.hline(lry, ulx+1, curses.ACS_HLINE, lrx - ulx - 1) @@ -157,8 +159,10 @@ class Textbox: if __name__ == '__main__': def test_editbox(stdscr): - win = curses.newwin(4, 9, 15, 20) - rectangle(stdscr, 14, 19, 19, 29) + ncols, nlines = 9, 4 + uly, ulx = 15, 20 + win = curses.newwin(nlines, ncols, uly, ulx) + rectangle(stdscr, uly-1, ulx-1, uly + nlines, ulx + ncols) stdscr.refresh() return Textbox(win).edit() |
