Camelot includes editors for various types of fields. Each editor at least supports these features :

  • a set_value method to set a python type as the editor’s value
  • a get_value method to retrieve a python type from the editor
  • the ValueLoading state : an editor has as its value ValueLoading upon construction and

the editor’s value can be set to ValueLoading if the value that should be displayed is not yet available in the GUI thread, but is still on it’s way from the model to the GUI. This means that once set_value( ValueLoading ) is called, get_value() will always return ValueLoading until set_value is called with another argument.

class camelot.view.controls.editors.BoolEditor(parent=None, minimum=-2147483648, maximum=2147483647, nullable=True, field_name='boolean', **kwargs)

Widget for editing a boolean field

class camelot.view.controls.editors.ChartEditor(parent=None, width=50, height=40, dpi=50, field_name='chart', **kwargs)

Editor to display and manipulate matplotlib charts. The editor itself is generic for all kinds of plots, it simply provides the data to be ploted with a set of axes. The data itself should know how exactly to plot itself.


Copy the chart to the clipboard

eventFilter(object, event)

intercept mouse clicks on a chart to show the chart fullscreen


draw the matplotlib figure on the canvas


Popup a print preview dialog for the Chart

set_field_attributes(*args, **kwargs)

Overwrite set_field attributes because a ChartEditor cannot be disabled or have its background color changed


Accepts a camelot.container.chartcontainer.FigureContainer or a camelot.container.chartcontainer.AxesContainer


Show the plot full screen, using the litebox

static show_fullscreen_chart(chart, parent)
Parameters:chart – a chart container
Returns:the widget showing the chart, by default a LiteBoxView
class camelot.view.controls.editors.ChoicesEditor(parent=None, nullable=True, field_name='choices', **kwargs)

A ComboBox aka Drop Down box that can be assigned a list of keys and values

Return type:a list of (value,name) tuples

Get the current value of the combobox

Parameters:choices – a list of (value,name) tuples. name will be displayed in the combobox,

while value will be used within get_value and set_value. This method changes the items in the combo box while preserving the current value, even if this value is not in the new list of choices.


Set the current value of the combobox where value, the name displayed is the one that matches the value in the list set with set_choices

class camelot.view.controls.editors.ColoredFloatEditor(parent, precision=2, reverse=False, neutral=False, option=None, field_name='float', **kwargs)

Widget for editing a float field, with a calculator

class camelot.view.controls.editors.CustomEditor(parent)

Base class for implementing custom editor widgets. This class provides dual state functionality. Each editor should have the posibility to have ValueLoading as its value, specifying that no value has been set yet.

class camelot.view.controls.editors.DateEditor(parent=None, editable=True, nullable=True, field_name='date', **kwargs)

Widget for editing date values

class camelot.view.controls.editors.DateTimeEditor(parent, editable=True, nullable=True, field_name='datetime', **kwargs)

Widget for editing date and time separated and with popups

class camelot.view.controls.editors.FileEditor(parent=None, storage=None, field_name='file', remove_original=False, **kwargs)

Widget for editing File fields


Called inside init, overwrite this method for custom file edit widgets


Slot to be called when a new stored_file has been created by the storage

class camelot.view.controls.editors.FloatEditor(parent, minimum=-1000000000000000.0, maximum=1000000000000000.0, calculator=True, decimal=False, option=None, field_name='float', **kwargs)

Widget for editing a float field, with a calculator button. The calculator button can be turned of with the calculator field attribute.

class camelot.view.controls.editors.ImageEditor(parent=None, storage=None, preview_width=100, preview_height=100, field_name='image', **kwargs)

Editor to view and edit image files, this is a customized implementation of a FileEditor

checkin_byte_array(byte_array, suffix)

Check a byte_array into the storage


Copy the image to the clipboard


Paste an image from the clipboard into the editor

class camelot.view.controls.editors.IntegerEditor(parent=None, minimum=-2147483648, maximum=2147483647, calculator=True, option=None, field_name='integer', **kwargs)

Widget for editing an integer field, with a calculator

Special use cases of the IntegerEditor :

we have a required integer field without a default.

so the model will do set_value( None )

since this is a required field, the user should be able to enter a value, 0 is a legitimate value.

when get_value is called, 0 should be returned if the user has set the editor to 0, and None if the user didn’t touch the editor.

so the editor should make a visual difference between None and 0, so the user can see he didn’t enter something yet

we have a non required integer field without a default

the model will do set_value( None )

the get_value() should return None and not 0. because in case it returns 0, 0 will be written to the db, causing an unneeded update of the db.

class camelot.view.controls.editors.LanguageEditor(parent=None, languages=[], field_name='language', **kwargs)

A ComboBox that shows a list of languages, the editor takes as its value the ISO code of the language

class camelot.view.controls.editors.LocalFileEditor(parent=None, field_name='local_file', directory=False, save_as=False, file_filter='All files (*)', **kwargs)

Widget for browsing local files and directories


Called inside init, overwrite this method for custom file edit widgets

class camelot.view.controls.editors.Many2OneEditor(admin=None, parent=None, editable=True, field_name='manytoone', **kwargs)

Widget for editing many 2 one relations

Returns:a function that returns the selected entity or ValueLoading

or None

search_completions(*args, **kwargs)

Search for object that match text, to fill the list of completions

Returns:a list of tuples of (object_representation, object_getter)

Update the gui

Parameters:value – either ValueLoading, or a function that returns None

or the entity to be shown in the editor

class camelot.view.controls.editors.MonthsEditor(parent=None, editable=True, field_name='months', **kw)


composite months and years editor

class camelot.view.controls.editors.NoteEditor(parent=None, field_name='note', **kwargs)

An editor that behaves like a note, the editor hides itself when there is no text to display

class camelot.view.controls.editors.One2ManyEditor(admin=None, parent=None, create_inline=False, direction='onetomany', field_name='onetomany', **kw)
Parameters:admin – the Admin interface for the objects on the one side of the


Parameters:create_inline – if False, then a new entity will be created within a

new window, if True, it will be created inline

after creating the editor, set_value needs to be called to set the actual data to the editor

class camelot.view.controls.editors.TextBoolEditor(parent=None, yes='Yes', no='No', color_yes=None, color_no=None, **kwargs)
Parameter :
color_yes: string

text-color of the True representation

color_no: string

text-color of the False representation

class camelot.view.controls.editors.WideEditor

Class signaling that an editor, is a wide editor, so it’s label should be displayed on top of the editor and the editor itself should take two columns:

class WideTextLineEditor(TextLineEditor, WideEditor):

will generate a test line editor where the text line takes the whole with of the form

Previous topic


Next topic


This Page