I am making a text-based game similar to Zork with Python. I have
decided to use the curses module, and have run into a problem. I want
to scroll the commands and output up after a command is run instead of
clearing the screen. But when I use std.scroll(), an exception is
raised. Here is the program:
#!/usr/bin/env python
# text_adventure. py
import curses
import curses.wrapper
def main(stdscr):
curses.echo()
stdscr.setscrre g(1, 24)
score = 0
moves = 0
statusbar = stdscr.subwin(2 , 80, 0, 0)
statusbar.addst r(0, 0, 'Dingo'+' '*(58-len('Dingo'))+' Score: %03d
Moves: %03d'%(score, moves), curses.A_REVERS E)
stdscr.addstr(2 4, 0, '')
x = stdscr.getstr(2 4, 2)
x = str(x)
stdscr.refresh( )
# stdscr.erase()
stdscr.scroll(3 )
statusbar.erase ()
statusbar.addst r(0, 0, x+' '*(58-len(x))+'Score: %03d Moves: %
03d'%(score, moves), curses.A_REVERS E)
stdscr.addstr(2 4, 0, '')
stdscr.getstr(2 4, 2)
curses.wrapper( main)
Unfortunately, the error message isn't very helpful. I'm just hoping
somebody out there knows curses and has the answer.
-- Ratfink 1 1423
On Sat, 12 Jul 2008 20:49:56 -0400, Clay Hobbs wrote:
Unfortunately, the error message isn't very helpful.
But it would be helpful to tell it. If you get exceptions, always
copy'n'paste the traceback here. People might know what the exception
means and share their wisdom.
Ciao,
Marc 'BlackJack' Rintsch This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Edmond Ho |
last post by:
Hi, I'm having trouble with a small curses program. I'm associate a pad with
a panel. As I understand, a pad is supposed to be just a window with an
arbitrary size. That seems to imply that a pad can be treated like a normal
window when working with panels. I have this code:
#!/usr/bin/env python
import curses
import curses.panel
|
by: Riccardo Galli |
last post by:
Hi,
I'm writing some widgets in curses.
Actually I'm trying to write a combobox. To do so, I need to create a pad
inside a panel, so that I can hide/show it.
I can't do it.
I can create a normal pad, but if I try to create it using "subpad" from a
window I get
_curses_panel.error: curses function returned NULL
|
by: Matthew Alton |
last post by:
The appended program freaks python 2.2 & 2.3 completely out. To
reproduce the wierdness: i) copy the source to a file called
consarn.py ii) $ python consarn.py; iii) the program is now doing a
getch(); iv) hit a key; v) the program locks up, the interptreter is
now munching on the CPU; vi) kill the interpreter from another shell;
vii) scratch head and wonder why neither of the mutually exclusive
clauses in the _io() member function...
|
by: Matt Garman |
last post by:
I'd like to write a class or module in python that allows me to do
on-the-fly color changing in the curses module.
I'm thinking about something along the lines of this:
addstr(y, x, 'hello', brightyellow, blue)
The module would automatically interpret the above as
curses.init_pair(i, curses.COLOR_YELLOW, curses.COLOR_BLUE)
|
by: Jerry Fleming |
last post by:
Hi,
I have wrote a game with python curses. The problem is that I want to
confirm before quitting, while my implementation doesn't seem to work.
Anyone can help me?
#!/usr/bin/python
#
# Brick & Ball in Python
# by Jerry Fleming <jerryfleming@etang.com>
| |
by: Simon Morgan |
last post by:
Hi,
I'm having trouble with the following code. The problem is that the value
read by getch() when I hit the up or down keys doesn't match curses.KEY_UP
or curses.KEY_DOWN respectively. Other keys, such as 'z' in my example
code, work fine.
I only seem to have this problem when dealing with newly created windows
and not with the standard/default/root one created by curses.wrapper() and
passed to main().
|
by: Gasten |
last post by:
Hello.
The last weeks I've been coding a roguelike (you know, like nethack) in
python using the nCurses library. Some week ago I ran into a problem:
When I made the object for messagebar-output, I found a bug that I
can't figure out (believe me; I've tried everything and asked for help
several times on the IRC-channel).
The updateMsg() and iMsg() takes a list of message-lines as argument
(or process a string to a list), and it'll output...
|
by: skip |
last post by:
Environment: Solaris 10, Python 2.4.2.
I'm trying to convert a very simple (display-wise) program to use curses.
This is my first try at using curses. I have wrapped my main:
try:
sys.exit(curses.wrapper(main, *sys.argv))
except (KeyboardInterrupt, SystemExit):
sys.exit(0)
|
by: 7stud |
last post by:
I can't see to get any y, x coordinates to work with curses. Here is
an example:
import curses
def my_program(screen):
while True:
ch = screen.getch()
if ch == ord("q"):
break
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |