editors Package

editors Package

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)

Bases: PyQt4.QtGui.QCheckBox, camelot.view.controls.editors.customeditor.AbstractCustomEditor

Widget for editing a boolean field

editingFinished
get_value()
set_enabled(editable=True)
set_value(value)
sizeHint()
class camelot.view.controls.editors.ChartEditor(parent=None, width=50, height=40, dpi=50, field_name='chart', **kwargs)

Bases: PyQt4.QtGui.QFrame, camelot.view.controls.editors.customeditor.CustomEditor, camelot.view.controls.editors.wideeditor.WideEditor

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

editingFinished
eventFilter(object, event)

intercept mouse clicks on a chart to show the chart fullscreen

on_draw()

draw the matplotlib figure on the canvas

on_paint_request(printer)
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
show_fullscreen_signal
class camelot.view.controls.editors.ChoicesEditor(parent=None, nullable=True, field_name='choices', **kwargs)

Bases: PyQt4.QtGui.QComboBox, camelot.view.controls.editors.customeditor.AbstractCustomEditor

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

editingFinished
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_field_attributes(editable=True, choices=None, **kwargs)
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

valueChanged
class camelot.view.controls.editors.CodeEditor(parent=None, parts=['99', 'AA'], editable=True, field_name='code', **kwargs)

Bases: camelot.view.controls.editors.customeditor.CustomEditor

emit_editing_finished()
get_value()
set_background_color(background_color)
set_enabled(editable=True)
set_field_attributes(editable=True, background_color=None, tooltip=None, **kwargs)
set_value(value)
class camelot.view.controls.editors.ColoredFloatEditor(parent, precision=2, reverse=False, neutral=False, option=None, field_name='float', **kwargs)

Bases: camelot.view.controls.editors.customeditor.CustomEditor

Widget for editing a float field, with a calculator

calculation_finished(value)
calculator_icon = Icon('tango/16x16/apps/accessories-calculator.png')
get_value()
go_down_blue = Icon('tango/16x16/actions/go-down-blue.png')
go_down_red = Icon('tango/16x16/actions/go-down-red.png')
go_up = Icon('tango/16x16/actions/go-up.png')
go_up_blue = Icon('tango/16x16/actions/go-up-blue.png')
popupCalculator(value)
set_background_color(background_color)
set_enabled(editable=True)
set_field_attributes(editable=True, background_color=None, tooltip=None, prefix='', suffix='', minimum=-1000000000000000.0, maximum=1000000000000000.0, single_step=1.0, **kwargs)
set_value(value)
spinbox_editing_finished()
zero = Icon('tango/16x16/actions/zero.png')
class camelot.view.controls.editors.ColorEditor(parent=None, editable=True, field_name='color', **kwargs)

Bases: camelot.view.controls.editors.customeditor.CustomEditor

buttonClicked(raised)
getColor()
get_value()
setColor(color)
set_enabled(editable=True)
set_value(value)
class camelot.view.controls.editors.CustomEditor(parent)

Bases: PyQt4.QtGui.QWidget, camelot.view.controls.editors.customeditor.AbstractCustomEditor

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.

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

Bases: camelot.view.controls.editors.customeditor.CustomEditor

Widget for editing date values

calendar_action_trigger
calendar_widget_activated(date)
focusOutEvent(event)
get_value()
line_edit_finished()
set_background_color(background_color)
set_enabled(editable=True)
set_field_attributes(editable=True, background_color=None, tooltip=None, **kwargs)
set_special_date(action)
set_value(value)
special_date_icon = Icon('tango/16x16/apps/office-calendar.png')
text_edited(text)
class camelot.view.controls.editors.DateTimeEditor(parent, editable=True, nullable=True, field_name='datetime', **kwargs)

Bases: camelot.view.controls.editors.customeditor.CustomEditor

Widget for editing date and time separated and with popups

date()
editing_finished(_arg=None)
get_value()
set_background_color(background_color)
set_enabled(editable=True)
set_field_attributes(editable=True, background_color=None, tooltip=None, **kwargs)
set_value(value)
time()
class camelot.view.controls.editors.EmbeddedMany2OneEditor(admin=None, parent=None, field_name='embedded', size_policy=<PyQt4.QtGui.QSizePolicy object at 0x9f71bfc>, **kwargs)

Bases: camelot.view.controls.editors.customeditor.CustomEditor, camelot.view.controls.editors.wideeditor.WideEditor

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

setEntity(entity_instance_getter, propagate=True)
set_field_attributes(editable=True, **kwargs)
set_value(value)
update_form(update_form_and_propagate)
class camelot.view.controls.editors.FileEditor(parent=None, storage=None, field_name='file', remove_original=False, **kwargs)

Bases: camelot.view.controls.editors.customeditor.CustomEditor

Widget for editing File fields

clear_button_clicked()
clear_icon = Icon('tango/16x16/actions/edit-delete.png')
document_pixmap = Icon('tango/16x16/mimetypes/x-office-document.png')
dragEnterEvent(event)
dragMoveEvent(event)
dropEvent(event)
file_completion_activated(index)
filter = 'All files (*)'
get_value()
new_icon = Icon('tango/16x16/actions/list-add.png')
open_button_clicked()
open_icon = Icon('tango/16x16/actions/document-open.png')
save_as_button_clicked()
save_as_icon = Icon('tango/16x16/actions/document-save-as.png')
set_enabled(editable=True)
set_field_attributes(editable=True, background_color=None, tooltip=None, remove_original=False, **kwargs)
set_tab_order()
set_value(value)
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)

Bases: camelot.view.controls.editors.customeditor.CustomEditor

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

calculation_finished(value)
calculator_icon = Icon('tango/16x16/apps/accessories-calculator.png')
get_value()
popupCalculator(value)
set_background_color(background_color)
set_enabled(editable=True)
set_field_attributes(editable=True, background_color=None, tooltip=None, prefix='', suffix='', precision=2, single_step=1.0, **kwargs)
set_value(value)
spinbox_editing_finished()
class camelot.view.controls.editors.ImageEditor(parent=None, storage=None, preview_width=100, preview_height=100, field_name='image', **kwargs)

Bases: camelot.view.controls.editors.fileeditor.FileEditor, camelot.view.controls.editors.wideeditor.WideEditor

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

clear_image()
clipboard_data_changed()
copy_to_clipboard()

Copy the image to the clipboard

draw_border()
eventFilter(object, event)
filter = 'Image files (*.bmp *.jpg *.jpeg *.mng *.png *.pbm *.pgm *.ppm\n*.tiff *.xbm *.xpm) All files (*)'
paste_from_clipboard()

Paste an image from the clipboard into the editor

set_enabled(editable=True)
set_image(image)
set_image_to_clipboard(image)
set_pixmap(pixmap)
set_value(value)
setup_widget()
show_fullscreen(image)
class camelot.view.controls.editors.IntegerEditor(parent=None, minimum=-2147483648, maximum=2147483647, calculator=True, option=None, field_name='integer', **kwargs)

Bases: camelot.view.controls.editors.customeditor.CustomEditor

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.

calculation_finished(value)
calculator_icon = Icon('tango/16x16/apps/accessories-calculator.png')
get_value()
popupCalculator(value)
set_enabled(editable=True)
set_field_attributes(editable=True, background_color=None, tooltip=None, prefix='', suffix='', nullable=True, single_step=1, **kwargs)
set_value(value)
spinbox_editing_finished()
class camelot.view.controls.editors.LabelEditor(parent=None, text='<loading>', field_name='label', **kwargs)

Bases: PyQt4.QtGui.QLabel, camelot.view.controls.editors.customeditor.AbstractCustomEditor

editingFinished
paintEvent(event)
set_field_attributes(editable=True, background_color=None, tooltip=None, **kwargs)
set_value(value)
class camelot.view.controls.editors.LanguageEditor(parent=None, languages=[], field_name='language', **kwargs)

Bases: PyQt4.QtGui.QComboBox, camelot.view.controls.editors.customeditor.AbstractCustomEditor

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

editingFinished
get_value()
language_choices = []
set_value(value)
class camelot.view.controls.editors.LocalFileEditor(parent=None, field_name='local_file', directory=False, save_as=False, file_filter='All files (*)', **kwargs)

Bases: camelot.view.controls.editors.customeditor.CustomEditor

Widget for browsing local files and directories

browse_button_clicked()
browse_icon = Icon('tango/16x16/places/folder-saved-search.png')
filename_editing_finished()
get_value()
set_field_attributes(editable=True, background_color=None, tooltip=None, **kwargs)
set_value(value)
setup_widget()

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

class camelot.view.controls.editors.ManyToManyEditor(admin=None, parent=None, create_inline=False, vertical_header_clickable=True, field_name='onetomany', **kw)

Bases: camelot.view.controls.editors.one2manyeditor.One2ManyEditor, camelot.view.controls.editors.abstractmanytooneeditor.AbstractManyToOneEditor

add_icon = Icon('tango/16x16/actions/list-add.png')
emit_editing_finished(*args)
removeSelectedRows()

Remove the selected rows in this tableview, but don’t delete them

remove_icon = Icon('tango/16x16/actions/list-remove.png')
selectEntity(entity_instance_getter)
set_field_attributes(editable=True, **kwargs)
setupButtons(layout, _table)
class camelot.view.controls.editors.Many2OneEditor(admin=None, parent=None, editable=True, field_name='manytoone', **kwargs)

Bases: camelot.view.controls.editors.customeditor.CustomEditor, camelot.view.controls.editors.abstractmanytooneeditor.AbstractManyToOneEditor

Widget for editing many 2 one relations

class CompletionsModel(parent=None)

Bases: PyQt4.QtCore.QAbstractListModel

columnCount(index=None)
data(index, role)
rowCount(index=None)
setCompletions(completions)
Many2OneEditor.arrow_down_key_pressed
Many2OneEditor.completionActivated(index)
Many2OneEditor.completion_highlighted(index)
Many2OneEditor.createFormView()
Many2OneEditor.createNew(*args, **kwargs)
Many2OneEditor.dataChanged(index1, index2)
Many2OneEditor.display_search_completions(*args, **kwargs)
Many2OneEditor.get_value()
Returns:a function that returns the selected entity or ValueLoading

or None

Many2OneEditor.new_icon = Icon('tango/16x16/actions/document-new.png')
Many2OneEditor.on_arrow_down_key_pressed()
Many2OneEditor.openButtonClicked()
Many2OneEditor.returnPressed()
Many2OneEditor.searchButtonClicked()
Many2OneEditor.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)
Many2OneEditor.search_icon = Icon('tango/16x16/actions/system-search.png')
Many2OneEditor.search_input_editing_finished()
Many2OneEditor.selectEntity(entity_instance_getter)
Many2OneEditor.setEntity(entity_instance_getter, propagate=True)
Many2OneEditor.set_editable(editable)
Many2OneEditor.set_field_attributes(editable=True, background_color=None, tooltip=None, **kwargs)
Many2OneEditor.set_instance_representation(representation_and_propagate)

Update the gui

Many2OneEditor.set_value(value)
Parameters:value – either ValueLoading, or a function that returns None

or the entity to be shown in the editor

Many2OneEditor.show_form_view(admin_and_title)
Many2OneEditor.show_new_view(*args, **kwargs)
Many2OneEditor.textEdited(text)
Many2OneEditor.trashButtonClicked()
class camelot.view.controls.editors.MonthsEditor(parent=None, editable=True, field_name='months', **kw)

Bases: camelot.view.controls.editors.customeditor.CustomEditor

MonthsEditor

composite months and years editor

get_value()
set_enabled(editable=True)
set_field_attributes(editable=True, background_color=None, tooltip=None, **kwargs)
set_value(value)
class camelot.view.controls.editors.NoteEditor(parent=None, field_name='note', **kwargs)

Bases: PyQt4.QtGui.QLabel, camelot.view.controls.editors.customeditor.AbstractCustomEditor

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

editingFinished
set_value(value)
class camelot.view.controls.editors.One2ManyEditor(admin=None, parent=None, create_inline=False, vertical_header_clickable=True, field_name='onetomany', **kw)

Bases: camelot.view.controls.editors.customeditor.CustomEditor, camelot.view.controls.editors.wideeditor.WideEditor

activate_editor(*args, **kwargs)
copy_icon = Icon('tango/16x16/actions/edit-copy.png')
createFormForIndex(index)
delete_icon = Icon('tango/16x16/places/user-trash.png')
exportToExcel()
getModel()
newRow()
new_icon = Icon('tango/16x16/actions/document-new.png')
set_field_attributes(editable=True, new_message=None, **kwargs)
set_value(model)
setupButtons(layout, table)
spreadsheet_icon = Icon('tango/16x16/mimetypes/x-office-spreadsheet.png')
update_delegates(*args)
class camelot.view.controls.editors.OneToManyChoicesEditor(parent, target=None, nullable=True, field_name='onetomanychoices', **kwargs)

Bases: camelot.view.controls.editors.choiceseditor.ChoicesEditor

get_choices()
set_field_attributes(editable=True, **kwargs)

Makes sure choices are not reset when changing the field attributes

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

Bases: camelot.view.controls.editors.customeditor.CustomEditor, camelot.view.controls.editors.wideeditor.WideEditor

emit_editing_finished()
get_value()
initToolbar()
set_aligncenter(bool)
set_alignleft(bool)
set_alignright(bool)
set_bold()
set_color()
set_editable(editable)
set_field_attributes(editable=True, background_color=None, **kwargs)
set_italic(bool)
set_underline(bool)
set_value(value)
update_alignment(al=None)
update_color()
update_format(format)
update_text()
class camelot.view.controls.editors.StarEditor(parent, maximum=5, editable=True, field_name='star', **kwargs)

Bases: camelot.view.controls.editors.customeditor.CustomEditor

get_value()
no_star_icon = Icon('tango/16x16/status/weather-clear-noStar.png')
set_background_color(background_color)
set_enabled(editable=True)
set_value(value)
starClick(value)
star_icon = Icon('tango/16x16/status/weather-clear.png')
class camelot.view.controls.editors.TextLineEditor(parent, length=20, field_name='text_line', **kwargs)

Bases: PyQt4.QtGui.QLineEdit, camelot.view.controls.editors.customeditor.AbstractCustomEditor

get_value()
paintEvent(event)
set_enabled(editable=True)
set_field_attributes(editable=True, background_color=None, tooltip=None, **kwargs)
set_value(value)
class camelot.view.controls.editors.TimeEditor(parent, editable=True, field_name='time', format='hh:mm', **kwargs)

Bases: PyQt4.QtGui.QTimeEdit, camelot.view.controls.editors.customeditor.AbstractCustomEditor

get_value()
paintEvent(event)
set_background_color(background_color)
set_enabled(editable=True)
set_field_attributes(editable=True, background_color=None, tooltip=None, **kwargs)
set_value(value)
class camelot.view.controls.editors.VirtualAddressEditor(parent=None, editable=True, address_type=None, address_validator=<function default_address_validator at 0x9e688b4>, field_name='virtual_address', **kwargs)

Bases: camelot.view.controls.editors.customeditor.CustomEditor

checkValue(text)
comboIndexChanged()
editorValueChanged(text)
emit_editing_finished()
get_value()
mail_click()
set_background_color(background_color)
set_enabled(editable=True)
set_field_attributes(editable=True, background_color=None, tooltip=None, **kwargs)
set_value(value)
class camelot.view.controls.editors.SmileyEditor(parent, editable=True, icons=[('face-angel', Icon('tango/16x16/emotes/face-angel.png')), ('face-crying', Icon('tango/16x16/emotes/face-crying.png')), ('face-devilish', Icon('tango/16x16/emotes/face-devilish.png')), ('face-glasses', Icon('tango/16x16/emotes/face-glasses.png')), ('face-grin', Icon('tango/16x16/emotes/face-grin.png')), ('face-kiss', Icon('tango/16x16/emotes/face-kiss.png')), ('face-monkey', Icon('tango/16x16/emotes/face-monkey.png')), ('face-plain', Icon('tango/16x16/emotes/face-plain.png')), ('face-sad', Icon('tango/16x16/emotes/face-sad.png')), ('face-smile', Icon('tango/16x16/emotes/face-smile.png')), ('face-smile-big', Icon('tango/16x16/emotes/face-smile-big.png')), ('face-surprise', Icon('tango/16x16/emotes/face-surprise.png')), ('face-wink', Icon('tango/16x16/emotes/face-wink.png'))], field_name='icons', **kwargs)

Bases: camelot.view.controls.editors.customeditor.CustomEditor

get_value()
set_enabled(editable=True)
set_value(value)
smiley_changed()
class camelot.view.controls.editors.TextBoolEditor(parent=None, yes='Yes', no='No', color_yes=None, color_no=None, **kwargs)

Bases: PyQt4.QtGui.QLabel, camelot.view.controls.editors.customeditor.AbstractCustomEditor

Parameter :
color_yes: string

text-color of the True representation

color_no: string

text-color of the False representation

editingFinished
set_value(value)
class camelot.view.controls.editors.TextEditEditor(parent, length=20, editable=True, field_name='text', **kwargs)

Bases: PyQt4.QtGui.QTextEdit, camelot.view.controls.editors.customeditor.AbstractCustomEditor, camelot.view.controls.editors.wideeditor.WideEditor

editingFinished
get_value()
set_enabled(editable=True)
set_value(value)
class camelot.view.controls.editors.WideEditor

Bases: object

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 Module

class camelot.view.controls.editors.abstractmanytooneeditor.AbstractManyToOneEditor[source]

Bases: object

Helper functions for implementing a ManyToOneEditor, to be used in the ManyToOneEditor and in the ManyToManyEditor

createSelectView()[source]
selectEntity(entity_instance_getter)[source]

booleditor Module

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

Bases: PyQt4.QtGui.QCheckBox, camelot.view.controls.editors.customeditor.AbstractCustomEditor

Widget for editing a boolean field

editingFinished
get_value()[source]
set_enabled(editable=True)[source]
set_value(value)[source]
sizeHint()[source]
class camelot.view.controls.editors.booleditor.TextBoolEditor(parent=None, yes='Yes', no='No', color_yes=None, color_no=None, **kwargs)[source]

Bases: PyQt4.QtGui.QLabel, camelot.view.controls.editors.customeditor.AbstractCustomEditor

Parameter :
color_yes: string

text-color of the True representation

color_no: string

text-color of the False representation

editingFinished
set_value(value)[source]

charteditor Module

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

Bases: PyQt4.QtGui.QFrame, camelot.view.controls.editors.customeditor.CustomEditor, camelot.view.controls.editors.wideeditor.WideEditor

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()[source]

Copy the chart to the clipboard

editingFinished
eventFilter(object, event)[source]

intercept mouse clicks on a chart to show the chart fullscreen

on_draw()[source]

draw the matplotlib figure on the canvas

on_paint_request(printer)[source]
print_preview()[source]

Popup a print preview dialog for the Chart

set_field_attributes(*args, **kwargs)[source]

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

set_value(value)[source]

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

show_fullscreen()[source]

Show the plot full screen, using the litebox

static show_fullscreen_chart(chart, parent)[source]
Parameters:chart – a chart container
Returns:the widget showing the chart, by default a LiteBoxView
show_fullscreen_signal

choiceseditor Module

class camelot.view.controls.editors.choiceseditor.ChoicesEditor(parent=None, nullable=True, field_name='choices', **kwargs)[source]

Bases: PyQt4.QtGui.QComboBox, camelot.view.controls.editors.customeditor.AbstractCustomEditor

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

editingFinished
get_choices()[source]
Return type:a list of (value,name) tuples
get_value()[source]

Get the current value of the combobox

set_choices(choices)[source]
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_field_attributes(editable=True, choices=None, **kwargs)[source]
set_value(value)[source]

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

valueChanged

codeeditor Module

class camelot.view.controls.editors.codeeditor.CodeEditor(parent=None, parts=['99', 'AA'], editable=True, field_name='code', **kwargs)[source]

Bases: camelot.view.controls.editors.customeditor.CustomEditor

emit_editing_finished()[source]
get_value()[source]
set_background_color(background_color)[source]
set_enabled(editable=True)[source]
set_field_attributes(editable=True, background_color=None, tooltip=None, **kwargs)[source]
set_value(value)[source]
class camelot.view.controls.editors.codeeditor.PartEditor(mask, max_length, first=False, last=False)[source]

Bases: PyQt4.QtGui.QLineEdit

focusInEvent(event)[source]
focusOutEvent(event)[source]
paintEvent(event)[source]
text_edited(text)[source]

coloredfloateditor Module

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

Bases: camelot.view.controls.editors.customeditor.CustomEditor

Widget for editing a float field, with a calculator

calculation_finished(value)[source]
calculator_icon = Icon('tango/16x16/apps/accessories-calculator.png')
get_value()[source]
go_down_blue = Icon('tango/16x16/actions/go-down-blue.png')
go_down_red = Icon('tango/16x16/actions/go-down-red.png')
go_up = Icon('tango/16x16/actions/go-up.png')
go_up_blue = Icon('tango/16x16/actions/go-up-blue.png')
popupCalculator(value)[source]
set_background_color(background_color)[source]
set_enabled(editable=True)[source]
set_field_attributes(editable=True, background_color=None, tooltip=None, prefix='', suffix='', minimum=-1000000000000000.0, maximum=1000000000000000.0, single_step=1.0, **kwargs)[source]
set_value(value)[source]
spinbox_editing_finished()[source]
zero = Icon('tango/16x16/actions/zero.png')

coloreditor Module

class camelot.view.controls.editors.coloreditor.ColorEditor(parent=None, editable=True, field_name='color', **kwargs)[source]

Bases: camelot.view.controls.editors.customeditor.CustomEditor

buttonClicked(raised)[source]
getColor()[source]
get_value()[source]
setColor(color)[source]
set_enabled(editable=True)[source]
set_value(value)[source]

customeditor Module

class camelot.view.controls.editors.customeditor.AbstractCustomEditor[source]

Bases: object

Helper class to be used to build custom editors. This class provides functionality to store and retrieve ValueLoading as an editor’s value.

Guidelines for implementing CustomEditors :

  • When an editor consists of multiple widgets, one widget must be the focusProxy of the editor, to have that widget immediately activated when the user single clicks in the table view.
  • When an editor has widgets that should not get selected when the user tabs through the editor, setFocusPolicy(Qt.ClickFocus) should be called on those widgets.
get_height()[source]
get_value()[source]
set_background_color(background_color)[source]
set_field_attributes(editable=True, background_color=None, tooltip='', **kwargs)[source]
set_value(value)[source]
class camelot.view.controls.editors.customeditor.CustomEditor(parent)[source]

Bases: PyQt4.QtGui.QWidget, camelot.view.controls.editors.customeditor.AbstractCustomEditor

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.

editingFinished
paintEvent(event)[source]
valueChanged
camelot.view.controls.editors.customeditor.draw_tooltip_visualization(widget)[source]

Draws a small visual indication in the top-left corner of a widget. :param widget: a QWidget

camelot.view.controls.editors.customeditor.set_background_color_palette(widget, background_color)[source]

Set the palette of a widget to have a cerain background color. :param widget: a QWidget :param background_color: a QColor

dateeditor Module

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

Bases: camelot.view.controls.editors.customeditor.CustomEditor

Widget for editing date values

calendar_action_trigger
calendar_widget_activated(date)[source]
focusOutEvent(event)[source]
get_value()[source]
line_edit_finished()[source]
set_background_color(background_color)[source]
set_enabled(editable=True)[source]
set_field_attributes(editable=True, background_color=None, tooltip=None, **kwargs)[source]
set_special_date(action)[source]
set_value(value)[source]
special_date_icon = Icon('tango/16x16/apps/office-calendar.png')
text_edited(text)[source]

datetimeeditor Module

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

Bases: camelot.view.controls.editors.customeditor.CustomEditor

Widget for editing date and time separated and with popups

date()[source]
editing_finished(_arg=None)[source]
get_value()[source]
set_background_color(background_color)[source]
set_enabled(editable=True)[source]
set_field_attributes(editable=True, background_color=None, tooltip=None, **kwargs)[source]
set_value(value)[source]
time()[source]
class camelot.view.controls.editors.datetimeeditor.TimeValidator(parent, nullable)[source]

Bases: PyQt4.QtGui.QValidator

validate(input, pos)[source]

embeddedmany2oneeditor Module

class camelot.view.controls.editors.embeddedmany2oneeditor.EmbeddedMany2OneEditor(admin=None, parent=None, field_name='embedded', size_policy=<PyQt4.QtGui.QSizePolicy object at 0x9f71bfc>, **kwargs)[source]

Bases: camelot.view.controls.editors.customeditor.CustomEditor, camelot.view.controls.editors.wideeditor.WideEditor

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

setEntity(entity_instance_getter, propagate=True)[source]
set_field_attributes(editable=True, **kwargs)[source]
set_value(value)[source]
update_form(update_form_and_propagate)[source]

fileeditor Module

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

Bases: camelot.view.controls.editors.customeditor.CustomEditor

Widget for editing File fields

clear_button_clicked()[source]
clear_icon = Icon('tango/16x16/actions/edit-delete.png')
document_pixmap = Icon('tango/16x16/mimetypes/x-office-document.png')
dragEnterEvent(event)[source]
dragMoveEvent(event)[source]
dropEvent(event)[source]
file_completion_activated(index)[source]
filter = 'All files (*)'
get_value()[source]
new_icon = Icon('tango/16x16/actions/list-add.png')
open_button_clicked()[source]
open_icon = Icon('tango/16x16/actions/document-open.png')
save_as_button_clicked()[source]
save_as_icon = Icon('tango/16x16/actions/document-save-as.png')
set_enabled(editable=True)[source]
set_field_attributes(editable=True, background_color=None, tooltip=None, remove_original=False, **kwargs)[source]
set_tab_order()[source]
set_value(value)[source]
setup_widget()[source]

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

stored_file_ready(stored_file)[source]

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

floateditor Module

class camelot.view.controls.editors.floateditor.CustomDoubleSpinBox(option=None, parent=None)[source]

Bases: PyQt4.QtGui.QDoubleSpinBox

Spinbox that doesn’t accept mouse scrolling as input

keyPressEvent(key_event)[source]
paintEvent(event)[source]
textFromValue(value)[source]
wheelEvent(wheel_event)[source]
class camelot.view.controls.editors.floateditor.FloatEditor(parent, minimum=-1000000000000000.0, maximum=1000000000000000.0, calculator=True, decimal=False, option=None, field_name='float', **kwargs)[source]

Bases: camelot.view.controls.editors.customeditor.CustomEditor

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

calculation_finished(value)[source]
calculator_icon = Icon('tango/16x16/apps/accessories-calculator.png')
get_value()[source]
popupCalculator(value)[source]
set_background_color(background_color)[source]
set_enabled(editable=True)[source]
set_field_attributes(editable=True, background_color=None, tooltip=None, prefix='', suffix='', precision=2, single_step=1.0, **kwargs)[source]
set_value(value)[source]
spinbox_editing_finished()[source]

imageeditor Module

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

Bases: camelot.view.controls.editors.fileeditor.FileEditor, camelot.view.controls.editors.wideeditor.WideEditor

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

checkin_byte_array(byte_array, suffix)[source]

Check a byte_array into the storage

clear_image()[source]
clipboard_data_changed()[source]
copy_to_clipboard()[source]

Copy the image to the clipboard

draw_border()[source]
eventFilter(object, event)[source]
filter = 'Image files (*.bmp *.jpg *.jpeg *.mng *.png *.pbm *.pgm *.ppm\n*.tiff *.xbm *.xpm) All files (*)'
paste_from_clipboard()[source]

Paste an image from the clipboard into the editor

set_enabled(editable=True)[source]
set_image(image)[source]
set_image_to_clipboard(image)[source]
set_pixmap(pixmap)[source]
set_value(value)[source]
setup_widget()[source]
show_fullscreen(image)[source]

integereditor Module

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

Bases: camelot.view.controls.editors.customeditor.CustomEditor

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.

calculation_finished(value)[source]
calculator_icon = Icon('tango/16x16/apps/accessories-calculator.png')
get_value()[source]
popupCalculator(value)[source]
set_enabled(editable=True)[source]
set_field_attributes(editable=True, background_color=None, tooltip=None, prefix='', suffix='', nullable=True, single_step=1, **kwargs)[source]
set_value(value)[source]
spinbox_editing_finished()[source]

labeleditor Module

class camelot.view.controls.editors.labeleditor.LabelEditor(parent=None, text='<loading>', field_name='label', **kwargs)[source]

Bases: PyQt4.QtGui.QLabel, camelot.view.controls.editors.customeditor.AbstractCustomEditor

editingFinished
paintEvent(event)[source]
set_field_attributes(editable=True, background_color=None, tooltip=None, **kwargs)[source]
set_value(value)[source]

languageeditor Module

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

Bases: PyQt4.QtGui.QComboBox, camelot.view.controls.editors.customeditor.AbstractCustomEditor

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

editingFinished
get_value()[source]
language_choices = []
set_value(value)[source]

localfileeditor Module

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

Bases: camelot.view.controls.editors.customeditor.CustomEditor

Widget for browsing local files and directories

browse_button_clicked()[source]
browse_icon = Icon('tango/16x16/places/folder-saved-search.png')
filename_editing_finished()[source]
get_value()[source]
set_field_attributes(editable=True, background_color=None, tooltip=None, **kwargs)[source]
set_value(value)[source]
setup_widget()[source]

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

many2oneeditor Module

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

Bases: camelot.view.controls.editors.customeditor.CustomEditor, camelot.view.controls.editors.abstractmanytooneeditor.AbstractManyToOneEditor

Widget for editing many 2 one relations

class CompletionsModel(parent=None)[source]

Bases: PyQt4.QtCore.QAbstractListModel

columnCount(index=None)[source]
data(index, role)[source]
rowCount(index=None)[source]
setCompletions(completions)[source]
Many2OneEditor.arrow_down_key_pressed
Many2OneEditor.completionActivated(index)[source]
Many2OneEditor.completion_highlighted(index)[source]
Many2OneEditor.createFormView()[source]
Many2OneEditor.createNew(*args, **kwargs)[source]
Many2OneEditor.dataChanged(index1, index2)[source]
Many2OneEditor.display_search_completions(*args, **kwargs)[source]
Many2OneEditor.get_value()[source]
Returns:a function that returns the selected entity or ValueLoading

or None

Many2OneEditor.new_icon = Icon('tango/16x16/actions/document-new.png')
Many2OneEditor.on_arrow_down_key_pressed()[source]
Many2OneEditor.openButtonClicked()[source]
Many2OneEditor.returnPressed()[source]
Many2OneEditor.searchButtonClicked()[source]
Many2OneEditor.search_completions(*args, **kwargs)[source]

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

Returns:a list of tuples of (object_representation, object_getter)
Many2OneEditor.search_icon = Icon('tango/16x16/actions/system-search.png')
Many2OneEditor.search_input_editing_finished()[source]
Many2OneEditor.selectEntity(entity_instance_getter)[source]
Many2OneEditor.setEntity(entity_instance_getter, propagate=True)[source]
Many2OneEditor.set_editable(editable)[source]
Many2OneEditor.set_field_attributes(editable=True, background_color=None, tooltip=None, **kwargs)[source]
Many2OneEditor.set_instance_representation(representation_and_propagate)[source]

Update the gui

Many2OneEditor.set_value(value)[source]
Parameters:value – either ValueLoading, or a function that returns None

or the entity to be shown in the editor

Many2OneEditor.show_form_view(admin_and_title)[source]
Many2OneEditor.show_new_view(*args, **kwargs)[source]
Many2OneEditor.textEdited(text)[source]
Many2OneEditor.trashButtonClicked()[source]

manytomanyeditor Module

class camelot.view.controls.editors.manytomanyeditor.ManyToManyEditor(admin=None, parent=None, create_inline=False, vertical_header_clickable=True, field_name='onetomany', **kw)[source]

Bases: camelot.view.controls.editors.one2manyeditor.One2ManyEditor, camelot.view.controls.editors.abstractmanytooneeditor.AbstractManyToOneEditor

add_icon = Icon('tango/16x16/actions/list-add.png')
emit_editing_finished(*args)[source]
removeSelectedRows()[source]

Remove the selected rows in this tableview, but don’t delete them

remove_icon = Icon('tango/16x16/actions/list-remove.png')
selectEntity(entity_instance_getter)[source]
set_field_attributes(editable=True, **kwargs)[source]
setupButtons(layout, _table)[source]

monthseditor Module

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

Bases: camelot.view.controls.editors.customeditor.CustomEditor

MonthsEditor

composite months and years editor

get_value()[source]
set_enabled(editable=True)[source]
set_field_attributes(editable=True, background_color=None, tooltip=None, **kwargs)[source]
set_value(value)[source]

noteeditor Module

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

Bases: PyQt4.QtGui.QLabel, camelot.view.controls.editors.customeditor.AbstractCustomEditor

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

editingFinished
set_value(value)[source]

one2manyeditor Module

class camelot.view.controls.editors.one2manyeditor.One2ManyEditor(admin=None, parent=None, create_inline=False, vertical_header_clickable=True, field_name='onetomany', **kw)[source]

Bases: camelot.view.controls.editors.customeditor.CustomEditor, camelot.view.controls.editors.wideeditor.WideEditor

activate_editor(*args, **kwargs)[source]
copy_icon = Icon('tango/16x16/actions/edit-copy.png')
createFormForIndex(index)[source]
delete_icon = Icon('tango/16x16/places/user-trash.png')
exportToExcel()[source]
getModel()[source]
newRow()[source]
new_icon = Icon('tango/16x16/actions/document-new.png')
set_field_attributes(editable=True, new_message=None, **kwargs)[source]
set_value(model)[source]
setupButtons(layout, table)[source]
spreadsheet_icon = Icon('tango/16x16/mimetypes/x-office-spreadsheet.png')
update_delegates(*args)[source]

onetomanychoiceseditor Module

class camelot.view.controls.editors.onetomanychoiceseditor.OneToManyChoicesEditor(parent, target=None, nullable=True, field_name='onetomanychoices', **kwargs)[source]

Bases: camelot.view.controls.editors.choiceseditor.ChoicesEditor

get_choices()[source]
set_field_attributes(editable=True, **kwargs)[source]

Makes sure choices are not reset when changing the field attributes

richtexteditor Module

class camelot.view.controls.editors.richtexteditor.CustomTextEdit(parent)[source]

Bases: PyQt4.QtGui.QTextEdit

A TextEdit editor that sends editingFinished events when the text was changed and focus is lost.

editingFinished
focusInEvent(event)[source]
focusOutEvent(event)[source]
receivedFocus
setHtml(html)[source]
setTextChanged(state=True)[source]
class camelot.view.controls.editors.richtexteditor.RichTextEditor(parent=None, field_name='richtext', **kwargs)[source]

Bases: camelot.view.controls.editors.customeditor.CustomEditor, camelot.view.controls.editors.wideeditor.WideEditor

emit_editing_finished()[source]
get_value()[source]
initToolbar()[source]
set_aligncenter(bool)[source]
set_alignleft(bool)[source]
set_alignright(bool)[source]
set_bold()[source]
set_color()[source]
set_editable(editable)[source]
set_field_attributes(editable=True, background_color=None, **kwargs)[source]
set_italic(bool)[source]
set_underline(bool)[source]
set_value(value)[source]
update_alignment(al=None)[source]
update_color()[source]
update_format(format)[source]
update_text()[source]

smileyeditor Module

class camelot.view.controls.editors.smileyeditor.SmileyEditor(parent, editable=True, icons=[('face-angel', Icon('tango/16x16/emotes/face-angel.png')), ('face-crying', Icon('tango/16x16/emotes/face-crying.png')), ('face-devilish', Icon('tango/16x16/emotes/face-devilish.png')), ('face-glasses', Icon('tango/16x16/emotes/face-glasses.png')), ('face-grin', Icon('tango/16x16/emotes/face-grin.png')), ('face-kiss', Icon('tango/16x16/emotes/face-kiss.png')), ('face-monkey', Icon('tango/16x16/emotes/face-monkey.png')), ('face-plain', Icon('tango/16x16/emotes/face-plain.png')), ('face-sad', Icon('tango/16x16/emotes/face-sad.png')), ('face-smile', Icon('tango/16x16/emotes/face-smile.png')), ('face-smile-big', Icon('tango/16x16/emotes/face-smile-big.png')), ('face-surprise', Icon('tango/16x16/emotes/face-surprise.png')), ('face-wink', Icon('tango/16x16/emotes/face-wink.png'))], field_name='icons', **kwargs)[source]

Bases: camelot.view.controls.editors.customeditor.CustomEditor

get_value()[source]
set_enabled(editable=True)[source]
set_value(value)[source]
smiley_changed()[source]

stareditor Module

class camelot.view.controls.editors.stareditor.StarEditor(parent, maximum=5, editable=True, field_name='star', **kwargs)[source]

Bases: camelot.view.controls.editors.customeditor.CustomEditor

get_value()[source]
no_star_icon = Icon('tango/16x16/status/weather-clear-noStar.png')
set_background_color(background_color)[source]
set_enabled(editable=True)[source]
set_value(value)[source]
starClick(value)[source]
star_icon = Icon('tango/16x16/status/weather-clear.png')

textediteditor Module

class camelot.view.controls.editors.textediteditor.TextEditEditor(parent, length=20, editable=True, field_name='text', **kwargs)[source]

Bases: PyQt4.QtGui.QTextEdit, camelot.view.controls.editors.customeditor.AbstractCustomEditor, camelot.view.controls.editors.wideeditor.WideEditor

editingFinished
get_value()[source]
set_enabled(editable=True)[source]
set_value(value)[source]

textlineeditor Module

class camelot.view.controls.editors.textlineeditor.TextLineEditor(parent, length=20, field_name='text_line', **kwargs)[source]

Bases: PyQt4.QtGui.QLineEdit, camelot.view.controls.editors.customeditor.AbstractCustomEditor

get_value()[source]
paintEvent(event)[source]
set_enabled(editable=True)[source]
set_field_attributes(editable=True, background_color=None, tooltip=None, **kwargs)[source]
set_value(value)[source]

timeeditor Module

class camelot.view.controls.editors.timeeditor.TimeEditor(parent, editable=True, field_name='time', format='hh:mm', **kwargs)[source]

Bases: PyQt4.QtGui.QTimeEdit, camelot.view.controls.editors.customeditor.AbstractCustomEditor

get_value()[source]
paintEvent(event)[source]
set_background_color(background_color)[source]
set_enabled(editable=True)[source]
set_field_attributes(editable=True, background_color=None, tooltip=None, **kwargs)[source]
set_value(value)[source]

virtualaddresseditor Module

class camelot.view.controls.editors.virtualaddresseditor.VirtualAddressEditor(parent=None, editable=True, address_type=None, address_validator=<function default_address_validator at 0x9e688b4>, field_name='virtual_address', **kwargs)[source]

Bases: camelot.view.controls.editors.customeditor.CustomEditor

checkValue(text)[source]
comboIndexChanged()[source]
editorValueChanged(text)[source]
emit_editing_finished()[source]
get_value()[source]
mail_click()[source]
set_background_color(background_color)[source]
set_enabled(editable=True)[source]
set_field_attributes(editable=True, background_color=None, tooltip=None, **kwargs)[source]
set_value(value)[source]
camelot.view.controls.editors.virtualaddresseditor.default_address_validator(address_type, address)[source]

Validates wether a virtual address is valid and correct it if possible. :param address_type: the type of address to validate, eg ‘phone’ :param address: the address itself :return: (valid, corrected_address) a tuple with a :type:`boolean`

indicating if the address is valid and a string with the corrected address.

wideeditor Module

class camelot.view.controls.editors.wideeditor.WideEditor[source]

Bases: object

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


Comments
blog comments powered by Disqus