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
5
votes
2 answers

Compiling Python with curses support

My attempts to compile and install Python with curses support have failed and I've tried various iterations on my compile flags and whatnot, and can't seem to get this thing working. This is on Solaris 11, Python version 3.4.3: First off, here's the…
CptSupermrkt
  • 6,144
  • 7
  • 50
  • 79
5
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
  • 81,422
  • 40
  • 198
  • 249
5
votes
2 answers

Python Curses - module 'curses' has no attribute 'LINES'

I am looking at some source-code from a book and noticed that some of the code does not seem to be in the current Python2.7 API. The module curses is, according to this code, supposed to have a constant variable called LINES and another called COLS.…
user_loser
  • 802
  • 1
  • 12
  • 25
4
votes
0 answers

Python curses getmaxyx not refreshed with ipython debugger tracer

I am working on a project using curses in Python. I use stdscr.getmaxyx() in a while True loop to get the current terminal window size, in order to display text at the center of the terminal window. The code below works as expected: when you run it…
guampi
  • 171
  • 8
4
votes
1 answer

Interpreting "ENTER" keypress in stdscr (curses module in Python)

I am using Python's curses module. In stdscr, whenever I press enter key, curse moves to the first column in the same line. I have couple of questions regarding it. What is the reason for that? Is there a way to move the curse to the next line? If…
Rob
  • 159
  • 1
  • 4
  • 15
4
votes
2 answers

Python3 + Curses: How to press "q" for ending program immediately?

When I run the following sample code and press just "q", it'll ends properly, but if I pressed any other characters "for instance many breaks and a lot of other characters" and then press "q" it'll not exit, how can I solve this? import curses,…
M. Adel
  • 381
  • 3
  • 7
4
votes
1 answer

ncurses 10,10 pad causes error when addstr to 9, 9

After declaring a 10 by 10 pad, I apparently can't write to lower right corner, 9, 9 without an error. What is going on here? import curses def start(stdscr): curses.curs_set(0) movement = curses.newpad(10, 10) movement.addstr(8, 9,…
Dan
  • 9,106
  • 14
  • 52
  • 65
3
votes
1 answer

Displaying text with trailing whitespace in curses

I'm currently working on a text editor and this was one of the oddities I couldn't quite figure out! I'll start with a small demo script which reduces down the problem import curses def c_main(stdscr): lines = ( 'welcome to my…
Anthony Sottile
  • 40,161
  • 9
  • 79
  • 122
3
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
  • 311
  • 4
  • 14
3
votes
2 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
  • 327
  • 3
  • 15
3
votes
1 answer

Python curses - textpad.Textbox() keyboard input not working with German umlauts

I'm trying to use the curses textpad.Textbox() function for text input. Everything is working fine so far, however, some keys don't get recognized, including the section sign (§) and all German umlauts (ä/ö/ü). I guess it's somehow related to the…
lsgng
  • 365
  • 6
  • 16
3
votes
1 answer

Use curses with colorama

Is it possible to use curses with colorama? Here is my code, it prints the escape sequences: from curses import wrapper import colorama STYLE = colorama.Fore.GREEN + colorama.Back.BLUE TITLE = STYLE + 'Current terminal size:' HEIGHT_STRING = STYLE…
Anonimista
  • 732
  • 1
  • 5
  • 12
3
votes
1 answer

output on a new line in python curses

I am using curses module in python to display output in real time by reading a file. The string messages are output to the console using addstr() function but I am not able to achieve printing to a newline wherever I need. sample code: import…
cool77
  • 821
  • 4
  • 12
  • 27
3
votes
2 answers

_curses.error: addstr() returned ERR

Using Python, I am trying to write a script which will convert all typed characters into 'a' whenever you pressed space-bar. For example, i typed "python" and then space, then "python" will convert into "aaaaaa". import argparse import curses import…
Rob
  • 159
  • 1
  • 4
  • 15
3
votes
2 answers

Standard keys functions in curses module

Have a simple program: import curses import time window = curses.initscr() curses.cbreak() window.nodelay(True) while True: key = window.getch() if key != -1: print key time.sleep(0.01) curses.endwin() How can i turn on…
mcklayin
  • 1,142
  • 7
  • 14
1
2
3
14 15