275 questions
0
votes
1
answer
94
views
Why can't I see the text?
I've been trying to develop my own simple little CLI Typing Game with Curses. The menu works, but when I try to press play on it, the words aren't appearing. I could see them before but they're just ...
1
vote
0
answers
48
views
Python curses refresh issues when resizing terminal
With this example
#!/usr/bin/env python3
import curses
def repaint(stdscr,flog,wlog):
flog.clear()
wlog.clear()
# It seems flog and wlog autoresizing magicaly
# flog.resize(curses.LINES, ...
1
vote
0
answers
67
views
Why do I need to execute a getch() before ncurses will display anything? [duplicate]
I have an curses application with a getch() loop.
I found that the application would only display after accepting user input. In other words, I could not draw anything to the terminal before ...
0
votes
2
answers
121
views
Python curses won't work properly in cmd or powershell
I'm trying to display big ascii text with curses, but it only works in the Visual Studio Code terminal for some reason.
Visual Studio Code terminal displays the text correctly
But when I try to run ...
1
vote
1
answer
154
views
What's the use of curses.KEY_ENTER, KEY_BACKSPACE?
curses.KEY_ENTER and curses.KEY_BACKSPACE have values that stdscr.getch never seems to return, so what's the point of them? Should my code even test for them?
Why do
c = stdscr.getch()
if c in (curses....
0
votes
1
answer
88
views
Add default text to curses Textbox object
I'm using the curses python library in an application and have implemented a Textbox as well https://docs.python.org/3/library/curses.html#textbox-objects.
Is there a way to add a default text when ...
0
votes
1
answer
60
views
Python Curses getkey giving different results based on input window
I'm writing a curses UI program in Python. I am using the curses wrapper and getting a screen object as a parameter to a function I've set up.
I divide the screen up into some smaller windows using ...
1
vote
0
answers
26
views
cannot fill curses window region with text - is this the design? [duplicate]
Here is code to simply fill a terminal screen:
import curses
def main(stdscr):
max_y = curses.LINES
max_x = curses.COLS
rows = max_y - 1
cols = max_x - 3
total_chars1 = rows *...
0
votes
0
answers
58
views
How do I find the Curses Module
How do I find the "curses" module for python? I cannot find it anywhere and whatever I tried I could not obtain any useful results or information, I also checked in visual studio code ...
0
votes
0
answers
41
views
Understanding Conceptually How Python Curses Files Fit With Files Containing Functions
So i'm building a command line script for installing gentoo and along the way decided i'd like to in as well beautify it or create a python curses menu alongside what functions i have handling ...
1
vote
1
answer
110
views
Python curses Textbox.gather() removes empty lines, is there a way to preserve them?
In below code box.gather() removes empty lines from text. Is there a way to collect the text as is including empty lines?
from curses import wrapper
from curses.textpad import Textbox
def main(stdscr)...
0
votes
0
answers
83
views
Flickering entities in curses python
Hey i got a lot of entities drawn with curses, they move dynamically and after i changed some code to async (for movement speed functionality) entities sometimes are flickering. What could be the ...
1
vote
0
answers
268
views
Python curses library not initializing
I installed the windows-curses library through pip, and it seemed to install without any issue.
However whenever I try to run a program like this simple one below in gives me this error.
Code:
import ...
1
vote
1
answer
822
views
How to detect the shortcut combination CTRL + Key in python curses
I have been reading the documentation on curses in Python but I cannot figure it out how to detect the combinations like CTRL-S, or CTRL-A, or ALT-X, or CMD+A (in macOS), etc.
Anyone knows how to do ...
1
vote
2
answers
7k
views
Can't install curses package
I'am trying to run
pip install curses
in the CMD put it returns the error:
ERROR: Could not find a version that satisfies the requirement curses (from versions: none)
ERROR: No matching distribution ...
0
votes
1
answer
145
views
Curses does not print output
I am new to curses so am a little confused why I don't see any output from this little "hello world":
import curses
import time
def main(window: curses.window):
window.addstr(1, 1, "...
-1
votes
1
answer
67
views
PyCurses MousClick
self.stdscr = stdscr
self.initialize(**object_dict)
self.map_all_colors()
self.draw_all_views()
curses.curs_set(0)
stdscr.keypad(1)
curses.mousemask(1)
curses.mousemask(curses.ALL_MOUSE_EVENTS)
# ...
0
votes
0
answers
127
views
Issue with Countdown Timer and User Input in Python using curses
I'm working on a Python program that involves a real-time countdown timer and allows the user to input a value inline with the timer using the curses library. However, I'm facing some issues with the ...
0
votes
1
answer
120
views
Input & Print at the same time?(python 3.11, windows11)
Currently, the code waits for user input before printing the next number. I want the code to print numbers continuously without being interrupted by user input, but still allow the user to enter a ...
2
votes
2
answers
1k
views
How to fix the width and height of the window using curses in Python?
According to this link, https://docs.python.org/3/library/curses.html, the description for curses.resizeterm(), it should be possible to fix the width and height of my terminal window to a fixed ...
0
votes
1
answer
288
views
Python Curses: Check if cursor is hidden
I am wanting to write a function to ask the user input using Python curses. The problem I am having is I want to have the cursor hidden in other parts of the program except in the text-box. I intend ...
2
votes
1
answer
125
views
Does Python curses have an equivalent to chtype strings?
In C curses, it is possible to store a character and associated attributes in a variable of type chtype (which is usually an unsigned int). This is useful when you want, for example, an easily ...
0
votes
1
answer
3k
views
python error "ModuleNotFoundError: No module named '_curses' "
import curses
class TextEditor:
def __init__(self):
self.screen = curses.initscr()
curses.noecho()
curses.cbreak()
self.screen.keypad(True)
self.buffer = &...
0
votes
1
answer
127
views
Left side displacing when using Japanese characters with curses in python
This is a small python program using curses:
import curses
import locale
def init_curses():
stdscr = curses.initscr()
curses.start_color()
curses.use_default_colors()
curses.noecho()
...
1
vote
3
answers
548
views
What are the `y` and `x` params to the python curses `window.getch()` method?
I may be missing something very obvious, but
I am confused by the optional [y, x] parameters to the window.getch( [y, x] ) method described in the Python documentation. What are these optional params ...
3
votes
1
answer
2k
views
ModuleNotFoundError: No module named '_curses' on Ubuntu 22.04
I want to use curses for a personnal Python project. However, when I try to import it, I get the following error :
>>> import curses
Traceback (most recent call last):
File "<stdin&...
3
votes
3
answers
5k
views
Python CLI Menu with Arrow Keys on Windows
The terminal I use on Windows is Mingw-w64 (Git Bash). I am trying to find or create a CLI menu with Python that I can navigate with arrow keys, however nothing I find works.
The Python library, ...
0
votes
0
answers
52
views
Python ncurses program stops working when resizing command prompt to mininimum size
I'm currently facing a problem where my program seems to work fine when the windows cmd has a height of at least 3 rows. However when the cmd is resized smaller than that, ncurses stops updating the ...
1
vote
0
answers
298
views
how to update stdscr size with python curses after resizing the terminal
I tried searching everywhere on the internet, but nowhere did I find an answer that worked for me, so I'm asking a new question.
In my code, I'm telling curses to get the terminal size and update some ...
0
votes
1
answer
113
views
What is curses.COLORS in Python curses library?
I would like to know what curses.COLORS is in the curses module.
I didn't find any explanation on what exactly it is in the documentation.
0
votes
1
answer
661
views
Animation using pads in curses
I would like to move a curses pad across the screen, but I can't figure out a way to automatically erase the pad from the previous position in the screen without erasing the contents of the pad. I don'...
-1
votes
1
answer
385
views
Why is junk data appearing in my Python's subprocess stdout?
I'm writing a Python app that runs a command on an AWS remote docker container, and saves the output to a file. The command that is being run remotely is generating binary data (a database dump).
The ...
2
votes
2
answers
583
views
Issue with Python displaying all available color pairs with Curses
I am running Python 3.10 and I am having an issue with curses, specifically when trying to utilize the full range of color pairs
curses.COLORS returns 256
curses.COLOR_PAIRS returns 65536
curses....
0
votes
0
answers
166
views
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 ...
0
votes
1
answer
233
views
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....
0
votes
1
answer
519
views
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. ...
-1
votes
2
answers
1k
views
ModuleNotFoundError: when importing curses in IDE
I get the error ModuleNotFoundError: No module named '_curses' every time I try to uses curses in VS Code or PyCharm.
But it works in the command prompt (I'm on Windows BTW)
Code is from Tech With Tim ...
0
votes
0
answers
76
views
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 <module>
curses.wrapper(main)
File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-...
1
vote
1
answer
2k
views
How can I use curses to respond to a key press without pausing the program to wait for an input?
An example of what I would like to do is the following:
import curses
while True:
key = stdscr.getch()
if key == 119:
print("key w pressed")
else:
...
-1
votes
1
answer
86
views
not able to append in a list in curses module?
I want to take a user input with python curses module but every time it is not adding any element in the list can any one please help me
my code :-
import curses
from curses import wrapper
from curses....
1
vote
2
answers
2k
views
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 ...
0
votes
1
answer
86
views
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('*'...
0
votes
0
answers
297
views
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 ...
1
vote
1
answer
748
views
Plotext and Curses - windows
Needed help with this code:
import plotext as plt
from contextlib import redirect_stdout
import io
import curses
import locale
locale.setlocale(locale.LC_ALL, '')
code = locale.getpreferredencoding()
...
0
votes
1
answer
839
views
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 ...
0
votes
0
answers
246
views
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....
1
vote
0
answers
832
views
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 ...
0
votes
0
answers
3k
views
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
...
0
votes
0
answers
68
views
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 = '''
╔╗─╔╦═══╦╗──╔╗──╔═══╗╔╗
║║─║║╔══╣║──║...
1
vote
1
answer
668
views
How would I print out a string one letter at a time using Python Curses?
For some style in my console applications, I'll often have a string print out one character at at time using code like this:
import time
def run():
the_string = "Hello world!"
for ...