1
2 from camelot.core.utils import ugettext_lazy as _
3
5 """An action that can be triggered by the user at the application level"""
6
7 - def run(self, parent):
8 """Execute the action, called within the gui thread
9
10 :param parent: a QWidget that can be used as a parent for widgets during the
11 execution of the action
12 """
13 raise NotImplemented
14
16 """:return: the name of the action, as it can be shown to the user"""
17 raise NotImplemented
18
20 """:return: a camelot.view.art.Icon object"""
21 raise NotImplemented
22
24 """Create an application action object from a function that is supposed to run
25 in the GUI thread"""
26
27 - def __init__(self, name, gui_function, icon=None, verbose_name=None):
28 """
29 :param name: a unicode string naming this action
30 :param gui_function: the function that will be called when the action
31 is triggered, this function takes a its single argument a parent QObject
32 :param icon: a camelot.view.art.Icon object
33 :param verbose_name: the name used to display the action, if not given,
34 the capitalized name will be used
35 """
36 self._name = name
37 self._verbose_name = verbose_name or _(name.capitalize())
38 self._icon = icon
39 self._gui_function = gui_function
40
41 - def run(self, parent):
43
46
48 return self._verbose_name
49
51 """An application action that opens a TableView for an Entity"""
52
53 - def __init__(self, entity, admin=None, verbose_name=None, parent_admin=None):
62
65
66 - def run(self, parent):
69
71 """Convert a python structure to an ApplicationAction"""
72 if isinstance(structure, (ApplicationAction,)):
73 return structure
74 return TableViewAction(structure)
75