source | issues
from flatland import Form, Dict, String, Integer, Boolean
from flatland.validation import ValueAtLeast, ValueAtMost

from pygtkhelpers.forms import FormView


class PersonSchema(Form):

    name = String

    age = Integer.using(validators=[
        ValueAtLeast(minimum=18),
        ValueAtMost(maximum=120)
    ])

    weight = Integer.using(validators=[
        ValueAtLeast(minimum=0),
        ValueAtMost(maximum=300)
    ])
    weight.render_options = dict(
        style='slider'
    )

    friendly = Boolean

    address = String.using()
    address.render_options = dict(
        style='multiline'
    )

    happy = Boolean.using()
    happy.render_options = dict(
        style='toggle'
    )


class PersonView(FormView):

    schema_type = PersonSchema

if __name__ == '__main__':
    PersonView().show_and_run()
../_images/simpleform.png

The resulting form

../_images/pygtkhelpers_forms.png

pygtkhelpers.forms

Providing specialized delegates that can be used to map and validate against schemas. Validation and schema support is provided by Flatland_.

copyright:2005-2008 by pygtkhelpers Authors
license:LGPL 2 or later (see README/COPYING/LICENSE)
class pygtkhelpers.forms.Field(element, widget, label_widget=None)

Encapsulates the widget and the label display

class pygtkhelpers.forms.FormView

A specialized delegate that adds widget proxying and schema support

class pygtkhelpers.forms.WidgetBuilder(widget_type)

Defer widget building to allow post-configuration

pygtkhelpers.forms.element_views

Map of flatland element types to view types

pygtkhelpers.forms.view_widgets

map of view types to flatland element types

pygtkhelpers.forms.widget_for(element)

Create a widget for a schema item