Classes to layout fields on a form. These are mostly used for specifying the form_display attribute in Admin classes, but they can be used on their own as well. Form classes can be used recursive.
Helper class for TabForm to delay the creation of tabs to the moment the tab is shown.
Base Form class to put fields on a form. The base class of a form is a list. So the form itself is nothing more than a list of field names or sub-forms. A form can thus be manipulated using the list’s method such as append or insert.
A form can be converted to a Qt widget by calling its render method.
Forms are defined using the form_display attribute of an Admin class:
class Admin( EntityAdmin ):
form_display = Form( [ 'title', 'short_description',
'release_date' ] )
and takes these parameters :
param content: an iterable with field names or sub-forms to render param columns: the number of columns in which to order the fields.
Remove a field from the form, This function can be used to modify inherited forms.
Parameters: | original_field – the name of the field to be removed |
---|---|
Returns: | True if the field was found and removed |
Parameters: |
|
---|---|
Returns: | a QtGui.QWidget into which the form is rendered |
Replace a field on this form with another field. This function can be used to modify inherited forms.
:param original_field : the name of the field to be replace :param new_field : the name of the new field :return: True if the original field was found and replaced
Put different fields into a grid, without a label. Row or column labels can be added using the Label form:
GridForm([['title', 'short_description'], ['director','release_date']])
Renders a form within a QGroupBox:
class Admin(EntityAdmin):
form_display = GroupBoxForm('Movie', ['title', 'short_description'])
Render different forms in a horizontal box:
form = forms.HBoxForm([['title', 'short_description'], ['director', 'release_date']])
Render a label using a QtGui.QLabel
A stretchable space with zero minimum size, this is able to fill a gap in the form if there are no other items to fill this space.
Render forms within a QtGui.QTabWidget:
from = TabForm([('First tab', ['title', 'short_description']),
('Second tab', ['director', 'release_date'])])
Add a tab to the form
Parameters: |
|
---|
Render different forms or widgets in a vertical box:
form = forms.VBoxForm([['title', 'short_description'], ['director', 'release_date']])
Renders a single widget without its label, typically a one2many widget
Convert a python data structure to a form, using the following rules :
- if structure is an instance of Form, return structure
- if structure is a list, create a Form from this list
This function is mainly used in the Admin class to construct forms out of the form_display attribute