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

225 questions
28
votes
4 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
  • 289
  • 1
  • 3
  • 3
15
votes
3 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
  • 9,426
  • 4
  • 40
  • 57
11
votes
4 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
  • 465
  • 4
  • 17
9
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
  • 12,330
  • 27
  • 79
  • 103
8
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
  • 13,484
  • 8
  • 69
  • 97
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
  • 159
  • 1
  • 5
7
votes
0 answers

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
  • 2,712
  • 4
  • 20
  • 30
6
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…
6
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
  • 805
  • 9
  • 24
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
  • 426
  • 4
  • 17
6
votes
2 answers

Why use curses.ascii.islower?

I've just recently stumbled upon curses.ascii.islower(). It checks if the passed character is lower case. What is the benefit in using this function as opposed to str.islower()? Yes, it requires a conversion of a ASCII character to string object,…
ilya1725
  • 3,506
  • 6
  • 31
  • 53
5
votes
1 answer

Curses - Certain emoji (flags) deform terminal output

When I output certain emoji (specifically flags) into a subwindow in curses, it deforms the output, even for output outside of that subwindow. Running: import curses def draw_screen(stdscr): event = 0 stdscr.clear() stdscr.refresh() …
Tom Anthony
  • 601
  • 6
  • 11
5
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?") …
5
votes
3 answers

How to display pre-colored string with curses?

I'm writing a curses program in Python. I'm a beginner of curses but I've used terminal control sequences for colored output. Now there's some code snippets to print inside the window, I'd like them be syntax highlighted, and it's better done with…
secondwtq
  • 53
  • 1
  • 5
5
votes
1 answer

Which $TERM to use to have both 256 colors and mouse move events in python curses?

Currently if I set the TERM environment variable to 'xterm-1003' I can get mouse move events but I get crappy colors and curses.can_change_color() == False os.environ['TERM'] = 'xterm-1003' ... curses.mousemask(curses.ALL_MOUSE_EVENTS |…
Wulfire
  • 85
  • 3
1
2 3
14 15