### Navigation

- index
- modules |
- next |
- previous |
- Camelot documentation »
- Camelot API »
- view »
- controls »

# 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=-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_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', **kwargs)

  A ComboBox aka Drop Down box that can be assigned a list of keys and 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. 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_value`(value)

    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.``EmbeddedMany2OneEditor`(admin=None, parent=None, field_name='embedded', size_policy=<PyQt4.QtGui.QSizePolicy object at 0x9f71bfc>, **kwargs)

  Widget for editing a many 2 one relation a a form embedded in another form.

  @todo: properly take care of making the form editable or not, simply enabling or disabling the widget as a whole is not functional, since tabs don’t work in that case

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

  Widget for editing File fields

  `setup_widget`()

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

  `stored_file_ready`(stored_file)

    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_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=-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

  `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', **kwargs)

  Widget for editing many 2 one relations

  `get_value`()

    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)

  `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

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

- abstractmanytooneeditor
- booleditor
- charteditor
- choiceseditor
- codeeditor
- coloredfloateditor
- coloreditor
- customeditor
- dateeditor
- datetimeeditor
- embeddedmany2oneeditor
- fileeditor
- floateditor
- imageeditor
- integereditor
- labeleditor
- languageeditor
- localfileeditor
- many2oneeditor
- manytomanyeditor
- monthseditor
- noteeditor
- one2manyeditor
- onetomanychoiceseditor
- richtexteditor
- smileyeditor
- stareditor
- textediteditor
- textlineeditor
- timeeditor
- virtualaddresseditor
- wideeditor

### Navigation

- index
- modules |
- next |
- previous |
- Camelot documentation »
- Camelot API »
- view »
- controls »

Comments
blog comments powered by Disqus