1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 """Manage QAction objects"""
29
30 from PyQt4 import QtGui, QtCore
31
33 if widgetaction:
34 return QtGui.QWidgetAction(parent)
35 else:
36 return QtGui.QAction(parent)
37
39 """creates and returns a QAction object"""
40
41
42 parent = kw['parent']
43 text = kw['text']
44 slot = kw.get('slot', None)
45 shortcut = kw.get('shortcut', '')
46 actionicon = kw.get('actionicon', '')
47 tip = kw.get('tip', '')
48 checkable = kw.get('checkable', False)
49 signal = kw.get('signal', 'triggered()')
50 widgetaction = kw.get('widgetaction', False)
51
52 action = getAction(parent, widgetaction)
53
54 action.setText(text)
55
56 if actionicon:
57 action.setIcon(QtGui.QIcon(actionicon))
58 if shortcut:
59 action.setShortcut(shortcut)
60 if tip:
61 action.setToolTip(tip)
62 action.setStatusTip(tip)
63 if slot is not None:
64 parent.connect(action, QtCore.SIGNAL(signal), slot)
65 if checkable:
66 action.setCheckable(True)
67 return action
68
70 """add action objects to menus, menubars, and toolbars
71 if action is None, add a separator.
72 """
73 for action in actions:
74 if action is None:
75 target.addSeparator()
76 else:
77 target.addAction(action)
78