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.
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 :
The name of the application, as it will appear in the title of the main window.
The url of the web site where the user can find more information on the application.
Points to either a local html file or a web site that contains the documentation of the application.
The name of the author of the application
The domain name of the author of the application, eg ‘mydomain.com’, this domain will be used to store settings of the application.
A string with the version of the application
A subclass of camelot.core.backup.BackupMechanism that enables the application to perform backups an restores.
The wizard that should be used to create new database profiles. Defaults to camelot.view.database_selection.ProfileWizard
if this is set to True, present the user with a database selection wizard prior to starting the application. Defaults to False.
A list of camelot.admin.section.Section objects, these are the sections to be displayed in the left panel.
Returns: | a list of camelot.admin.application_action.ApplicationAction objects |
---|
that should be added to the menu and the icon bar for this application
Returns: | the name of the application, by default this is the class |
---|
attribute name
Returns: | string representing version of the application, by default this |
---|
is the class attribute verion
Returns: | the camelot.view.art.Icon that should be used for the application |
---|
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.
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 |
---|