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.
Widget for editing a boolean field
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
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
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
Parameters: | chart – a chart container |
---|---|
Returns: | the widget showing the chart, by default a LiteBoxView |
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
Widget for editing a float field, with a calculator
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.
Widget for editing date values
Widget for editing date and time separated and with popups
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
Widget for editing a float field, with a calculator button. The calculator button can be turned of with the calculator field attribute.
Editor to view and edit image files, this is a customized implementation of a FileEditor
Check a byte_array into the storage
Copy the image to the clipboard
Paste an image from the clipboard into the editor
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.
A ComboBox that shows a list of languages, the editor takes as its value the ISO code of the language
Widget for browsing local files and directories
Called inside init, overwrite this method for custom file edit widgets
Widget for editing many 2 one relations
Returns: | a function that returns the selected entity or ValueLoading |
---|
or None
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
MonthsEditor
composite months and years editor
An editor that behaves like a note, the editor hides itself when there is no text to display
Parameters: | admin – the Admin interface for the objects on the one side of the |
---|
relation
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
Parameter : |
|
---|
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):
pass
will generate a test line editor where the text line takes the whole with of the form