By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,246 Members | 1,480 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,246 IT Pros & Developers. It's quick & easy.

curses : unexpected behaviour with pad

P: n/a
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
, if the pad is greater than the window. But aren't pad supposed to be
greater than windows ?

If I create a pad and I try to attach it to a panel, with
panel.new_panel(pad)
I get again
_curses_panel.error: curses function returned NULL

I need to have a pad to show/hide.
Am I doing something wrong ?

Here comes what I do

########
import curses
from curses import panel

def main(stdscr):
pad = curses.newpad(100, 100)
pad.bkgd('x',0)
pad.refresh( 0,0, 5,5, 15,15)
pad.getch()

def main_1(stdscr):
win=curses.newwin(0,0)
pad=win.subpad(100,100) #<--- error
my_pan=panel.new_panel(win)
pad.bkgd('x',0)
pad.refresh( 0,0, 5,5, 15,15)
panel.update_panels()
curses.doupdate()
pad.getch()

def main_2(stscr):
pad = curses.newpad(100, 100)
a_panel= panel.new_panel(pad) #<--- error
pad.bkgd('x',0)
pad.refresh( 0,0, 5,5, 15,15)

panel.update_panels()
curses.doupdate()
pad.getch()

if __name__=='__main__':
curses.wrapper(main)
#curses.wrapper(main_1)
#curses.wrapper(main_2)
########

Thank you,
Riccardo

--
-=Riccardo Galli=-
_,e.
s~ ``
~@. ideralis Programs
.. ol
`**~ http://www.sideralis.net
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
> def main_1(stdscr):
win=curses.newwin(0,0)
pad=win.subpad(100,100) #<--- error
I found that the behaviour of curses silently considers
subpad of a WINDOW object as also a WINDOW instead of PAD,
whether you uses subpad or subwin. try:

win=curses.newpad(0,0)
pad=win.subpad(100,100)
def main_2(stscr):
pad = curses.newpad(100, 100)
a_panel= panel.new_panel(pad) #<--- error


Panel does not support PAD. you must use WINDOW. this should
works:

pad = curses.newwin(100, 100)
a_panel= panel.new_panel(pad)

--
Best regards,
dody mailto:do**@postaccesslite.com












Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.