On 5/8/07, Ori Peleg <[EMAIL PROTECTED]> wrote:
Hi Maxim!

I'm not a curses expert and I don't know why this is happening, but maybe
these suggestions will help:

Have you read the tutorial Curses Programming with Python ? I found it very
helpful.
Try using curses.addstr to print text (including colors) instead of 'print'
or 'sys.std*'. Examples are in the tutorial.
curses.wrapper is nice, takes care of initscr and friends.
Check out the Python curses demos, here or in a Python source tarball.
Bli Kesher, you can get the color codes from terminfo without running 'tput'
(but you don't need them when using curses.addstr):
curses.setupterm() # not needed if you call curses.initscr()
 curses.tparm(curses.tigetstr('setaf'), 0) # same as
commands.getoutput('tput setaf 0')
 Hope I helped,
Ori.


Hi,

I found out about TIOCGWINSZ so here is the implementation in python
to get what I screen x,y (the reason I've used curses in the first
place). Thanks for the help :)

"""
# Determining Terminal or Window Size

# either use ioctl
import struct, fcntl, termios, sys

s = struct.pack("4H", 0, 0, 0, 0)
hchar, wchar = struct.unpack("4H", fcntl.ioctl(sys.stdout,
termios.TIOCGWINSZ, s))[:2]
print hchar, wchar
"""

The code is a slightly modified version of
http://pleac.sourceforge.net/pleac_python/userinterfaces.html

As a side note, yes I did read the curses tutorial, I find it fuzzy.

Maxim.

--
Cheers,
Maxim Veksler

"Free as in Freedom" - Do u GNU ?

לענות