Show More
@@ -279,6 +279,7 class ConsoleWidget(LoggingConfigurable, QtGui.QWidget): | |||||
279 | shortcut="Ctrl+Z", |
|
279 | shortcut="Ctrl+Z", | |
280 | statusTip="Undo last action if possible", |
|
280 | statusTip="Undo last action if possible", | |
281 | triggered=self._control.undo) |
|
281 | triggered=self._control.undo) | |
|
282 | self.undo_action.setDisabled(True) | |||
282 | self.addAction(self.undo_action) |
|
283 | self.addAction(self.undo_action) | |
283 |
|
284 | |||
284 | self.redo_action = QtGui.QAction("Redo", |
|
285 | self.redo_action = QtGui.QAction("Redo", | |
@@ -286,36 +287,42 class ConsoleWidget(LoggingConfigurable, QtGui.QWidget): | |||||
286 | shortcut="Ctrl+Shift+Z", |
|
287 | shortcut="Ctrl+Shift+Z", | |
287 | statusTip="Redo last action if possible", |
|
288 | statusTip="Redo last action if possible", | |
288 | triggered=self._control.redo) |
|
289 | triggered=self._control.redo) | |
|
290 | self.redo_action.setDisabled(True) | |||
289 | self.addAction(self.redo_action) |
|
291 | self.addAction(self.redo_action) | |
290 |
|
292 | |||
291 | self.reset_action = QtGui.QAction("Reset", |
|
293 | self.reset_action = QtGui.QAction("Reset", | |
292 | self, |
|
294 | self, | |
293 | statusTip="Clear all varible from workspace", |
|
295 | statusTip="Clear all varible from workspace", | |
294 | triggered=self.reset_magic) |
|
296 | triggered=self.reset_magic) | |
|
297 | self.reset_action.setDisabled(True) | |||
295 | self.addAction(self.reset_action) |
|
298 | self.addAction(self.reset_action) | |
296 |
|
299 | |||
297 | self.clear_action = QtGui.QAction("Clear", |
|
300 | self.clear_action = QtGui.QAction("Clear", | |
298 | self, |
|
301 | self, | |
299 | statusTip="Clear the console", |
|
302 | statusTip="Clear the console", | |
300 | triggered=self.clear_magic) |
|
303 | triggered=self.clear_magic) | |
|
304 | self.clear_action.setDisabled(True) | |||
301 | self.addAction(self.clear_action) |
|
305 | self.addAction(self.clear_action) | |
302 |
|
306 | |||
303 | self.who_action = QtGui.QAction("Who", |
|
307 | self.who_action = QtGui.QAction("Who", | |
304 | self, |
|
308 | self, | |
305 | statusTip="List interactive variable", |
|
309 | statusTip="List interactive variable", | |
306 | triggered=self.who_magic) |
|
310 | triggered=self.who_magic) | |
|
311 | self.who_action.setDisabled(True) | |||
307 | self.addAction(self.who_action) |
|
312 | self.addAction(self.who_action) | |
308 |
|
313 | |||
309 | self.whos_action = QtGui.QAction("Whos", |
|
314 | self.whos_action = QtGui.QAction("Whos", | |
310 | self, |
|
315 | self, | |
311 | statusTip="List interactive variable with detail", |
|
316 | statusTip="List interactive variable with detail", | |
312 | triggered=self.whos_magic) |
|
317 | triggered=self.whos_magic) | |
|
318 | self.whos_action.setDisabled(True) | |||
313 | self.addAction(self.whos_action) |
|
319 | self.addAction(self.whos_action) | |
314 |
|
320 | |||
315 | self.who_ls_action = QtGui.QAction("Who ls", |
|
321 | self.who_ls_action = QtGui.QAction("Who ls", | |
316 | self, |
|
322 | self, | |
317 | statusTip="Return a list of interactive variable", |
|
323 | statusTip="Return a list of interactive variable", | |
318 | triggered=self.who_ls_magic) |
|
324 | triggered=self.who_ls_magic) | |
|
325 | self.who_ls_action.setDisabled(True) | |||
319 | self.addAction(self.who_ls_action) |
|
326 | self.addAction(self.who_ls_action) | |
320 |
|
327 | |||
321 |
|
328 |
@@ -35,12 +35,14 class HistoryConsoleWidget(ConsoleWidget): | |||||
35 | self, |
|
35 | self, | |
36 | statusTip="show command history", |
|
36 | statusTip="show command history", | |
37 | triggered=self.history_magic) |
|
37 | triggered=self.history_magic) | |
|
38 | self.history_action.setDisabled(True) | |||
38 | self.addAction(self.history_action) |
|
39 | self.addAction(self.history_action) | |
39 |
|
40 | |||
40 | self.save_action = QtGui.QAction("Export History ", |
|
41 | self.save_action = QtGui.QAction("Export History ", | |
41 | self, |
|
42 | self, | |
42 | statusTip="Export History as Python File", |
|
43 | statusTip="Export History as Python File", | |
43 | triggered=self.save_magic) |
|
44 | triggered=self.save_magic) | |
|
45 | self.save_action.setDisabled(True) | |||
44 | self.addAction(self.save_action) |
|
46 | self.addAction(self.save_action) | |
45 |
|
47 | |||
46 | #--------------------------------------------------------------------------- |
|
48 | #--------------------------------------------------------------------------- |
@@ -103,44 +103,110 class MainWindow(QtGui.QMainWindow): | |||||
103 | # it with possible action, don't do it on other platform |
|
103 | # it with possible action, don't do it on other platform | |
104 | # as some user might not want the menu bar, or give them |
|
104 | # as some user might not want the menu bar, or give them | |
105 | # an option to remove it |
|
105 | # an option to remove it | |
106 | if sys.platform == 'darwin': |
|
|||
107 | #create menu in the order they should appear in the menu bar |
|
|||
108 | self.fileMenu = self.menuBar().addMenu("File") |
|
|||
109 | self.editMenu = self.menuBar().addMenu("Edit") |
|
|||
110 | self.fontMenu = self.menuBar().addMenu("Font") |
|
|||
111 | self.windowMenu = self.menuBar().addMenu("Window") |
|
|||
112 | self.magicMenu = self.menuBar().addMenu("Magic") |
|
|||
113 |
|
||||
114 | # please keep the Help menu in Mac Os even if empty. It will |
|
|||
115 | # automatically contain a search field to search inside menus and |
|
|||
116 | # please keep it spelled in English, as long as Qt Doesn't support |
|
|||
117 | # a QAction.MenuRole like HelpMenuRole otherwise it will loose |
|
|||
118 | # this search field fonctionnality |
|
|||
119 |
|
||||
120 | self.helpMenu = self.menuBar().addMenu("Help") |
|
|||
121 |
|
||||
122 | # sould wrap every line of the following block into a try/except, |
|
|||
123 | # as we are not sure of instanciating a _frontend which support all |
|
|||
124 | # theses actions, but there might be a better way |
|
|||
125 |
|
106 | |||
|
107 | def initMenuBar(self): | |||
|
108 | #create menu in the order they should appear in the menu bar | |||
|
109 | self.fileMenu = self.menuBar().addMenu("File") | |||
|
110 | self.editMenu = self.menuBar().addMenu("Edit") | |||
|
111 | self.fontMenu = self.menuBar().addMenu("Font") | |||
|
112 | self.windowMenu = self.menuBar().addMenu("Window") | |||
|
113 | self.magicMenu = self.menuBar().addMenu("Magic") | |||
|
114 | ||||
|
115 | # please keep the Help menu in Mac Os even if empty. It will | |||
|
116 | # automatically contain a search field to search inside menus and | |||
|
117 | # please keep it spelled in English, as long as Qt Doesn't support | |||
|
118 | # a QAction.MenuRole like HelpMenuRole otherwise it will loose | |||
|
119 | # this search field fonctionnality | |||
|
120 | ||||
|
121 | self.helpMenu = self.menuBar().addMenu("Help") | |||
|
122 | ||||
|
123 | # sould wrap every line of the following block into a try/except, | |||
|
124 | # as we are not sure of instanciating a _frontend which support all | |||
|
125 | # theses actions, but there might be a better way | |||
|
126 | try: | |||
126 | self.fileMenu.addAction(self._frontend.print_action) |
|
127 | self.fileMenu.addAction(self._frontend.print_action) | |
|
128 | except AttributeError: | |||
|
129 | print "trying to add unexisting action, skipping" | |||
|
130 | ||||
|
131 | try: | |||
127 | self.fileMenu.addAction(self._frontend.export_action) |
|
132 | self.fileMenu.addAction(self._frontend.export_action) | |
|
133 | except AttributeError: | |||
|
134 | print "trying to add unexisting action, skipping" | |||
|
135 | ||||
|
136 | try: | |||
128 | self.fileMenu.addAction(self._frontend.select_all_action) |
|
137 | self.fileMenu.addAction(self._frontend.select_all_action) | |
|
138 | except AttributeError: | |||
|
139 | print "trying to add unexisting action, skipping" | |||
129 |
|
140 | |||
|
141 | try: | |||
130 | self.editMenu.addAction(self._frontend.undo_action) |
|
142 | self.editMenu.addAction(self._frontend.undo_action) | |
|
143 | self._frontend.undo_action.setEnabled(True) | |||
|
144 | except AttributeError: | |||
|
145 | print "trying to add unexisting action, skipping" | |||
|
146 | ||||
|
147 | try: | |||
131 | self.editMenu.addAction(self._frontend.redo_action) |
|
148 | self.editMenu.addAction(self._frontend.redo_action) | |
|
149 | self._frontend.redo_action.setEnabled(True) | |||
|
150 | except AttributeError: | |||
|
151 | print "trying to add unexisting action, skipping" | |||
132 |
|
152 | |||
|
153 | try: | |||
133 | self.fontMenu.addAction(self._frontend.increase_font_size) |
|
154 | self.fontMenu.addAction(self._frontend.increase_font_size) | |
|
155 | except AttributeError: | |||
|
156 | print "trying to add unexisting action, skipping" | |||
|
157 | ||||
|
158 | try: | |||
134 | self.fontMenu.addAction(self._frontend.decrease_font_size) |
|
159 | self.fontMenu.addAction(self._frontend.decrease_font_size) | |
|
160 | except AttributeError: | |||
|
161 | print "trying to add unexisting action, skipping" | |||
|
162 | ||||
|
163 | try: | |||
135 | self.fontMenu.addAction(self._frontend.reset_font_size) |
|
164 | self.fontMenu.addAction(self._frontend.reset_font_size) | |
|
165 | except AttributeError: | |||
|
166 | print "trying to add unexisting action, skipping" | |||
136 |
|
167 | |||
|
168 | try: | |||
137 | self.magicMenu.addAction(self._frontend.reset_action) |
|
169 | self.magicMenu.addAction(self._frontend.reset_action) | |
|
170 | self._frontend.reset_action.setEnabled(True) | |||
|
171 | except AttributeError: | |||
|
172 | print "trying to add unexisting action, skipping" | |||
|
173 | ||||
|
174 | try: | |||
138 | self.magicMenu.addAction(self._frontend.history_action) |
|
175 | self.magicMenu.addAction(self._frontend.history_action) | |
|
176 | self._frontend.history_action.setEnabled(True) | |||
|
177 | except AttributeError: | |||
|
178 | print "trying to add unexisting action, skipping" | |||
|
179 | ||||
|
180 | try: | |||
139 | self.magicMenu.addAction(self._frontend.save_action) |
|
181 | self.magicMenu.addAction(self._frontend.save_action) | |
|
182 | self._frontend.save_action.setEnabled(True) | |||
|
183 | except AttributeError: | |||
|
184 | print "trying to add unexisting action, skipping" | |||
|
185 | ||||
|
186 | try: | |||
140 | self.magicMenu.addAction(self._frontend.clear_action) |
|
187 | self.magicMenu.addAction(self._frontend.clear_action) | |
|
188 | self._frontend.clear_action.setEnabled(True) | |||
|
189 | except AttributeError: | |||
|
190 | print "trying to add unexisting action, skipping" | |||
|
191 | ||||
|
192 | try: | |||
141 | self.magicMenu.addAction(self._frontend.who_action) |
|
193 | self.magicMenu.addAction(self._frontend.who_action) | |
|
194 | self._frontend.who_action.setEnabled(True) | |||
|
195 | except AttributeError: | |||
|
196 | print "trying to add unexisting action, skipping" | |||
|
197 | ||||
|
198 | try: | |||
142 | self.magicMenu.addAction(self._frontend.who_ls_action) |
|
199 | self.magicMenu.addAction(self._frontend.who_ls_action) | |
|
200 | self._frontend.who_ls_action.setEnabled(True) | |||
|
201 | except AttributeError: | |||
|
202 | print "trying to add unexisting action, skipping" | |||
|
203 | ||||
|
204 | try: | |||
143 | self.magicMenu.addAction(self._frontend.whos_action) |
|
205 | self.magicMenu.addAction(self._frontend.whos_action) | |
|
206 | self._frontend.whos_action.setEnabled(True) | |||
|
207 | except AttributeError: | |||
|
208 | print "trying to add unexisting action, skipping" | |||
|
209 | ||||
144 |
|
210 | |||
145 | #--------------------------------------------------------------------------- |
|
211 | #--------------------------------------------------------------------------- | |
146 | # QWidget interface |
|
212 | # QWidget interface | |
@@ -537,6 +603,7 class IPythonQtConsoleApp(BaseIPythonApplication): | |||||
537 | self.window = MainWindow(self.app, self.widget, self.existing, |
|
603 | self.window = MainWindow(self.app, self.widget, self.existing, | |
538 | may_close=local_kernel, |
|
604 | may_close=local_kernel, | |
539 | confirm_exit=self.confirm_exit) |
|
605 | confirm_exit=self.confirm_exit) | |
|
606 | self.window.initMenuBar() | |||
540 | self.window.setWindowTitle('Python' if self.pure else 'IPython') |
|
607 | self.window.setWindowTitle('Python' if self.pure else 'IPython') | |
541 |
|
608 | |||
542 | def init_colors(self): |
|
609 | def init_colors(self): |
General Comments 0
You need to be logged in to leave comments.
Login now