snack
index
/usr/lib/python1.5/snack.py
 

# snack.py: maps C extension module _snack to proper python types in module
# snack.
# The first section is a very literal mapping.
# The second section contains convenience classes that amalgamate
# the literal classes and make them more object-oriented.

   
Modules
                        
_snack
string
types

   
Classes
                        
Form
Grid
ButtonBar
GridForm
RadioBar
SnackScreen
Widget
Button
Checkbox
CheckboxTree
Entry
Label
Listbox
RadioGroup
Scale
SingleRadioButton
Textbox
TextboxReflowed

   
class Button(Widget)
              
__init__(self, text)

   
class ButtonBar(Grid)
              
__init__(self, screen, buttonlist)
buttonPressed(self, result)
Takes the widget returned by Form.run and looks to see
if it was one of the widgets in the ButtonBar.

   
class Checkbox(Widget)
              
__init__(self, text, isOn=0)
selected(self)
setFlags(self, flag, sense)
value(self)

   
class CheckboxTree(Widget)
              
__init__(self, height, scroll=0)
addItem(self, text, path, item=None, selected=0)
append(self, text, item=None, selected=0)
getSelection(self)

   
class Entry(Widget)
              
__init__(self, width, text='', hidden=0, scroll=1, returnExit=0)
set(self, text)
setFlags(self, flag, sense)
value(self)

   
class Form
              
__init__(self)
add(self, widget)
addHotKey(self, keyname)
draw(self)
run(self)
setCurrent(self, co)

   
class Grid
              
__init__(self, *args)
place(self, x, y)
setField(self, what, col, row, padding=(0, 0, 0, 0), anchorLeft=0, anchorTop=0, anchorRight=0, anchorBottom=0, growx=0, growy=0)

   
class GridForm(Grid)
              
__init__(self, screen, title, *args)
add(self, widget, col, row, padding=(0, 0, 0, 0), anchorLeft=0, anchorTop=0, anchorRight=0, anchorBottom=0, growx=0, growy=0)
addHotKey(self, keyname)
create(self)
draw(self)
run(self)
runOnce(self)
runPopup(self)
setCurrent(self, co)

   
class Label(Widget)
              
__init__(self, text)
setText(self, text)

   
class Listbox(Widget)
              
__init__(self, height, scroll=0, returnExit=0, width=0)
append(self, text, item)
current(self)
delete(self, item)
insert(self, text, item, before)
replace(self, text, item)
setCurrent(self, item)

   
class RadioBar(Grid)
              
__init__(self, screen, buttonlist)
getSelection(self)

   
class RadioGroup(Widget)
              
__init__(self)
add(self, title, value, default=None)
getSelection(self)

   
class Scale(Widget)
              
__init__(self, width, total)
set(self, amount)

   
class SingleRadioButton(Widget)
              
__init__(self, text, group, isOn=0)
selected(self)

   
class SnackScreen
              
__init__(self)
centeredWindow(self, width, height, title)
drawRootText(self, left, top, text)
finish(self)
gridWrappedWindow(self, grid, title)
openWindow(self, left, top, width, height, title)
popHelpLine(self)
popWindow(self)
pushHelpLine(self, text)
refresh(self)
resume(self)
suspend(self)
suspendCallback(self, cb, data=None)

   
class Textbox(Widget)
              
__init__(self, width, height, text, scroll=0, wrap=0)
setText(self, text)

   
class TextboxReflowed(Textbox)
              
__init__(self, width, text, flexDown=5, flexUp=10, maxHeight=-1)

   
class Widget
              
setCallback(self, obj, data=None)

   
Functions
                        
ButtonChoiceWindow(screen, title, text, buttons=['Ok', 'Cancel'], width=40)
EntryWindow(screen, title, text, prompts, allowCancel=1, width=40, entryWidth=20, buttons=['Ok', 'Cancel'])
ListboxChoiceWindow(screen, title, text, items, buttons=('Ok', 'Cancel'), width=40, scroll=0, height=-1, default=None)
reflow(text, width, flexDown=5, flexUp=5)
# returns a tuple of the wrapped text, the actual width, and the actual height

   
Constants
                        
FLAGS_RESET = 1
FLAGS_SET = 0
FLAGS_TOGGLE = 2
FLAG_DISABLED = 8
n = 'F1'