Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38507 > unrolled thread
| Started by | Vlasov Vitaly <vnigtha@gmail.com> |
|---|---|
| First post | 2013-02-09 03:23 -0800 |
| Last post | 2013-02-10 14:06 -0800 |
| Articles | 8 — 4 participants |
Back to article view | Back to comp.lang.python
Python3 curses behavior Vlasov Vitaly <vnigtha@gmail.com> - 2013-02-09 03:23 -0800
Re: Python3 curses behavior Chris Angelico <rosuav@gmail.com> - 2013-02-09 22:28 +1100
Re: Python3 curses behavior Vlasov Vitaly <vnigtha@gmail.com> - 2013-02-09 04:38 -0800
Re: Python3 curses behavior Vlasov Vitaly <vnigtha@gmail.com> - 2013-02-09 04:38 -0800
Re: Python3 curses behavior Terry Reedy <tjreedy@udel.edu> - 2013-02-09 14:22 -0500
Re: Python3 curses behavior Vlasov Vitaly <vnigtha@gmail.com> - 2013-02-10 14:06 -0800
Re: Python3 curses behavior Dan Stromberg <drsalists@gmail.com> - 2013-02-11 15:53 -0800
Re: Python3 curses behavior Vlasov Vitaly <vnigtha@gmail.com> - 2013-02-10 14:06 -0800
| From | Vlasov Vitaly <vnigtha@gmail.com> |
|---|---|
| Date | 2013-02-09 03:23 -0800 |
| Subject | Python3 curses behavior |
| Message-ID | <3adc871c-9a35-42ea-9687-52413d72a918@googlegroups.com> |
Hello. I found strange behavior of curses module, that i can't understand. I initialize screen with curses.initscr(), then i create subwin of screen with screen.subwin(my_subwin_sizes). After that i fill subwin with my_char in for-loop. On last char in last line subwin.addch() raises exception. This is my problem. Why? How to fix it? (If i will ignore exception, then last char will be displayed) Here simple example: http://pastebin.com/SjyMsHZB Thank You!
[toc] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-02-09 22:28 +1100 |
| Message-ID | <mailman.1541.1360409341.2939.python-list@python.org> |
| In reply to | #38507 |
On Sat, Feb 9, 2013 at 10:23 PM, Vlasov Vitaly <vnigtha@gmail.com> wrote: > Hello. > > I found strange behavior of curses module, that i can't understand. I initialize screen with curses.initscr(), then i create subwin of screen with screen.subwin(my_subwin_sizes). After that i fill subwin with my_char in for-loop. On last char in last line subwin.addch() raises exception. > > This is my problem. Why? How to fix it? > > (If i will ignore exception, then last char will be displayed) > > Here simple example: > http://pastebin.com/SjyMsHZB What exception is being raised? That's kinda the most important part here :) ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Vlasov Vitaly <vnigtha@gmail.com> |
|---|---|
| Date | 2013-02-09 04:38 -0800 |
| Message-ID | <6c2e8a19-2495-4d71-b7b8-c2d45cffe003@googlegroups.com> |
| In reply to | #38510 |
суббота, 9 февраля 2013 г., 15:28:51 UTC+4 пользователь Chris Angelico написал: > On Sat, Feb 9, 2013 at 10:23 PM, Vlasov Vitaly <vnigtha@gmail.com> wrote: > > > Hello. > > > > > > I found strange behavior of curses module, that i can't understand. I initialize screen with curses.initscr(), then i create subwin of screen with screen.subwin(my_subwin_sizes). After that i fill subwin with my_char in for-loop. On last char in last line subwin.addch() raises exception. > > > > > > This is my problem. Why? How to fix it? > > > > > > (If i will ignore exception, then last char will be displayed) > > > > > > Here simple example: > > > http://pastebin.com/SjyMsHZB > > > > What exception is being raised? That's kinda the most important part here :) > > > > ChrisA curses.error <-- all curses-related exception Exception text: curses.error: 'addch() returned ERR'
[toc] | [prev] | [next] | [standalone]
| From | Vlasov Vitaly <vnigtha@gmail.com> |
|---|---|
| Date | 2013-02-09 04:38 -0800 |
| Message-ID | <mailman.1543.1360413504.2939.python-list@python.org> |
| In reply to | #38510 |
суббота, 9 февраля 2013 г., 15:28:51 UTC+4 пользователь Chris Angelico написал: > On Sat, Feb 9, 2013 at 10:23 PM, Vlasov Vitaly <vnigtha@gmail.com> wrote: > > > Hello. > > > > > > I found strange behavior of curses module, that i can't understand. I initialize screen with curses.initscr(), then i create subwin of screen with screen.subwin(my_subwin_sizes). After that i fill subwin with my_char in for-loop. On last char in last line subwin.addch() raises exception. > > > > > > This is my problem. Why? How to fix it? > > > > > > (If i will ignore exception, then last char will be displayed) > > > > > > Here simple example: > > > http://pastebin.com/SjyMsHZB > > > > What exception is being raised? That's kinda the most important part here :) > > > > ChrisA curses.error <-- all curses-related exception Exception text: curses.error: 'addch() returned ERR'
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2013-02-09 14:22 -0500 |
| Message-ID | <mailman.1560.1360437812.2939.python-list@python.org> |
| In reply to | #38507 |
On 2/9/2013 6:23 AM, Vlasov Vitaly wrote: > Hello. > > I found strange behavior of curses module, that i can't understand. I > initialize screen with curses.initscr(), then i create subwin of > screen with screen.subwin(my_subwin_sizes). After that i fill subwin > with my_char in for-loop. On last char in last line subwin.addch() > raises exception. I have never used curses but I have used text screens. I suspect that addch moves the cursor to the position beyond where the character is added, but there is no such position. I remember having problems writing to the last char of a 24x80 screen without getting either a scroll or beep if scrolling was disabled. > This is my problem. Why? How to fix it? Perhaps this will help: window.leaveok(yes) If yes is 1, cursor is left where it is on update, instead of being at “cursor position.” This reduces cursor movement where possible. If possible the cursor will be made invisible. > (If i will ignore exception, then last char will be displayed) Otherwise, just catch the exception, as you already discovered. > Here simple example: http://pastebin.com/SjyMsHZB -- Terry Jan Reedy
[toc] | [prev] | [next] | [standalone]
| From | Vlasov Vitaly <vnigtha@gmail.com> |
|---|---|
| Date | 2013-02-10 14:06 -0800 |
| Message-ID | <56516403-5a1a-4b3e-9b99-8a687535a09a@googlegroups.com> |
| In reply to | #38536 |
суббота, 9 февраля 2013 г., 23:22:47 UTC+4 пользователь Terry Reedy написал: > On 2/9/2013 6:23 AM, Vlasov Vitaly wrote: > > > Hello. > > > > > > I found strange behavior of curses module, that i can't understand. I > > > initialize screen with curses.initscr(), then i create subwin of > > > screen with screen.subwin(my_subwin_sizes). After that i fill subwin > > > with my_char in for-loop. On last char in last line subwin.addch() > > > raises exception. > > > > I have never used curses but I have used text screens. I suspect that > > addch moves the cursor to the position beyond where the character is > > added, but there is no such position. I remember having problems writing > > to the last char of a 24x80 screen without getting either a scroll or > > beep if scrolling was disabled. > > > > > This is my problem. Why? How to fix it? > > > > Perhaps this will help: > > window.leaveok(yes) > > If yes is 1, cursor is left where it is on update, instead of being at > > “cursor position.” This reduces cursor movement where possible. If > > possible the cursor will be made invisible. > > > > > (If i will ignore exception, then last char will be displayed) > > > > Otherwise, just catch the exception, as you already discovered. > > > > > Here simple example: http://pastebin.com/SjyMsHZB > > > > -- > > Terry Jan Reedy Thank you. I tried everything in my test script. win.leaveok() - no effect curses.cur_vis() - no effect win.scrollok() - start newline and place cursor on it It's only one last option: on last line last char try/except with pass.
[toc] | [prev] | [next] | [standalone]
| From | Dan Stromberg <drsalists@gmail.com> |
|---|---|
| Date | 2013-02-11 15:53 -0800 |
| Message-ID | <mailman.1673.1360627136.2939.python-list@python.org> |
| In reply to | #38607 |
[Multipart message — attachments visible in raw view] — view raw
Sent from my android phone. On Feb 10, 2013 2:09 PM, "Vlasov Vitaly" <vnigtha@gmail.com> wrote: > > суббота, 9 февраля 2013 г., 23:22:47 UTC+4 пользователь Terry Reedy написал: > > On 2/9/2013 6:23 AM, Vlasov Vitaly wrote: > > > -- > > > > Terry Jan Reedy > > Thank you. > > I tried everything in my test script. > win.leaveok() - no effect > curses.cur_vis() - no effect > win.scrollok() - start newline and place cursor on it > > It's only one last option: > on last line last char try/except with pass. I doubt this is a Python 2 or Python 3 problem; historically some terminal types curses supports could not fill the lower right-most character cell without causing an undesired scroll of the screen by one line. So portable curses programs avoid filling that spot with anything.
[toc] | [prev] | [next] | [standalone]
| From | Vlasov Vitaly <vnigtha@gmail.com> |
|---|---|
| Date | 2013-02-10 14:06 -0800 |
| Message-ID | <mailman.1605.1360533970.2939.python-list@python.org> |
| In reply to | #38536 |
суббота, 9 февраля 2013 г., 23:22:47 UTC+4 пользователь Terry Reedy написал: > On 2/9/2013 6:23 AM, Vlasov Vitaly wrote: > > > Hello. > > > > > > I found strange behavior of curses module, that i can't understand. I > > > initialize screen with curses.initscr(), then i create subwin of > > > screen with screen.subwin(my_subwin_sizes). After that i fill subwin > > > with my_char in for-loop. On last char in last line subwin.addch() > > > raises exception. > > > > I have never used curses but I have used text screens. I suspect that > > addch moves the cursor to the position beyond where the character is > > added, but there is no such position. I remember having problems writing > > to the last char of a 24x80 screen without getting either a scroll or > > beep if scrolling was disabled. > > > > > This is my problem. Why? How to fix it? > > > > Perhaps this will help: > > window.leaveok(yes) > > If yes is 1, cursor is left where it is on update, instead of being at > > “cursor position.” This reduces cursor movement where possible. If > > possible the cursor will be made invisible. > > > > > (If i will ignore exception, then last char will be displayed) > > > > Otherwise, just catch the exception, as you already discovered. > > > > > Here simple example: http://pastebin.com/SjyMsHZB > > > > -- > > Terry Jan Reedy Thank you. I tried everything in my test script. win.leaveok() - no effect curses.cur_vis() - no effect win.scrollok() - start newline and place cursor on it It's only one last option: on last line last char try/except with pass.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web