class ColorizedList(object): (source)
Known subclasses: nltk.app.chartparser_app.EdgeList
, nltk.draw.cfg.ProductionList
Constructor: ColorizedList(parent, items, **options)
An abstract base class for displaying a colorized list of items. Subclasses should define:
- _init_colortags, which sets up Text color tags that will be used by the list.
- _item_repr, which returns a list of (text,colortag) tuples that make up the colorized representation of the item.
Note | |
Typically, you will want to register a callback for 'select' that calls mark on the given item. |
Method | __init__ |
Construct a new list. |
Method | add |
Register a callback function with the list. This function will be called whenever the given event occurs. |
Method | focus |
Undocumented |
Method | get |
No summary |
Method | grid |
Undocumented |
Method | mark |
Highlight the given item. :raise ValueError: If item is not contained in the list. |
Method | markonly |
Remove any current highlighting, and mark the given item. :raise ValueError: If item is not contained in the list. |
Method | pack |
Undocumented |
Method | remove |
Deregister a callback function. If func is none, then all callbacks are removed for the given event. |
Method | set |
Modify the list of items contained by this list. |
Method | unmark |
Remove highlighting from the given item; or from every item, if no item is given. :raise ValueError: If item is not contained in the list. :raise KeyError: If item is not marked. |
Method | view |
Adjust the view such that the given item is visible. If the item is already visible, then do nothing. |
Method | _buttonpress |
Undocumented |
Method | _fire |
Undocumented |
Method | _init |
Set up any colortags that will be used by this colorized list. E.g.: |
Method | _init |
Undocumented |
Method | _item |
Return a list of (text, colortag) tuples that make up the colorized representation of the item. Colorized representations may not span multiple lines. I.e., the text strings returned may not contain newline characters. |
Method | _keypress |
Undocumented |
Instance Variable | _callbacks |
Undocumented |
Instance Variable | _itemframe |
Undocumented |
Instance Variable | _items |
Undocumented |
Instance Variable | _marks |
Undocumented |
Instance Variable | _parent |
Undocumented |
Instance Variable | _textscroll |
Undocumented |
Instance Variable | _textwidget |
Undocumented |
Construct a new list.
Parameters | |
parent | The Tk widget that contains the colorized list |
items | The initial contents of the colorized list. |
**options |
Register a callback function with the list. This function will be called whenever the given event occurs.
Parameters | |
event | The event that will trigger the callback function. Valid events are: click1, click2, click3, space, return, select, up, down, next, prior, move |
func | The function that should be called when the event occurs. func will be called with a single item as its argument. (The item selected or the item moved to). |
Remove any current highlighting, and mark the given item. :raise ValueError: If item is not contained in the list.
Deregister a callback function. If func is none, then all callbacks are removed for the given event.
Remove highlighting from the given item; or from every item, if no item is given. :raise ValueError: If item is not contained in the list. :raise KeyError: If item is not marked.
Adjust the view such that the given item is visible. If the item is already visible, then do nothing.
nltk.app.chartparser_app.EdgeList
, nltk.draw.cfg.ProductionList
Set up any colortags that will be used by this colorized list. E.g.:
>>> textwidget.tag_config('terminal', foreground='black')
nltk.app.chartparser_app.EdgeList
, nltk.draw.cfg.ProductionList
Return a list of (text, colortag) tuples that make up the colorized representation of the item. Colorized representations may not span multiple lines. I.e., the text strings returned may not contain newline characters.