In Progress: Tkinter 3000 Form Library
February 2003 | Fredrik Lundh
Note: This design note discusses features that may be added to a future release of the Tkinter 3000 library.
The Tkinter 3000 Form Library (aka Form Construction Kit) allows you to create entry forms and dialogues, and attach them to existing Python data models.
The Form Library provides a single form widget, which manages a number of subviews attached to a single model object. In addition to the subviews, the form widget can also draw decorations (including captions, borders, and help panels).
from WCK.Form import FormWidget form_content = ... form_model = ... form = FormWidget(root, form=form_content, model=form_model) form.pack()
The Form Widget
The form widget class provides a form view that handles editor subviews, and decorations.
The exact look of a subview depends on two things; the view category, and the target data type.
The Input Category
Free-form data entry. Views in this category are usually rendered as single-line entry fields, but can also be rendered as a checkboxes (for boolean data) or using custom widgets (e.g. a color selector).
The TextArea Category
Free-form data entry, intended for entering multiline content.
The Trigger Category
User-triggered operations. Views in this category are usually rendered as buttons.
The Range Category
Selection from a sequential range of values, usually rendered as a slider.
The Select and SingleSelect Category
Selection from a set of choices, usually rendered as a list, a combobox, or a group of radiobuttons or checkboxes.
Selections may use two model variables; one for the current selection, and one for the list of possible choices.
The Form Model Interface
The form model class must implement the following four methods:
- get(key) => value
Get current value for the given key. The method should return a string, or an object that can be converted to a string.
- set(key, value)
Set value for the given key.
Add an observer to this model. The observer implements the simple observer protocol.
Remove an observer from this model.
The FCK provides a standard model, based on a standard Python dictionary.