### Navigation

- index
- modules |
- next |
- previous |
- Camelot documentation »
- Camelot Documentation contents »
- Camelot Documentation »

# Customizing the Application

The ApplicationAdmin controls how the application behaves, it determines the sections in the left pane, the availability of help, the about box, the menu structure, etc.

>     from camelot.view.art import Icon
>     from camelot.admin.application_admin import ApplicationAdmin
>     from camelot.admin.section import Section
>     from camelot.core.utils import ugettext_lazy as _

>     class MyApplicationAdmin(ApplicationAdmin):

>         name = 'Camelot Video Store'

>     # begin sections
>         def get_sections(self):

>             from camelot.model.memento import Memento
>             from camelot.model.authentication import Person, Organization
>             from camelot.model.i18n import Translation

>             from camelot_example.model import Movie, Tag, VisitorReport
>             from camelot_example.view import VisitorsPerDirector
>     # begin import action
>             from camelot_example.importer import ImportCovers
>     # end import action

>             return [
>     # begin section with action
>                     Section( _('Movies'),
>                              self,
>                              Icon('tango/22x22/mimetypes/x-office-presentation.png'),
>                              items = [ Movie,
>                                        Tag,
>                                        VisitorReport,
>                                        VisitorsPerDirector,
>                                        ImportCovers() ]),
>     # end section with action
>                     Section( _('Relation'),
>                              self,
>                              Icon('tango/22x22/apps/system-users.png'),
>                              items = [ Person,
>                                        Organization ]),
>                     Section( _('Configuration'),
>                              self,
>                              Icon('tango/22x22/categories/preferences-system.png'),
>                              items = [ Memento,
>                                        Translation ])
>                     ]
>     # end sections

>     # begin actions
>         def get_actions(self):
>             from camelot.admin.action import OpenNewView
>             from camelot_example.model import Movie

>             new_movie_action = OpenNewView( self.get_related_admin(Movie) )
>             new_movie_action.icon = Icon('tango/22x22/mimetypes/x-office-presentation.png')

>             return [new_movie_action]
>     # end actions

Each Camelot application should subclass the ApplicationAdmin and overwrite some of its methods.

class `camelot.admin.application_admin.``ApplicationAdmin`

  The ApplicationAdmin class defines how the application should look like, it also ties Python classes to their associated `camelot.admin.object_admin.ObjectAdmin` class or subclass. It’s behaviour can be steered by overwriting its static attributes or it’s methods :

  `name`

    The name of the application, as it will appear in the title of the main window.

  `application_url`

    The url of the web site where the user can find more information on the application.

  `help_url`

    Points to either a local html file or a web site that contains the documentation of the application.

  `author`

    The name of the author of the application

  `domain`

    The domain name of the author of the application, eg ‘mydomain.com’, this domain will be used to store settings of the application.

  `version`

    A string with the version of the application

  `backup_mechanism`

    A subclass of `camelot.core.backup.BackupMechanism` that enables the application to perform backups an restores.

  `database_profile_wizard`

    The wizard that should be used to create new database profiles. Defaults to `camelot.view.database_selection.ProfileWizard`

  `database_selection`

    if this is set to True, present the user with a database selection wizard prior to starting the application. Defaults to `False`.

  `get_sections`(*args, **kwargs)

    A list of `camelot.admin.section.Section` objects, these are the sections to be displayed in the left panel.

  `get_actions`()

    Returns: | a list of `camelot.admin.application_action.ApplicationAction` objects

    that should be added to the menu and the icon bar for this application

  `get_name`()

    Returns: | the name of the application, by default this is the class

    attribute name

  `get_version`()

    Returns: | string representing version of the application, by default this

    is the class attribute verion

  `get_icon`()

    Returns: | the `camelot.view.art.Icon` that should be used for the application

  `get_splashscreen`()

    Returns: | a `PyQt4.QtGui.QPixmap` to be used as splash screen

  `get_stylesheet`()

    Returns: | a string with the qt stylesheet to be used for this application as a string

    or None if no stylesheet needed.

    Camelot comes with a couple of default stylesheets :

    > - stylesheet/office2007_blue.qss
    > - stylesheet/office2007_black.qss
    > - stylesheet/office2007_silver.qss

    Have a look at the default implementation to use another stylesheet.

  `get_translator`()

    Reimplement this method to add application specific translations to your application. The default method returns a list with the default Qt and the default Camelot translator for the current system locale. Call `QLocale.setDefault()` before this method is called if you want to load different translations then the system default.

    Returns: | a list of `QtCore.QTranslator` objects that should be used to translate the application

  `get_about`()

    Returns: | the content of the About dialog, a string with html

    syntax

### Navigation

- index
- modules |
- next |
- previous |
- Camelot documentation »
- Camelot Documentation contents »
- Camelot Documentation »

Comments
blog comments powered by Disqus