[Tutor] curses.wrapper() question
Alan Gauld
alan.gauld@blueyonder.co.uk
Thu Jul 17 18:33:01 2003
No help on the curses wrapper stuff, in fact its existence
was news to me! However...
> #### Begin Code
>
> def newWindow():
> begin_x = 20 ; begin_y = 7
> height = 5 ; width = 40
> win = curses.newwin(height, width, begin_y, begin_x)
> return
You need to indent the function body(but that might just be
an email wobbly) More significantly you don't need the empty
return statement. By default Python functions return None.
Also you might be better putting x,y,h and w in as parameters
rather than variables. This will allow you to specify them when
you call newWindow. Like this:
def newWindow(begin_x=20, begin_y=7, height=5,width=40):
win = curses.newwin(height, width, begin_y, begin_x)
You can then call this like:
newWin() # use the defaults specified
newWin(7,5,3,4) # a very small window
newWin(width=70) # defaults except for width
> for y in range(0,100):
> for x in range(0,100):
> try: pad.addch(y,x, ord('a') + (x*x+y*y) % 26)
> except curses.error: pass
Again I assume mail is messing up the necessary indentation?
HTH even if not with your real problem,
Alan G.