Questions tagged [python-curses]

The Python curses module provides an interface to the curses library, the de-facto standard for portable advanced terminal handling.

The Python curses module provides an interface to the curses library, the de-facto standard for portable advanced terminal handling.

https://docs.python.org/2/library/curses.html

271 questions
38
votes
5 answers

ImportError: No module named '_curses' when trying to import blessings

I am trying to run this: from blessings import Terminal t = Terminal() print (t.bold('Hi there!')) print (t.bold_red_on_bright_green('It hurts my eyes!')) with t.location(0, t.height - 1): print ('This is at the bottom.') Which is the first…
Nazarii Morhun
  • 489
  • 1
  • 4
  • 3
19
votes
4 answers

Why does the escape key have a delay in Python curses?

In the Python curses module, I have observed that there is a roughly 1-second delay between pressing the esc key and getch() returning. This delay does not seem to occur for other keys. Why does this happen and what can I do about it? Test…
augurar
  • 12,081
  • 6
  • 50
  • 65
14
votes
5 answers

curses fails when calling addch on the bottom right corner

I am starting to learn curses in Python. I am using Python 3.5 on Mac OS X. When I try to write in the bottom-right corner, the program crashes with the following error: $ python ex_curses.py [...] File "ex_curses.py", line 19, in do_curses …
Giovanni
  • 625
  • 2
  • 6
  • 19
9
votes
3 answers

How can VIM tell the difference between `Ctrl-J` and `LF`?

I'm trying to create a little Python/curses app. But as far as I can see there's no way to tell whether CTRL+J or Enter have been pressed. Now this may be caused by the fact that they both have the same ascii code…
Dave Halter
  • 15,556
  • 13
  • 76
  • 103
8
votes
1 answer

Curses.init_color() won't take effect

I'm using Python curses and trying to initialize a new color using curses.init_color(). Even after initializing a new RGB value and assigning it to a pair, the changes won't take effect. My terminal supports color change since…
8
votes
3 answers

Python's curses module does not refresh pad until first character received

I have the following code that allows you to scroll up and down a pad of text. Each time you scroll (i.e. handle a user input) the pad updates as expected. However, before the first key is pressed nothing is shown, despite that I'm calling…
felix001
  • 15,341
  • 32
  • 94
  • 121
7
votes
1 answer

python script crashes after long time running

I have a python 2.7 script running on a Raspberry Pi 3. class UIThread(threading.Thread): def __init__(self, threadID, name, counter, U): threading.Thread.__init__(self) self.threadID = threadID self.name = name self.counter…
flyblade
  • 169
  • 1
  • 7
7
votes
0 answers

Remove delay after first symbol on key hold

When I press and hold a key, a first symbol is typed, then there is a little delay, and then other symbols are typed fast. Something like this: Same happens in Terminal. Same happens in linux console (tty), even though this delay is smaller…
Highstaker
  • 1,015
  • 2
  • 12
  • 28
7
votes
1 answer

How to scroll with curses?

How to scroll with curses? I tried the following, but it fails: import curses def main(stdscr): stdscr.clear() # Display 10 numbered lines: for line in range(10): stdscr.addstr(line, 0, str(line)) stdscr.getch() # Wait…
Eric O. Lebigot
  • 91,433
  • 48
  • 218
  • 260
6
votes
1 answer

Python curses, splitting terminal window in 4 pads - prefresh() returned ERR

I'm running a multiprocessing system in Python, and I was planning to use curses to divide the terminal window in 4 quadrants, and display the output of each of the processes in one of them. So, the final output should look something…
Carlo
  • 1,321
  • 12
  • 37
6
votes
1 answer

_curses.error: addwstr() returned ERR on changing nlines to 1 on newwin method

The code is: from curses import * from curses.panel import * def main(stdscr): start_color() curs_set(0) init_pair(1, COLOR_BLACK, COLOR_CYAN) posy = posx = 0 window = newwin(1, 1, posy, posx) panel = new_panel(window) …
rudevdr
  • 389
  • 1
  • 5
  • 15
6
votes
4 answers

Python Curses - Detecting the Backspace Key

I'm having a difficult time with detecting the Backspace key using the Curses module. Whenever I press the Backspace key, the character / string returned is '^?', however I'm not able to detect it with: if str(key) == '^?': The code below is set up…
Neil Graham
  • 593
  • 1
  • 5
  • 17
6
votes
2 answers

Python Type hinting with curses

I'm trying to figure out what to put in my type annotation at the top of this function. I have the following trivial example: import curses def main(stdscr): stdscr.clear() stdscr.addstr(2, 0, "What is the type of stdscr?") …
6
votes
4 answers

How to make a scrolling menu in python-curses

There is a way to make a scrolling menu in python-curses? I have a list of records that I got from a query in sqlite3 and I have to show them in a box but they are more than the max number of rows: can I make a little menu to show them all without…
Alessio Ragno
  • 476
  • 1
  • 6
  • 20
6
votes
1 answer

Python curses print terminal color escape codes

I have a bash script that prints a nice big colorful table, using escape codes for foreground and background generated from tput. My curses application needs to call this bash script and put the output on the screen. When I try to do that, curses…
ACK_stoverflow
  • 3,148
  • 4
  • 24
  • 32
1
2 3
18 19