How2 use curses for data input

Grant Edwards grant at nowhere.
Fri Apr 21 13:23:09 EDT 2000


In article <38FF8F9C.9D533E74 at sprint.ca>, Miles Thompson wrote:

>I located it on the RH system here in the office at home. The
>target machine is Debian, and I think I can install RPM on it
>so that if need be, I can get the RPM. Debian doesn't seem to
>have a snack package.

It's something that RH did for use in their installer and
system admin tools, so I don't think it's part of the standard
Python dist.  Which is a shame.

>Thanks for the lead, much appreciated. I've searched google,
>www.python.org, and www.debian.org for information on how to
>use it. 

Didn't find much, eh?  (Been there.)

>All that's on my system is snack.py, .pyc and _snackmodule.so.
>I *hoped* there might be some clues in __builtin__ or in
>snakc.py, but I drew a blank.

Here's a little demo program:

======================================================================
import snack
import time

screen = snack.SnackScreen()
screen.drawRootText(1,1,"background text")
screen.refresh()
time.sleep(1)
x = snack.ButtonChoiceWindow(screen,
                         "test window", 
                         "This is a test of the button choice window")
y = snack.EntryWindow(screen, 
                "EntryWindow Title",
                "This is some text",
                ["prompt1", "prompt2"])
z = snack.ListboxChoiceWindow(screen,
                              "ListboxChoiceWindow Title",
                              "This is a bunch of text for thelist box choice window",
                              ['item1','item2','item3'])
time.sleep(1)
screen.finish()
print x
print y
print z
======================================================================

The above program uses some pre-defined window layouts.  The
newt source package contains some other more complex examples
showing how to layout your own windows using a grid placement
manager.  The nested checkbox-tree widget is pretty cool.

I'll put the newt source package in my ftp directory:

   <ftp://ftp.visi.com/users/grante/stuff/newt-0.50.tar.gz>

Newt/snack is really a handy little package. Too bad it's so
little known.  The tutorial contained in the source package I
have is a bit out of date and doesn't explain grid widgets, so
you've got to figure them out based on the source code and the
example programs.  I should look around to see if there's a
newer version of newt available...

-- 
Grant Edwards                   grante             Yow!  I OWN six pink
                                  at               HIPPOS!!
                               visi.com            



More information about the Python-list mailing list