473,791 Members | 3,071 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.er ror: getmouse() returned ERR". This is much less informative
than one might hope.

Thanks in advance for any help.

James
Feb 27 '07 #1
4 2503
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.uc la.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.er ror: 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.uc la.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
1207
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 getmouse of curses. In this way I want to admin the click of the ref to start the function startfile() to open every files (*.pdf, *.word) with the current application. In my editor Python 2.2 that I download in www.python.it I've not the curses....
0
1776
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 getch(); iv) hit a key; v) the program locks up, the interptreter is now munching on the CPU; vi) kill the interpreter from another shell; vii) scratch head and wonder why neither of the mutually exclusive clauses in the _io() member function...
0
1883
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', brightyellow, blue) The module would automatically interpret the above as curses.init_pair(i, curses.COLOR_YELLOW, curses.COLOR_BLUE)
4
4127
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 'Schwerdy' Schwerdhöfer
1
3734
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 do this. After searching google, I've come upon this; include: import curses in the header. However, I've found various methods of actually reading the keyboard press (getch(), raw_input, etc.). What is the best method to use for reading...
1
3698
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 # # Brick & Ball in Python # by Jerry Fleming <jerryfleming@etang.com>
3
4874
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 keys, such as 'z' in my example code, work fine. I only seem to have this problem when dealing with newly created windows and not with the standard/default/root one created by curses.wrapper() and passed to main().
7
2855
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 found a bug that I can't figure out (believe me; I've tried everything and asked for help several times on the IRC-channel). The updateMsg() and iMsg() takes a list of message-lines as argument (or process a string to a list), and it'll output...
5
6332
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
10427
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10155
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5431
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4110
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.