editors

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=-2147483647, 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_to_clipboard()

Copy the chart to the clipboard

eventFilter(object, event)

intercept mouse clicks on a chart to show the chart fullscreen

on_draw()

draw the matplotlib figure on the canvas

print_preview()

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

set_value(value)

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

show_fullscreen()

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', actions=[], **kwargs)

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

static append_item(model, data)

Append an item in a combobox model :param data: a dictionary mapping roles to values

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

Get the current value of the combobox

set_choices(choices)
Parameters:choices – a list of (value,name) tuples or a list of dicts.

In case a list of tuples is used, name will be displayed in the combobox, while value will be used within get_value() and set_value().

In case a list of dicts is used, the keys of the dict are used as the roles, and the values as the value for that role, where Qt.UserRole is the value that is passed through get_value(), eg : {Qt.DisplayRole: “Hello”, Qt.UserRole: 1}

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. If there is no item with value None in the list of choices, this will be added.

set_value(value, display_role=None)

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

Parameters:display_role – this is the name used to display the value in case the value is not in the list of choices. If this is None, the string representation of the value is used.
class camelot.view.controls.editors.ColorEditor(parent=None, editable=True, field_name='color', **kwargs)

This editor alows the user to select a color. When the selected color is completely transparent, the value of the editor will be None.

class camelot.view.controls.editors.CustomEditor(parent, column_width=None)

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', validator=<camelot.view.validator.DateValidator object at 0x10df353e0>, **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, actions=[<camelot.admin.action.field_action.DetachFile object at 0x10f33b950>, <camelot.admin.action.field_action.OpenFile object at 0x10f33b990>, <camelot.admin.action.field_action.UploadFile object at 0x10f33b9d0>, <camelot.admin.action.field_action.SaveFile object at 0x10f33ba10>], **kwargs)

Widget for editing File fields

setup_widget()

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

class camelot.view.controls.editors.FloatEditor(parent, minimum=-999999999999999.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_to_clipboard()

Copy the image to the clipboard

paste_from_clipboard()

Paste an image from the clipboard into the editor

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

Widget for editing an integer field, with a calculator

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

setup_widget()

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', actions=[<camelot.admin.action.field_action.ClearObject object at 0x10f483410>, <camelot.admin.action.field_action.SelectObject object at 0x10f483590>, <camelot.admin.action.field_action.NewObject object at 0x10f4837d0>, <camelot.admin.action.field_action.OpenObject object at 0x10f483d90>], **kwargs)

Widget for editing many 2 one relations

get_value()
Returns:a function that returns the selected entity or ValueLoading

or None

search_completions(text)

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

Returns:a list of tuples of (dict_of_object_representation, object)
set_instance_representation(representation_and_propagate)

Update the gui

set_value(value)
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)

MonthsEditor

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. The default background color of the not is yellow, but can be changed through the background_color field attribute.

class camelot.view.controls.editors.One2ManyEditor(admin=None, parent=None, create_inline=False, direction='onetomany', field_name='onetomany', column_width=None, proxy=None, rows=5, **kw)
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

Parameters:
  • proxy – the proxy class to use to present the data in the list or the query to the table view
  • column_width – the width of the editor in number of characters
  • rows – minimum number of rows visible

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

get_model()
Returns:a QtGui.QAbstractItemModel or None
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):
  pass

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