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

How do I add my current code fit into a main menu screen with Python Curses?

I'm working on a snake game for a school assignment in Python Curses but the code I have written doesn't have a menu option and I am looking for one that will work for it. I really just need a play button to enter the game and an exit button to quit…
0
votes
0 answers

How to enable both live mouse updates AND extended colors in a Python 3 curses app on a Cygwin Xterm?

This is a follow-up to a question from from 7 years ago [see Link *]. I'd like a built-in or portable way to enable live-mouse updates AND extended colors, in a python 3 curses application that currently runs on a Windows Cygwin Xterm. I don't want…
MrMattBusby
  • 116
  • 5
0
votes
0 answers

python curses' getch() returns -1 instead of KEY_RESIZE when terminal is resized. Why?

I am attempting to create handling for manual terminal resizing in my python program that uses the curses module. After a bit of testing, it seems that when the terminal is manually resized, getch() doesn't return KEY_RESIZE but instead returns -1…
U_0047
  • 1
  • 2
0
votes
0 answers

Implementing scroll on Python courses library

Just for fun, I am implementing a python program to generate Ulam spirals (https://en.wikipedia.org/wiki/Ulam_spiral) of arbitrary size. The program receives the size of the spiral and eventually the program prints the spiral on stdout. I was…
0
votes
1 answer

is there any solution to curses library problem?

so I was programing a snake game with curses and it's already there but python tells me that it doesn't exist import random import curses screen = curses.initscr() sh, sw = screen.getmaxyx() curses.curs_set(0) window = curses.newwin(sh, sw, 0,…
0
votes
0 answers

from _curses import * ModuleNotFoundError: No module named '_curses

This is the error I am getting: Traceback (most recent call last): File "c:\Users\brook\python_practice\snake.py", line 1, in import curses File "C:\Users\brook\AppData\Local\Programs\Python\Python310\lib\curses_init_.py", line 13, in from _curses…
0
votes
1 answer

curses.addstr does not output to console

I've recently installed the windows-curses module on my machine, via py -m pip install windows-curses run in an elevated command prompt. I wrote the following code to test if it was working correctly. If it runs correctly, it should print the string…
Mous
  • 953
  • 3
  • 14
0
votes
0 answers

Why is my function breaking (ascii game using curses)? I dont understand why this error persists

The error looks like this: Traceback (most recent call last): File "main.py", line 136, in curses.wrapper(main) File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/curses/__init__.py", line 105, in…
0
votes
2 answers

How to integrate Rich with Python curses?

I'm thinking of creating a CLI app using python curses and rich libraries. As curses requires addstr method to print text to string, I'm unable to print using rich. Is it possible to integrate these two libraries? Following codes don't work…
Sharukh Rahman
  • 327
  • 3
  • 12
0
votes
1 answer

Taking mouse input curses

Can anyone tell me how to take mouse input în Python curses? And if there is any way that I can create a custom cursor for the mouse inside the terminal when I run the program? curses.set_curs_char('*') Or something in this manner.
Furtunos
  • 1
  • 1
0
votes
0 answers

How to completely unload the readline module in python?

I want to dynamically disable the readline functionality by completely getting rid of it. Not by disabling tab completion or any other provided functionality, but to completely unhook it, free resources. I have a program that uses ncurses for…
mwo
  • 446
  • 3
  • 9
0
votes
1 answer

How to wrap text to the next line in curses?

I am trying to display text files in the terminal using curses, but some lines of the file are larger than the size of my terminal. How can I wrap this overflowing text to the next line? def display(self): max_y, max_x =…
0
votes
0 answers

ModuleNotFoundError: No module named '_curses' when trying to use curses in py2exe

my python code I'm trying to run: import curses, random def main(stdscr): stdscr.clear() for i in range(0, 21): stdscr.addstr(i, 0, f'count {i+1}, and rand value {random.randint(0, 100)}') stdscr.refresh() …
0
votes
0 answers

python curses, how to use control, shift keys?

I am currently making a python project in curses, I want to know how to use the control and shift keys using stdscr.getch(), the other keys work, except for a few keys including ctrl and shift. The code for the files look like this #…
kible
  • 31
  • 5
0
votes
0 answers

ModuleNotFoundError: No module named '_curses'

I am using windows and would like to use the curses package,I installed it with the command: pip install windows-curses but when I try to import curses it gives an eror from the python source file __init__.py here's the…