473,320 Members | 2,027 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Curses sorely lacking an event loop?

Hello,

Is curses really lacking an event loop? Do I have to write my own? I
infer from the docs that this is the case. For example, I want the
screen to be updated with resize but I find myself waiting for getch()
if I want user input, and so the screen must remain ugly until the user
presses a key. What am I missing?

Also, does anyone have boilerplate for handling mouse events? getmouse()
returns an "ERR" of no particular description and also appears to
require a preceding getch() and hence does not seem to be wired at all
for clicks, although allusion to clicks is found in the descriptions for
mouseinterval() and mousemask().

Here is the error message for getmouse() in case anyone wants details:
"_curses.error: getmouse() returned ERR". This is much less informative
than one might hope.

Thanks in advance for any help.

James
Feb 27 '07 #1
4 2482
On Tue, 27 Feb 2007 12:27:17 GMT, James Stroud wrote:
>
Is curses really lacking an event loop? Do I have to write my own? I
infer from the docs that this is the case. For example, I want the
screen to be updated with resize but I find myself waiting for getch()
if I want user input, and so the screen must remain ugly until the user
presses a key. What am I missing?
I'm not a curses expert, but I can answer this part. When the screen
is resized, SIGWINCH is sent to the process. You can use the normal
signal handling apparatus to install a handler that updates the screen
when that signal arrives.
Mike

--
Michael Zawrotny
Institute of Molecular Biophysics
Florida State University | email: za******@sb.fsu.edu
Tallahassee, FL 32306-4380 | phone: (850) 644-0069
Feb 27 '07 #2
On Feb 27, 1:27 pm, James Stroud <jstr...@mbi.ucla.eduwrote:
Hello,

Is curses really lacking an event loop? Do I have to write my own? I
infer from the docs that this is the case. For example, I want the
screen to be updated with resize but I find myself waiting for getch()
if I want user input, and so the screen must remain ugly until the user
presses a key. What am I missing?

Also, does anyone have boilerplate for handling mouse events? getmouse()
returns an "ERR" of no particular description and also appears to
require a preceding getch() and hence does not seem to be wired at all
for clicks, although allusion to clicks is found in the descriptions for
mouseinterval() and mousemask().

Here is the error message for getmouse() in case anyone wants details:
"_curses.error: getmouse() returned ERR". This is much less informative
than one might hope.

Thanks in advance for any help.

James
Did you check Urwid? http://excess.org/urwid

Michele Simionato

Feb 27 '07 #3
Michael Zawrotny wrote:
On Tue, 27 Feb 2007 12:27:17 GMT, James Stroud wrote:
> Is curses really lacking an event loop? Do I have to write my own? I
infer from the docs that this is the case. For example, I want the
screen to be updated with resize but I find myself waiting for getch()
if I want user input, and so the screen must remain ugly until the user
presses a key. What am I missing?

I'm not a curses expert, but I can answer this part. When the screen
is resized, SIGWINCH is sent to the process. You can use the normal
signal handling apparatus to install a handler that updates the screen
when that signal arrives.
Mike
Thank you. This is good to know.

James
Feb 28 '07 #4
Michele Simionato wrote:
On Feb 27, 1:27 pm, James Stroud <jstr...@mbi.ucla.eduwrote:
>Hello,

Is curses really lacking an event loop? Do I have to write my own? I
infer from the docs that this is the case. For example, I want the
screen to be updated with resize but I find myself waiting for getch()
if I want user input, and so the screen must remain ugly until the user
presses a key. What am I missing?

Also, does anyone have boilerplate for handling mouse events? getmouse()
returns an "ERR" of no particular description and also appears to
require a preceding getch() and hence does not seem to be wired at all
for clicks, although allusion to clicks is found in the descriptions for
mouseinterval() and mousemask().

Here is the error message for getmouse() in case anyone wants details:
"_curses.error: getmouse() returned ERR". This is much less informative
than one might hope.

Thanks in advance for any help.

James

Did you check Urwid? http://excess.org/urwid

Michele Simionato
Perfect. Just what I was looking for.

Thank you.

James
Feb 28 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Pierluigi Fabbris | last post by:
I'm a python programmer since three month and I need that you help me. I want to use python in my web site and in particular I want to add to a ref in Html <a href=""> a event. The event is the...
0
by: Matthew Alton | last post by:
The appended program freaks python 2.2 & 2.3 completely out. To reproduce the wierdness: i) copy the source to a file called consarn.py ii) $ python consarn.py; iii) the program is now doing a...
0
by: Matt Garman | last post by:
I'd like to write a class or module in python that allows me to do on-the-fly color changing in the curses module. I'm thinking about something along the lines of this: addstr(y, x, 'hello',...
4
by: schwerdy | last post by:
Hi together, can someone provide an example of a curses application that works in a xterm that can be resized? I could not find any working example yet... Thanks in advance, Sebastian...
1
by: ale.of.ginger | last post by:
Now that I have gotoxy() down for moving the cursor around, I want that to be a result of keypresses (namely from the numpad -- 7 = NorthWest, 8 = North, 9 = NE, etc...). I have little clue how to...
1
by: Jerry Fleming | last post by:
Hi, I have wrote a game with python curses. The problem is that I want to confirm before quitting, while my implementation doesn't seem to work. Anyone can help me? #!/usr/bin/python # #...
3
by: Simon Morgan | last post by:
Hi, I'm having trouble with the following code. The problem is that the value read by getch() when I hit the up or down keys doesn't match curses.KEY_UP or curses.KEY_DOWN respectively. Other...
7
by: Gasten | last post by:
Hello. The last weeks I've been coding a roguelike (you know, like nethack) in python using the nCurses library. Some week ago I ran into a problem: When I made the object for messagebar-output, I...
5
by: 7stud | last post by:
I can't see to get any y, x coordinates to work with curses. Here is an example: import curses def my_program(screen): while True: ch = screen.getch() if ch == ord("q"): break
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.