Package nltk :: Package draw :: Class ColorizedList
[hide private]
[frames] | no frames]

Class ColorizedList

source code

object --+
         |
        ColorizedList
Known Subclasses:

An abstract base class for displaying a colorized list of items. Subclasses should define:


Note: Typically, you will want to register a callback for 'select' that calls mark on the given item.

Instance Methods [hide private]
 
__init__(self, parent, items=[], **options)
Construct a new list.
source code
 
_buttonpress(self, event) source code
 
_fire_callback(self, event, itemnum) source code
 
_init_colortags(self, textwidget, options)
Set up any colortags that will be used by this colorized list.
source code
 
_init_itemframe(self, options) source code
 
_item_repr(self, item)
Return a list of (text, colortag) tuples that make up the colorized representation of the item.
source code
 
_keypress(self, event) source code
 
add_callback(self, event, func)
Register a callback function with the list.
source code
 
focus(self) source code
 
get(self, index=None)
Returns: A list of the items contained by this list.
source code
 
grid(self, cnf={}, **kw) source code
 
mark(self, item)
Highlight the given item.
source code
 
markonly(self, item)
Remove any current highlighting, and mark the given item.
source code
 
pack(self, cnf={}, **kw) source code
 
remove_callback(self, event, func=None)
Deregister a callback function.
source code
 
set(self, items)
Modify the list of items contained by this list.
source code
 
unmark(self, item=None)
Remove highlighting from the given item; or from every item, if no item is given.
source code
 
view(self, item)
Adjust the view such that the given item is visible.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, parent, items=[], **options)
(Constructor)

source code 

Construct a new list.

Parameters:
  • parent - The Tk widget that contains the colorized list
  • items - The initial contents of the colorized list.
  • options
Overrides: object.__init__

_init_colortags(self, textwidget, options)

source code 

Set up any colortags that will be used by this colorized list. E.g.:

>>> textwidget.tag_config('terminal', foreground='black')

_item_repr(self, item)

source code 

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.

add_callback(self, event, func)

source code 

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).

get(self, index=None)

source code 
Returns:
A list of the items contained by this list.

mark(self, item)

source code 

Highlight the given item.

Raises:
  • ValueError - If item is not contained in the list.

markonly(self, item)

source code 

Remove any current highlighting, and mark the given item.

Raises:
  • ValueError - If item is not contained in the list.

remove_callback(self, event, func=None)

source code 

Deregister a callback function. If func is none, then all callbacks are removed for the given event.

unmark(self, item=None)

source code 

Remove highlighting from the given item; or from every item, if no item is given.

Raises:
  • ValueError - If item is not contained in the list.
  • KeyError - If item is not marked.

view(self, item)

source code 

Adjust the view such that the given item is visible. If the item is already visible, then do nothing.