curses : unexpected behaviour with pad

R

Riccardo Galli

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
 
D

dody

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top