1 """
2 Overview
3 ========
4 This module provides the menuing system for the Basin Client. It is used in conjunction with the Actions
5 module so that it can take every action from each package and give it its own menu.
6 """
7
8 import PyQt4.QtGui
9
10 import re
11
12 import Constants
13
15 """
16 Overview
17 ========
18 This class is a convenienve class which bundles the adding of all the menu items into
19 the menu's constructor. The way it can do this is by asking the Action object, for
20 which is has access to from the bridge, for all of the actions it has under a given
21 package. This helps in automating the process of creating menus, especially for
22 large menus such as "General Functions".
23 """
24
26 """
27 Overview
28 ========
29 The constructor will pull all of the actions from each individual package of actions
30 from the Actions object. For each package, a seperatorList is defined as a list of
31 names of actions in that package. For each name in the list, a seperator will appear
32 after that action. In this way, the user doesn't have to worry about anything other
33 than how to seperate out actions in a package, the rest is taken care of.
34
35 @param parent: The main window for which this menubar will be applied to.
36 @type parent: QMainWindow
37
38 @param bridge: The bridge object which connects all interactive components together.
39 @type bridge: L{Bridge<client.Bridge.Bridge>}
40 """
41
42 PyQt4.QtGui.QMenuBar.__init__ (self, parent)
43
44 self._bridge = bridge
45 bridge.setMenuBar (self)
46
47
48
49
50
51
52 self.file = PyQt4.QtGui.QMenu ("&File", parent)
53 seperatorList = ["Update", "Save", "Load Batch File"]
54 for act in self._bridge._actions._file:
55 self.file.addAction (act)
56 if seperatorList.count (act.text ()) > 0:
57 self.file.addSeparator ()
58 self.addMenu (self.file)
59
60 self.plot = PyQt4.QtGui.QMenu ("&Plotting", parent)
61 seperatorList = []
62 for act in self._bridge._actions._plot:
63 self.plot.addAction (act)
64 if seperatorList.count (act.text ()) > 0:
65 self.plot.addSeparator ()
66 self.addMenu (self.plot)
67
68 self.genf = PyQt4.QtGui.QMenu ("&General Functions", parent)
69 seperatorList = ["Attribute Index", "Imaginary", "Index Sort", "exp10"]
70 for act in self._bridge._actions._genf:
71 self.genf.addAction (act)
72 if seperatorList.count (act.text ()) > 0:
73 self.genf.addSeparator ()
74 self.addMenu (self.genf)
75
76 self.cosm = PyQt4.QtGui.QMenu ("&Cosmology", parent)
77 seperatorList = ["Redshift To Growth"]
78 for act in self._bridge._actions._cosm:
79 self.cosm.addAction (act)
80 if seperatorList.count (act.text ()) > 0:
81 self.cosm.addSeparator ()
82 self.addMenu (self.cosm)
83
84 self.lina = PyQt4.QtGui.QMenu ("&Linear Algebra", parent)
85 seperatorList = ["Create Identity Matrix"]
86 for act in self._bridge._actions._linalg:
87 self.lina.addAction (act)
88 if seperatorList.count (act.text ()) > 0:
89 self.lina.addSeparator ()
90 self.addMenu (self.lina)
91
92 self.stel = PyQt4.QtGui.QMenu ("Stellar &Dynamics", parent)
93 seperatorList = []
94 for act in self._bridge._actions._stel:
95 self.stel.addAction (act)
96 if seperatorList.count (act.text ()) > 0:
97 self.stel.addSeparator ()
98 self.addMenu (self.stel)
99
100 self.stat = PyQt4.QtGui.QMenu ("&Statistics", parent)
101 seperatorList = []
102 for act in self._bridge._actions._stat:
103 self.stat.addAction (act)
104 if seperatorList.count (act.text ()) > 0:
105 self.stat.addSeparator ()
106 self.addMenu (self.stat)
107
108 self.tran = PyQt4.QtGui.QMenu ("&Transformations", parent)
109 seperatorList = ["Cartesian To Spherical", "Cartesian To Equatorial", \
110 "Cartesian To Polar", "Cartesian To Cylindrical", "FFT", "Convolve"]
111 for act in self._bridge._actions._tran:
112 self.tran.addAction (act)
113 if seperatorList.count (act.text ()) > 0:
114 self.tran.addSeparator ()
115 self.addMenu (self.tran)
116
117 self.help = PyQt4.QtGui.QMenu ("&Help", parent)
118 seperatorList = []
119 for act in self._bridge._actions._help:
120 self.help.addAction (act)
121 if seperatorList.count (act.text ()) > 0:
122 self.help.addSeparator ()
123 self.addMenu (self.help)
124
125 self._bridge._actions.menuDisconnect ()
126 parent.setMenuBar (self)
127 self._bridge._toolBar.loadSettings ()
128