You are not logged in.

#1 2010-01-27 02:53:35

pepeapepepe
Member
From: Buenos Aires, Argentina
Registered: 2009-05-13
Posts: 36

newbie python curses, :)[SOLVED]

Hi,

   Could any one help me with this python code,
    Why it doesn't print the A? on an xterm

    It should work according to the docs sad
http://docs.python.org/library/curses.h … ses.newpad


Regards

import curses

if __name__="__main__":
      #initializing screen
      screen = curses.initscr()
      curses.noecho()
      curses.cbreak() #respond to keys inmidiatly


      pad = curses.newpad(10,10)
      pad.addch(1,1,'A')
      pad.refresh(0,0,0,0,10,10)
      screen.refresh()

       screen.getch()
      #finalizing screen
      curses.nocbreak()
      curses.echo()
      curses.endwin()

Last edited by pepeapepepe (2010-01-27 03:16:59)


.--.-.... --. .-.-.-..-.-..--....- .- .-...-... --..-..-... -.-.----. ..-.. ...------....-...-.-----..-- .-....---.-..- --. .-.-.-..-.-.--- .-...-... --..-..-... -.-.----. .-...- -......-...-...-..-..-

Offline

#2 2010-01-27 03:10:53

mikesd
Member
From: Australia
Registered: 2008-02-01
Posts: 788
Website

Re: newbie python curses, :)[SOLVED]

Refresh the screen window first, then the pad. You need to draw from the bottom layer up.

Offline

#3 2010-01-27 03:18:06

pepeapepepe
Member
From: Buenos Aires, Argentina
Registered: 2009-05-13
Posts: 36

Re: newbie python curses, :)[SOLVED]

Thanks mikesd,

    You are the best


.--.-.... --. .-.-.-..-.-..--....- .- .-...-... --..-..-... -.-.----. ..-.. ...------....-...-.-----..-- .-....---.-..- --. .-.-.-..-.-.--- .-...-... --..-..-... -.-.----. .-...- -......-...-...-..-..-

Offline

#4 2010-01-27 03:21:04

mikesd
Member
From: Australia
Registered: 2008-02-01
Posts: 788
Website

Re: newbie python curses, :)[SOLVED]

No problem. Curses in python is pretty cool. I'm using it myself at the moment. Check out curses.wrapper[1]. It makes it much easier to debug your application when it starts throwwing exceptions. smile

[1] http://docs.python.org/library/curses.h … es.wrapper

Offline

Board footer

Powered by FluxBB