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().
I'd also appreciate any pointers to good tutorials on curses, I've read
the one by awk and esr but found it rather brief and lacking in detail.
Thanks.
import curses
def main(scr):
status = curses.newwin(1 , curses.COLS, 0, 0) status.bkgd('0' )
status.refresh( )
list = curses.newwin(c urses.LINES, curses.COLS, 1, 0) list.bkgd('X')
list.refresh()
y = 0
while True:
c = list.getch()
if c in (curses.KEY_UP, curses.KEY_DOWN , ord('z')):
list.addstr("Ma tch!")
elif c == ord('q'):
break
curses.wrapper( main) 3 4869
On Sat, 07 Oct 2006 13:12:33 +0000, Simon Morgan wrote:
import curses
def main(scr):
status = curses.newwin(1 , curses.COLS, 0, 0) status.bkgd('0' )
status.refresh( )
list = curses.newwin(c urses.LINES, curses.COLS, 1, 0) list.bkgd('X')
list.refresh()
If I use scr.subwin() instead of curses.newwin() ...
y = 0
while True:
c = list.getch()
and scr.getch() instead of list.getch(), things seem to work. I'd still
really like to know what's going on though.
if c in (curses.KEY_UP, curses.KEY_DOWN , ord('z')):
list.addstr("Ma tch!")
elif c == ord('q'):
break
curses.wrapper( main)
Simon Morgan wrote:
On Sat, 07 Oct 2006 13:12:33 +0000, Simon Morgan wrote:
import curses
def main(scr):
status = curses.newwin(1 , curses.COLS, 0, 0) status.bkgd('0' )
status.refresh( )
list = curses.newwin(c urses.LINES, curses.COLS, 1, 0) list.bkgd('X')
list.refresh()
If I use scr.subwin() instead of curses.newwin() ...
y = 0
while True:
c = list.getch()
and scr.getch() instead of list.getch(), things seem to work. I'd still
really like to know what's going on though.
if c in (curses.KEY_UP, curses.KEY_DOWN , ord('z')):
list.addstr("Ma tch!")
elif c == ord('q'):
break
curses.wrapper( main)
I don't have a linux here now but I vaguely remember running into this.
I think what I did was just writing down what code you do get when
pressing down and up, etc, and using that code. By the way I looked
around back then and didn't find any thorough tutorials on curses,
either.
Simon Morgan <me@privacy.net wrote:
I'd also appreciate any pointers to good tutorials on curses, I've read
the one by awk and esr but found it rather brief and lacking in detail.
esr only contributed his name - awk wrote the rest.
(When I asked why, he only said it sounded like a good idea ;-)
--
Thomas E. Dickey http://invisible-island.net ftp://invisible-island.net This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Michele Simionato |
last post by:
I have just performed this experiment with curses:
from curses import *
maxwidth=79
maxheight=21
def wait4q(stdscr):
scr=stdscr
scr.addstr("Press 'q' to exit\n")
|
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...
|
by: MackS |
last post by:
Hello
I am writing a small app to learn how to use the curses module. I would
like to know how I can get "composite" key presses, eg, Control+Q.
Currently I am looking at the following code snippet:
import curses.wrapper
def main(stdscr):
|
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...
|
by: Ian Ward |
last post by:
When I run the following code in a terminal with the encoding set to
UTF-8 I get garbage on the first line, but the correct output on the second.
import curses
s = curses.initscr()
s.addstr('\xc3\x85 U+00C5 LATIN CAPITAL LETTER A WITH RING ABOVE\n')
s.addstr('\xc3\xa5 U+00F5 LATIN SMALL LETTER O WITH TILDE')
s.refresh()
s.getstr()
| |
by: Mario Figueiredo |
last post by:
Hello everyone,
I'm having trouble controlling the cursor position when I make two
consecutive calls to the get family of functions. This problem does not
happen if there is an output in between.
The following code illustrates the problem in a simplified way:
#include "curses.h"
|
by: Kenneth McDonald |
last post by:
I know that the curses module has a long-standing bug wherein cursor
visibility can't be set. I'm looking at using the module for certain
uses, and this isn't a problems (as long as I hide the cursor offscreen)
as I would control visuals to provide a simulated cursor anyway. I'm
wondering, though, if there are any other elements of the curses module
I should be aware of before I commit to it, i.e. bugs that could cause
serious difficulties...
|
by: shrek2099 |
last post by:
Hi All,
Recently I ran into a problem with UTF-8 surrport when using curses
library in python 2.5 in Fedora 7. I found out that the program using
curses cannot print out unicode characters correctly on UTF-8 enabled
console. I googled around and got an impression that the reason for
this problem is that python is linked with libcurses library instead
of libcursesw. The latter one is said to be able to solve this
problem. Has anybody...
|
by: linkmaster032000 |
last post by:
I tried curses.setsyx(2,3) in my script and it doesn't move the curses
cursor. Any alternatives/solutions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |