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
0
votes
0 answers

Python template strings in curses

I am making a game using curses on python. My code is: from curses import wrapper import curses def main(stdscr): score = 0 stdscr.erase() text =…
eyah
  • 111
  • 1
  • 8
0
votes
0 answers

Reclaim a redirected STDOUT temporarly in python

I wrote a program, that shows a terminal UI with python curses. The program shall be able to read from STDIN and write the result after the user interaction to STDOUT w/o so the output may be redirected to another program or file like so: cat in.csv…
Benjamin
  • 1,726
  • 1
  • 14
  • 35
0
votes
1 answer

Python curses border doesn't redraw; window resizing ruins border

I have a very simple curses project (I started learning this library for a CLI-themed text game) and want to have a border around my window. However, running screen.border() does NOT redraw my screen's border, which makes resizing the window…
0
votes
1 answer

When I'm importing curses module and adding multiple text to the screen, then an error is displayed in the terminal

I'm getting this error:- I have written the following code:- import curses from curses import wrapper def main(stdscr): stdscr.clear() # clears screen stdscr.addstr(10, 10, "Hello World!") # adds text to the screen stdscr.addstr(10,…
0
votes
1 answer

How to add scrolling in a textbox in curses?

Currently when we reach the end of the textbox area, we just move to the next line outside of the box. How can I implement scrolling such that when we reach the end and try to move to the next line, the top line disappears and the entire text body…
0
votes
1 answer

When using curses.getkey() arrow keys return different values in command prompt and vscode integrated terminal?

If I use a simple python script to check the value that is returned by the curses.getkey() import curses def main(stdscr): input = stdscr.getkey() curses.endwin() print(input) curses.wrapper(main) I get different values for arrow keys…
5akr1
  • 55
  • 5
0
votes
1 answer

i cannot import the library curses, i receive module _curses not found

if i try to "import curses" with python 3.9.6 installed i receive the message "C:\Program Files\Python39\python.exe" C:/Users/marco/PyCharm/Custom01/cursor.py Traceback (most recent call last): File "C:\Users\marco\PyCharm\Custom01\cursor.py",…
0
votes
1 answer

Curses - Replace getstr input to * (Asterisks)

I want getstr to display * (Asterisk) when a key is pressed, basically its like a password login form. Any clues on how to do that ? (Samiliar to getpass) So if i inputed abcd it would return **** (abcd) I don't know if this question already been…
RaphielHS
  • 31
  • 7
0
votes
1 answer

Should subwin windows be one size larger than content

I have the piece of code below which wouldn't work unless n_rows > 3 or n_cols > 3. Otherwise I get this error: Traceback (most recent call last): File "script.py", line 16, in curses.wrapper(main) File…
Hakim
  • 3,225
  • 5
  • 37
  • 75
0
votes
1 answer

Pylint error: Module 'curses' has no 'endwin' member

Having newly installed windows-curses (and restarted VS Code), I am attempting to write a context manager to abstract away curses.initscr() and curses.endwin(). However, in the problems pane, Pylint keeps throwing this error: Module 'curses' has no…
Lyndon Gingerich
  • 604
  • 7
  • 17
0
votes
0 answers

Python3 curses doesn't recognize curses.resizeterm()

I am running Python on a Fedora PC(redhat linux), and ran IDLE from the terminal via python3 -m idlelib.idle. However, attempting to run curses.resizeterm(40,40) results in the error File "/home/quowlord/Documents/ASCIIengineALPHA_1.py", line 75, in…
KillerQuow
  • 37
  • 8
0
votes
1 answer

Python curses' newwin not being displayed if stdscr hasn't been refreshed first

I'm currently playing around with curses and trying to understand how everything reacts. I was thinking I was making progress until I stumbled on this simple piece of code: import curses def main(stdscr: curses.window) -> None: stdscr.addstr(0,…
aureo
  • 35
  • 5
0
votes
1 answer

How do I print the Pi symbol using the curses module

I am trying to print the symbol pi to the terminal using curses.ACS_PI, but whenever I do so, it returns an error: >>> import curses >>> print(curses.ACS_PI) AttributeError: module 'curses' has no attribute 'ACS_PI' How do I get it to print pi to…
0
votes
1 answer

Top-Down map scrolling with python ncurses

I'm new to curses but I have some experience. I'm trying to make a top-down style game in python with ncurses, but I don't even know where to start. I'm wanting the character to be centered on the screen and move around the map, but the environment…
NOTFLIKS
  • 21
  • 3
0
votes
1 answer

Custom key-bind functionality in curses

I'm trying to implement some simple text editing functionality in a TUI I'm working on. I'm using the Python wrapper for curses. Currently what I'm trying to do is associate certain key-binds to a particular function or operation, but unsure of how…
r4bb1t
  • 1,033
  • 2
  • 13
  • 36