action_steps¶
- class camelot.view.action_steps.ActionView(title, actions)¶
Open a new view which presents the user with a number of actions to trigger.
Parameters: - title – the tile of the view
- actions – a list of actions
- class camelot.view.action_steps.ChangeField(admin, field_attributes=None, field_name=None)¶
Pop up a list of fields from an object a user can change. When the user selects a field, an appropriate widget is shown to change the value of that field.
Parameters: - admin – the admin of the object of which to change the field
- field_attributes – a list of field attributes of the fields that can be changed. If None is given, all fields are shown.
- field_name – the name of the selected field when opening the dialog
This action step returns a tuple with the name of the selected field, and its new value.
- render()¶
create the dialog. this method is used to unit test the action step.
- class camelot.view.action_steps.ChangeObject(obj, admin=None)¶
Pop up a form for the user to change an object
Parameters: - obj – the object to change
- admin – an instance of an admin class to use to edit the object, None if the default is to be taken
- accept¶
The text shown in the accept button
- reject¶
The text shown in the reject button
- get_object()¶
Use this method to get access to the object to change in unit tests
Returns: the object to change
- render(gui_context)¶
create the dialog. this method is used to unit test the action step.
- class camelot.view.action_steps.ChangeObjects(objects, admin)¶
Pop up a list for the user to change objects
Parameters: - objects – a list of objects to change
- admin – an instance of an admin class to use to edit the objects.
This action step can be customised using these attributes :
- window_title¶
the window title of the dialog shown
- title¶
the title of the dialog shown
- subtitle¶
the subtitle of the dialog shown
- icon¶
the camelot.view.art.Icon in the top right corner of the dialog
- get_objects()¶
Use this method to get access to the objects to change in unit tests
Returns: the object to change
- render()¶
create the dialog. this method is used to unit test the action step.
- class camelot.view.action_steps.CloseView(accept=True)¶
Close the view that triggered the action, if such a view is available.
Parameters: accept – a boolean indicating if the view’s widget should accept the close event. This defaults to True, when this is set to False, the view will trigger it’s corresponding close action instead of accepting the close event. The close action might involve validating if the view can be closed, or requesting confirmation from the user.
- class camelot.view.action_steps.CreateObject(obj)¶
Inform the GUI that obj was created.
Parameters: obj – the object that was created
- class camelot.view.action_steps.DeleteObject(obj)¶
Inform the GUI that obj is going to be deleted.
Parameters: obj – the object that is going to be deleted
- class camelot.view.action_steps.EditTextDocument(document)¶
Display a rich text editor to edit a text document.
Parameters: document – a QtGui.QTextDocument object. When this action step is constructed, the thread affinity of the document is changed to be the gui thread. when the editing of the document is finished, the affinity is returned to the current thread. There is no Cancel button on the dialog because the document is changed when the user is editing it, and this cannot be undone.
This action step can be customised using these attributes :
- window_title¶
the window title of the dialog shown
- title¶
the title of the dialog shown
- subtitle¶
the subtitle of the dialog shown
- render()¶
create the text edit dialog. this method is used to unit test the action step.
- class camelot.view.action_steps.Exit(return_code=0)¶
Stop the event loop, and exit the application
- class camelot.view.action_steps.FlushSession(session, update_depending_objects=True)¶
Flushes the session and informs the GUI about the changes.
Parameters: - session – an instance of sqlalchemy.orm.Session
- update_depending_objects – set to False if the objects that depend on an object that has been modified need not to be updated in the GUI. This will make the flushing faster, but the GUI might become inconsistent.
- class camelot.view.action_steps.InstallTranslator(admin)¶
Install a translator in the application. Ownership of the translator will be moved to the application.
Parameters: admin – a :class:`camelot.admin.application_admin.ApplicationAdmin’ object
- class camelot.view.action_steps.MainWindow(admin)¶
Open a top level application window
Parameters: admin – a :class:`camelot.admin.application_admin.ApplicationAdmin’ object - window_title¶
The title of the main window, defaults to the application name if None is given
- render(gui_context)¶
create the main window. this method is used to unit test the action step.
- class camelot.view.action_steps.MessageBox(text, icon=1, title=_('Message'), standard_buttons=<PyQt4.QtGui.StandardButtons object at 0x111f5ecf8>)¶
Popup a QtWidgets.QMessageBox and send it result back. The arguments of this action are the same as those of the QtWidgets.QMessageBox constructor.
Parameters: - text – the text to be displayed within the message box
- icon – one of the QtWidgets.QMessageBox.Icon constants
- title – the window title of the message box
- standard_buttons – the buttons to be displayed on the message box, out of the QtWidgets.QMessageBox.StandardButton enumeration. by default an Ok and a button Cancel will be shown.
When the Cancel button is pressed, this action step will raise a camelot.core.exception.CancelRequest
- render()¶
create the message box. this method is used to unit test the action step.
- class camelot.view.action_steps.OpenFile(path)¶
Open a file with the preferred application from the user. The absolute path is preferred, as this is most likely to work when running from an egg and in all kinds of setups.
Parameters: file_name – the absolute path to the file to open The yield statement will return True if the file was opend successfull.
- classmethod create_temporary_file(suffix)¶
Create a temporary filename that can be used to write to, and open later on.
Parameters: suffix – the suffix of the file to create Returns: the filename of the temporary file
- get_path()¶
Returns: the path to the file that will be opened, use this method to verify the content of the file in unit tests
- class camelot.view.action_steps.OpenFormView(objects, admin)¶
Open the form view for a list of objects, in a non blocking way.
Parameters: - objects – the list of objects to display in the form view, if objects is set to None, the model of the item view of the gui context is reused
- admin – the admin class to use to display the form
- row¶
Which object to display when opening the form, defaults to the first object, so row is 0 by default
- actions¶
A list of camelot.admin.action.base.Action objects to be displayed at the side of the form, this defaults to the ones returned by the admin
- top_toolbar_actions¶
A list of camelot.admin.action.base.Action objects to be displayed at the top toolbar of the form, this defaults to the ones returned by the admin
- get_objects()¶
Use this method to get access to the objects to change in unit tests
Returns: the list of objects to display in the form view
- class camelot.view.action_steps.OpenJinjaTemplate(template, context={}, environment=<camelot.core.templates.environment>, suffix='.txt')¶
Render a jinja template into a temporary file and open that file with the prefered application of the user.
Parameters: - environment – a jinja2.Environment object to be used to load templates from.
- template – the name of the template as it can be fetched from the Jinja environment.
- suffix – the suffix of the temporary file to create, this will determine the application used to open the file.
- context – a dictionary with objects to be used when rendering the template
- class camelot.view.action_steps.OpenStream(stream, suffix='.txt')¶
Write a stream to a temporary file and open that file with the preferred application of the user.
Parameters: - stream – the byte stream to write to a file
- suffix – the suffix of the temporary file
- class camelot.view.action_steps.OpenString(string, suffix='.txt')¶
Write a string to a temporary file and open that file with the preferred application of the user.
Parameters: - string – the binary string to write to a file
- suffix – the suffix of the temporary file
- class camelot.view.action_steps.OpenTableView(admin, value)¶
Open a new table view in the workspace.
Parameters: - admin – an camelot.admin.object_admin.ObjectAdmin instance
- value – a list of objects or a query
- title¶
- the title of the the new view
- subclasses¶
- a tree of subclasses to be displayed on the left of the
- new_tab¶
- open the view in a new tab instead of the current tab
- class camelot.view.action_steps.PrintChart(chart)¶
Display a print preview dialog box for a matplotlib chart.
Parameters: chart – a camelot.container.chartcontainer.FigureContainer object or a camelot.container.chartcontainer.AxesContainer subclass Example use of this action step :
- class camelot.view.action_steps.PrintHtml(html)¶
Display a print preview dialog box for an html string.
Parameters: html – a string containing the html to render in the print preview. the rendering of the html can be customised using the same attributes as those of the PrintPreview class.
- class camelot.view.action_steps.PrintJinjaTemplate(template, context={}, environment=<camelot.core.templates.environment>)¶
Render a jinja template into a print preview dialog.
Parameters: - template – the name of the template as it can be fetched from the Jinja environment.
- context – a dictionary with objects to be used when rendering the template
- environment – a jinja2.Environment object to be used to load templates from. This defaults to the environment object available in camelot.core.templates
- class camelot.view.action_steps.PrintPreview(document)¶
Display a print preview dialog box.
Parameters: document – an instance of QtGui.QTextDocument or QtWebKit.QWebView that has a print_() method. The thread affinity of this object will be changed to be able to use it in the GUI. the print preview can be customised using these attributes :
- margin_left¶
change the left margin of the content to the page border, unit is set by margin_unit
- margin_top¶
change the top margin of the content to the page border, unit is set by margin_unit
- margin_right¶
change the right margin of the content to the page border, unit is set by margin_unit
- margin_bottom¶
change the bottom margin of the content to the page border, unit is set by margin_unit
- margin_unit¶
defin which unit is used for the defined margins (e.g. margin_left, margin_bottom)
- page_size¶
the page size, by default QtPrintSupport.QPrinter.A4 is used
- page_orientation¶
the page orientation, by default QtPrintSupport.QPrinter.Portrait is used.
- document¶
the QtGui.QTextDocument holding the document that will be shown in the print preview
- actions¶
the list of additional document actions to be displayed in the toolbar of the print preview
- render(gui_context)¶
create the print preview widget. this method is used to unit test the action step.
- class camelot.view.action_steps.Refresh¶
Refresh all the open screens on the desktop, this will reload queries from the database
- class camelot.view.action_steps.RemoveTranslators(admin)¶
Unregister all previously installed translators from the application.
Parameters: admin – a :class:`camelot.admin.application_admin.ApplicationAdmin’ object
- class camelot.view.action_steps.SaveFile(file_name_filter='', file_name=None)¶
Select a file for saving
Parameters: - file_name_filter – Filter on the names of the files that can be selected, such as ‘All files (*)’. See QtGui.QFileDialog for more documentation.
- file_name – None or the default filename to use
- caption¶
The text to display to the user
The yield statement of SaveFile returns a file name. Raises a camelot.core.exception.CancelRequest when no file was selected.
This action step stores its last location into the QtCore.QSettings and uses it as the initial location the next time it is invoked.
- class camelot.view.action_steps.SelectDirectory¶
Select a single directory
- caption¶
The text to display to the user
- options¶
options to pass to QtGui.QFileDialog.getExistingDirectory(), defaults to QtGui.QFileDialog.ShowDirsOnly
- class camelot.view.action_steps.SelectFile(file_name_filter='')¶
Select one or more files to open
Parameters: file_name_filter – Filter on the names of the files that can be selected, such as ‘All files (*)’. See QtGui.QFileDialog for more documentation. - single¶
defaults to True, set to False if selection of multiple files is allowed
- caption¶
The text to display to the user
The yield statement of SelectFile returns a list of selected file names. This list has only one element when single is set to True. Raises a camelot.core.exception.CancelRequest when no file was selected.
This action step stores its last location into the QtCore.QSettings and uses it as the initial location the next time it is invoked.
- class camelot.view.action_steps.SelectItem(items, value=None)¶
This action step pops up a single combobox dialog in which the user can select one item from a list of items.
Parameters: - items – a list of tuples with values and the visible name of the items from which the user can select, such as `[(1, ‘first’), (2,’second’)]
- value – the value that should be selected when the dialog pops up
- autoaccept – if True the dialog closes immediately after the user selected an option. When this is False, the user should press OK first.
- class camelot.view.action_steps.SelectObjects(admin, search_text=None, value=None)¶
Select one or more object from a query. The yield of this action step return a list of objects.
Parameters: - admin – a camelot.admin.object_admin.ObjectAdmin object
- search_text – a default string on which to search for in the selection dialog
- value – a query or a list of object from which the selection should be made. If none is given, the default query from the admin is taken.
- class camelot.view.action_steps.SelectSubclass(admin)¶
Allow the user to select a subclass out of a class hierarchy. If the hierarch has only one class, this step returns immediately.
Parameters: admin – a camelot.admin.object_admin.ObjectAdmin object yielding this step will return the admin for the subclass selected by the user.
- class camelot.view.action_steps.ShowChart(chart)¶
Show a full screen chart.
Parameters: chart – a camelot.container.chartcontainer.FigureContainer or camelot.container.chartcontainer.AxesContainer
- class camelot.view.action_steps.ShowPixmap(pixmap)¶
Show a full screen pixmap
Parameters: pixmap – a camelot.view.art.Pixmap object
- class camelot.view.action_steps.ToFirstForm¶
Show the first object in the collection in the current form
- class camelot.view.action_steps.ToLastForm¶
Show the last object in the collection in the current form
- class camelot.view.action_steps.ToNextForm¶
Show the next object in the collection in the current form
- class camelot.view.action_steps.ToPreviousForm¶
Show the previous object in the collection in the current form
- class camelot.view.action_steps.UpdateEditor(attribute, value, propagate=False)¶
This step should be used in the context of an editor action. It will update an attribute of the editor.
Parameters: - attribute – the name of the attribute of the editor to update
- value – the new value of the attribute
- propagate – set to True if the editor should notify the underlying model of it’s change, so that the changes can be written to the model
- class camelot.view.action_steps.UpdateObject(obj)¶
Inform the GUI that obj has changed.
Parameters: obj – the object that has changed
- class camelot.view.action_steps.UpdatePrintPreview¶
Force the print preview dialog to update itself.
To be used inside a document action
- class camelot.view.action_steps.UpdateProgress(value=None, maximum=None, text=None, detail=None, clear_details=False, title=None, blocking=False, enlarge=False)¶
Inform the user about the progress the application is making while executing an action. This ActionStep is not blocking. So it can be used inside transactions and will result in a minimum of delay when yielded. Each time an object is yielded, the progress dialog will be updated.
Parameters: - value – the current step
- maximum – the maximum number of steps that will be executed. set it to 0 to display a busy indicator instead of a progres bar
- text – the text to be displayed inside the progres bar
- detail – the text to be displayed below the progres bar, this text is appended to the text already there
- clear_details – clear the details text already there before putting the new detail text.
- title – the text to be displayed in the window’s title bar
- blocking – wait until the user presses OK, for example to review the details.
- enlarge – increase the size of the window to two thirds of the screen, useful when there are a lot of details displayed.
- gui_run(gui_context)¶
This method will update the progress dialog, if such dialog exists within the GuiContext
Parameters: gui_context – a camelot.admin.action.GuiContext instance
- class camelot.view.action_steps.UpdateTableView(admin, value)¶
Change the admin and or value of an existing table view
Parameters: - admin – an camelot.admin.object_admin.ObjectAdmin instance
- value – a list of objects or a query
- class camelot.view.action_steps.WordJinjaTemplate(template, context={}, environment=<camelot.core.templates.environment>, suffix='.xml')¶
Render a jinja template into a temporary file and open that file with microsoft word through the use of COM objects.
Parameters: - environment – a jinja2.Environment object to be used to load templates from.
- template – the name of the template as it can be fetched from the Jinja environment.
- suffix – the suffix of the temporary file to create, this will determine the application used to open the file.
- context – a dictionary with objects to be used when rendering the template