Markdown Format | JSON API | MCP Server Tool
Help on module snack: NAME snack DESCRIPTION This module provides the NEWT Windowing toolkit API for Python This is a lightweight text-mode windowing library, based on slang. Classes: - Widget - Button - CompactButton - Checkbox - SingleRadioButton - Listbox - Textbox - TextboxReflowed - Label - Scale - Entry - Form - Grid - SnackScreen - RadioGroup - RadioBar - ButtonBar - GridFormHelp - GridForm - CheckboxTree - Clistbox Functions: - ListboxChoiceWindow - ButtonChoiceWindow - EntryWindow CLASSES builtins.object Form Grid ButtonBar CListbox GridFormHelp GridForm RadioBar SnackScreen Widget Button Checkbox CheckboxTree CompactButton Entry Label Listbox RadioGroup Scale SingleRadioButton Textbox TextboxReflowed class Button(Widget) | Button(text) | | Basic button class, takes button text as parameter | | method: | | - Button(self, text): returns a button | | Method resolution order: | Button | Widget | builtins.object | | Methods defined here: | | __init__(self, text) | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from Widget: | | setCallback(self, obj, data=None) | | ---------------------------------------------------------------------- | Data descriptors inherited from Widget: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class ButtonBar(Grid) | ButtonBar(screen, buttonlist, compact=0) | | Bar of buttons, based on grid. | | methods: | | - ButtonBar(screen, buttonlist,buttonlist, compact = 0): | - buttonPressed(self, result): Takes the widget returned by Form.run and looks to see | if it was one of the widgets in the ButtonBar. | | Method resolution order: | ButtonBar | Grid | builtins.object | | Methods defined here: | | __init__(self, screen, buttonlist, compact=0) | Initialize self. See help(type(self)) for accurate signature. | | buttonPressed(self, result) | | ---------------------------------------------------------------------- | Methods inherited from Grid: | | 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) | | ---------------------------------------------------------------------- | Data descriptors inherited from Grid: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class CListbox(Grid) | CListbox(height, cols, col_widths, scroll=0, returnExit=0, width=0, col_pad=1, col_text_align=None, col_labels=None, col_label_align=None, adjust_width=0) | | Clistbox convenience class. | | methods: | | - Clistbox(self, height, cols, cols_widths, scroll = 0) : constructor | - colFormText(self, col_text, align = None, adjust_width = 0) : column text. | - append(self, col_text, item, col_text_align = None) : | - insert(self, col_text, item, before, col_text_align = None) | - delete(self, item) | - replace(self, col_text, item, col_text_align = None) | - current(self) : returns current item | - setCurrent(self, item): sets an item as current | - clear(self): clear the listbox | | Alignments may be LEFT, RIGHT, CENTER, None | | Method resolution order: | CListbox | Grid | builtins.object | | Methods defined here: | | __init__(self, height, cols, col_widths, scroll=0, returnExit=0, width=0, col_pad=1, col_text_align=None, col_labels=None, col_label_align=None, adjust_width=0) | Initialize self. See help(type(self)) for accurate signature. | | append(self, col_text, item, col_text_align=None) | | clear(self) | | colFormText(self, col_text, align=None, adjust_width=0) | | current(self) | | delete(self, item) | | insert(self, col_text, item, before, col_text_align=None) | | replace(self, col_text, item, col_text_align=None) | | setCurrent(self, item) | | ---------------------------------------------------------------------- | Methods inherited from Grid: | | 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) | | ---------------------------------------------------------------------- | Data descriptors inherited from Grid: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class Checkbox(Widget) | Checkbox(text, isOn=0) | | A checkbox. | | methods: | | - Checkbox(self, text, isOn = 0) : text, and boolean as to default value | - setValue(self) : set value | - value(self, value) : return checkbox value | - selected(self) : returns boolean | - setFlags(self, flag, sense) : set flags | | flags: FLAG_DISABLED, FLAGS_SET, FLAGS_RESET | | Method resolution order: | Checkbox | Widget | builtins.object | | Methods defined here: | | __init__(self, text, isOn=0) | Initialize self. See help(type(self)) for accurate signature. | | selected(self) | | setFlags(self, flag, sense) | | setValue(self, value) | | value(self) | | ---------------------------------------------------------------------- | Methods inherited from Widget: | | setCallback(self, obj, data=None) | | ---------------------------------------------------------------------- | Data descriptors inherited from Widget: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class CheckboxTree(Widget) | CheckboxTree(height, scroll=0, width=None, hide_checkbox=0, unselectable=0) | | CheckboxTree combo widget, | | methods: | | - CheckboxTree(self, height, scroll = 0, width = None, hide_checkbox = 0, unselectable = 0) | constructor. | - append(self, text, item = None, selected = 0): | - addItem(self, text, path, item = None, selected = 0): | - getCurrent(self): | - getSelection(self): | - setEntry(self, item, text): | - setCurrent(self, item): | - setEntryValue(self, item, selected = 1): | - getEntryValue(self, item): | | Method resolution order: | CheckboxTree | Widget | builtins.object | | Methods defined here: | | __init__(self, height, scroll=0, width=None, hide_checkbox=0, unselectable=0) | Initialize self. See help(type(self)) for accurate signature. | | addItem(self, text, path, item=None, selected=0) | | append(self, text, item=None, selected=0) | | getCurrent(self) | | getEntryValue(self, item) | | getSelection(self) | | setCurrent(self, item) | | setEntry(self, item, text) | | setEntryValue(self, item, selected=1) | | ---------------------------------------------------------------------- | Methods inherited from Widget: | | setCallback(self, obj, data=None) | | ---------------------------------------------------------------------- | Data descriptors inherited from Widget: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class CompactButton(Widget) | CompactButton(text) | | Compact Button class (less frilly button decoration). | | methods: | | - CompactButton(self,text) : create button, with text. | | Method resolution order: | CompactButton | Widget | builtins.object | | Methods defined here: | | __init__(self, text) | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from Widget: | | setCallback(self, obj, data=None) | | ---------------------------------------------------------------------- | Data descriptors inherited from Widget: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class Entry(Widget) | Entry(width, text='', hidden=0, password=0, scroll=1, returnExit=0) | | Entry widget. | | methods: | | - Entry(self, width, text = "", hidden = 0, password = 0, scroll = 1, returnExit = 0) | constructor. hidden doesn't show text, password stars it out, | scroll includes scroll bars; | if returnExit is set, return from Form when exiting this element, else | proceed to next entry widget. | - value(self): return value. | - set(text, cursorAtEnd = 1) : set the text | - setFlags (flag, sense) : flags can be FLAG_DISABLED, FLAGS_SET, FLAGS_RESET, FLAGS_TOGGLE | | Method resolution order: | Entry | Widget | builtins.object | | Methods defined here: | | __init__(self, width, text='', hidden=0, password=0, scroll=1, returnExit=0) | Initialize self. See help(type(self)) for accurate signature. | | set(self, text, cursorAtEnd=1) | | setFlags(self, flag, sense) | | value(self) | | ---------------------------------------------------------------------- | Methods inherited from Widget: | | setCallback(self, obj, data=None) | | ---------------------------------------------------------------------- | Data descriptors inherited from Widget: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class Form(builtins.object) | Form(helpArg=None) | | Base Form class, from which Grid, etc. inherit | | methods: | | - Form(self, helpArg = None) : constructor. | - addHotKey(self, keyname) : keynames of form "F1" through "F12", "ESC" | - add(self, widget) : Add a widget | - run(self): run a form, expecting input | - draw(self): draw form. | - setTimer(self, timer) : add a timer | - watchFile(self, file, flags) : watch a named file | - setCurrent (self, co): Set a given widget as the current focus | | Methods defined here: | | __init__(self, helpArg=None) | Initialize self. See help(type(self)) for accurate signature. | | add(self, widget) | | addHotKey(self, keyname) | | draw(self) | | run(self) | | setCurrent(self, co) | | setTimer(self, timer) | | watchFile(self, file, flags) | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class Grid(builtins.object) | Grid(*args) | | Grid class. | | methods: | | - place(self,x,y): Return what is placed at (x,y) | - setField(self, what, col, row, padding = (0, 0, 0, 0), | anchorLeft = 0, anchorTop = 0, anchorRight = 0, | anchorBottom = 0, growx = 0, growy = 0): | used to add widget 'what' to grid. | - Grid(self, *args): eg. g = Grid(2,3) for 2x3 grid | | Methods defined here: | | __init__(self, *args) | Initialize self. See help(type(self)) for accurate signature. | | 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) | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class GridForm(GridFormHelp) | GridForm(screen, title, *args) | | GridForm class (extends GridFormHelp): | | methods: | | - GridForm(self, screen, title, *args): | | Method resolution order: | GridForm | GridFormHelp | Grid | builtins.object | | Methods defined here: | | __init__(self, screen, title, *args) | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from GridFormHelp: | | 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, x=None, y=None) | | draw(self) | | run(self, x=None, y=None) | | runOnce(self, x=None, y=None) | | runPopup(self) | | setCurrent(self, co) | | setTimer(self, keyname) | | ---------------------------------------------------------------------- | Methods inherited from Grid: | | 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) | | ---------------------------------------------------------------------- | Data descriptors inherited from Grid: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class GridFormHelp(Grid) | GridFormHelp(screen, title, help, *args) | | Subclass of Grid, for the help form text. | | methods: | | - GridFormHelp(self, screen, title, help, *args) : | - add (self, widget, col, row, padding = (0, 0, 0, 0), | anchorLeft = 0, anchorTop = 0, anchorRight = 0, | anchorBottom = 0, growx = 0, growy = 0): | - runOnce(self, x = None, y = None): pop up the help window | - addHotKey(self, keyname): | - setTimer(self, keyname): | - create(self, x = None, y = None): | - run(self, x = None, y = None): | - draw(self): | - runPopup(self): | - setCurrent (self, co): | | Method resolution order: | GridFormHelp | Grid | builtins.object | | Methods defined here: | | __init__(self, screen, title, help, *args) | Initialize self. See help(type(self)) for accurate signature. | | 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, x=None, y=None) | | draw(self) | | run(self, x=None, y=None) | | runOnce(self, x=None, y=None) | | runPopup(self) | | setCurrent(self, co) | | setTimer(self, keyname) | | ---------------------------------------------------------------------- | Methods inherited from Grid: | | 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) | | ---------------------------------------------------------------------- | Data descriptors inherited from Grid: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class Label(Widget) | Label(text) | | A Label (simple text). | | methods: | | - Label(self,text) : create label | - setText(self,text) : change text. | - setColors(self, colorset) : change individual colors | | Method resolution order: | Label | Widget | builtins.object | | Methods defined here: | | __init__(self, text) | Initialize self. See help(type(self)) for accurate signature. | | setColors(self, colorset) | | setText(self, text) | | ---------------------------------------------------------------------- | Methods inherited from Widget: | | setCallback(self, obj, data=None) | | ---------------------------------------------------------------------- | Data descriptors inherited from Widget: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class Listbox(Widget) | Listbox(height, scroll=0, returnExit=0, width=0, showCursor=0, multiple=0, border=0) | | Listbox class. | | methods: | | - Listbox(self, height, scroll = 0, returnExit = 0, width = 0, showCursor = 0, multiple = 0, border = 0) | - insert(self, text, item, before) : insert element; before = key to item to insert before, or None. | - delete(self, item) : delete item from list. | - replace(self, text,item) : Replace a given item's text | - current(self) : returns currently selected item | - getSelection(self) : returns a list of selected items | - setCurrent(self,i tem) : select current. | - clear(self) : clear listbox | | Method resolution order: | Listbox | Widget | builtins.object | | Methods defined here: | | __init__(self, height, scroll=0, returnExit=0, width=0, showCursor=0, multiple=0, border=0) | Initialize self. See help(type(self)) for accurate signature. | | append(self, text, item) | | clear(self) | | current(self) | | delete(self, item) | | getSelection(self) | | insert(self, text, item, before) | | replace(self, text, item) | | setCurrent(self, item) | | ---------------------------------------------------------------------- | Methods inherited from Widget: | | setCallback(self, obj, data=None) | | ---------------------------------------------------------------------- | Data descriptors inherited from Widget: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class RadioBar(Grid) | RadioBar(screen, buttonlist) | | Bar of Radio buttons, based on Grid. | | methods: | | - RadioBar(self, screen, buttonlist) : constructor. | - getSelection(self): return value of selected button | | Method resolution order: | RadioBar | Grid | builtins.object | | Methods defined here: | | __init__(self, screen, buttonlist) | Initialize self. See help(type(self)) for accurate signature. | | getSelection(self) | | ---------------------------------------------------------------------- | Methods inherited from Grid: | | 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) | | ---------------------------------------------------------------------- | Data descriptors inherited from Grid: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class RadioGroup(Widget) | Combo widget: Group of Radio buttons | | methods: | | - RadioGroup(self): constructor. | - add(self,title, value, default = None): add a button. Returns button. | - getSelection(self) : returns value of selected button | None | | Method resolution order: | RadioGroup | Widget | builtins.object | | Methods defined here: | | __init__(self) | Initialize self. See help(type(self)) for accurate signature. | | add(self, title, value, default=None) | | getSelection(self) | | ---------------------------------------------------------------------- | Methods inherited from Widget: | | setCallback(self, obj, data=None) | | ---------------------------------------------------------------------- | Data descriptors inherited from Widget: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class Scale(Widget) | Scale(width, total) | | A Scale (progress bar). | | methods: | | - Scale(self,width, total) : create scale; width: size on screen, fullamount: integer. | - set(self,amount) : set amount to integer. | | Method resolution order: | Scale | Widget | builtins.object | | Methods defined here: | | __init__(self, width, total) | Initialize self. See help(type(self)) for accurate signature. | | set(self, amount) | | ---------------------------------------------------------------------- | Methods inherited from Widget: | | setCallback(self, obj, data=None) | | ---------------------------------------------------------------------- | Data descriptors inherited from Widget: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class SingleRadioButton(Widget) | SingleRadioButton(text, group, isOn=0) | | Single Radio Button. | | methods: | | - SingleRadioButton(text, group, isOn = 0) : create button | - selected(self) : returns bool, whether or not is selected. | | Method resolution order: | SingleRadioButton | Widget | builtins.object | | Methods defined here: | | __init__(self, text, group, isOn=0) | Initialize self. See help(type(self)) for accurate signature. | | selected(self) | | ---------------------------------------------------------------------- | Methods inherited from Widget: | | setCallback(self, obj, data=None) | | ---------------------------------------------------------------------- | Data descriptors inherited from Widget: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class SnackScreen(builtins.object) | A Screen; | | methods: | | - Screen(self) : constructor | - finish(self) | - resume(self) | - suspend(self) | - doHelpCallback(self,arg) call callback with arg | - helpCallback(self,cb): Set help callback | - suspendcallback(self,cb, data=None) : set callback. data=data to pass to cb. | - openWindow(self,left, top, width, height, title): Open a window. | - pushHelpLine(self,text): put help line on screen. Returns current help line if text=None | - setColor(self, colorset, fg, bg): Set foreground and background colors; | colorset = key from snack.colorsets, | fg & bg = english color names defined by S-Lang | (ref: S-Lang Library C Programmer's Guide section: | 8.4.4. Setting Character Attributes) | | Methods defined here: | | __init__(self) | Initialize self. See help(type(self)) for accurate signature. | | centeredWindow(self, width, height, title) | | doHelpCallback(self, arg) | | drawRootText(self, left, top, text) | | finish(self) | | gridWrappedWindow(self, grid, title, x=None, y=None) | | helpCallback(self, cb) | | openWindow(self, left, top, width, height, title) | | popHelpLine(self) | | popWindow(self, refresh=True) | | pushHelpLine(self, text) | | refresh(self) | | resume(self) | | setColor(self, colorset, fg, bg) | | suspend(self) | | suspendCallback(self, cb, data=None) | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class Textbox(Widget) | Textbox(width, height, text, scroll=0, wrap=0) | | Textbox, container for text. | | methods: | | - Textbox(self, width, height, scroll = 0, wrap = 0): scroll, wrap are flags | include scroll bars, or text wrap. | - setText(text) : set text. | - setHeight(height): set height. | | Method resolution order: | Textbox | Widget | builtins.object | | Methods defined here: | | __init__(self, width, height, text, scroll=0, wrap=0) | Initialize self. See help(type(self)) for accurate signature. | | setHeight(self, height) | | setText(self, text) | | ---------------------------------------------------------------------- | Methods inherited from Widget: | | setCallback(self, obj, data=None) | | ---------------------------------------------------------------------- | Data descriptors inherited from Widget: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class TextboxReflowed(Textbox) | TextboxReflowed(width, text, flexDown=5, flexUp=10, maxHeight=-1) | | Method resolution order: | TextboxReflowed | Textbox | Widget | builtins.object | | Methods defined here: | | __init__(self, width, text, flexDown=5, flexUp=10, maxHeight=-1) | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from Textbox: | | setHeight(self, height) | | setText(self, text) | | ---------------------------------------------------------------------- | Methods inherited from Widget: | | setCallback(self, obj, data=None) | | ---------------------------------------------------------------------- | Data descriptors inherited from Widget: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class Widget(builtins.object) | Base class for NEWT toolkit - Do not use directly | | methods: | | - Widget(self) | - setCallback(self, obj, data = None) : | The callback for when object activated. | data is passed to obj. | | Methods defined here: | | __init__(self) | Initialize self. See help(type(self)) for accurate signature. | | setCallback(self, obj, data=None) | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) FUNCTIONS ButtonChoiceWindow(screen, title, text, buttons=['Ok', 'Cancel'], width=40, x=None, y=None, help=None) - ButtonChoiceWindow(screen, title, text, buttons = [ 'Ok', 'Cancel' ], width = 40, x = None, y = None, help = None): EntryWindow(screen, title, text, prompts, allowCancel=1, width=40, entryWidth=20, buttons=['Ok', 'Cancel'], help=None) EntryWindow(screen, title, text, prompts, allowCancel = 1, width = 40, entryWidth = 20, buttons = [ 'Ok', 'Cancel' ], help = None): ListboxChoiceWindow(screen, title, text, items, buttons=('Ok', 'Cancel'), width=40, scroll=0, height=-1, default=None, help=None) - ListboxChoiceWindow(screen, title, text, items, buttons = ('Ok', 'Cancel'), width = 40, scroll = 0, height = -1, default = None, help = None): customColorset(x) reflow(text, width, flexDown=5, flexUp=5) returns a tuple of the wrapped text, the actual width, and the actual height DATA CENTER = (0, 0) DOWN = (-1, -1) FD_EXCEPT = 4 FD_READ = 1 FD_WRITE = 2 FLAGS_RESET = 1 FLAGS_SET = 0 FLAGS_TOGGLE = 2 FLAG_DISABLED = 8 LEFT = (-1, 0) RIGHT = (1, 0) UP = (1, 1) absolute_import = _Feature((2, 5, 0, 'alpha', 1), (3, 0, 0, 'alpha', 0... c = '9' colorsets = {'ACTBUTTON': 8, 'ACTCHECKBOX': 10, 'ACTLISTBOX': 14, 'ACT... hotkeys = {'F1': 32869, 'F2': 32870, 'F3': 32871, 'F4': 32872, 'F5': 3... n = ' ' o = 57 print_function = _Feature((2, 6, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0)... snackArgs = {'append': -1} unicode_literals = _Feature((2, 6, 0, 'alpha', 2), (3, 0, 0, 'alpha', ... FILE /usr/lib/python3/dist-packages/snack.py
Generated by phpMan Author: Che Dong Under GNU General Public License
2026-06-02 05:14 @216.73.216.198 CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)