Permalink
Browse files

unwrap adding action from try/except, add %guiref and '?' in help menu

  • Loading branch information...
1 parent 564d1ca commit c48eab0df1df273ec1b11ae25dd8eb9315bc0047 @Carreau Carreau committed with fperez Oct 14, 2011
Showing with 110 additions and 137 deletions.
  1. +110 −137 IPython/frontend/qt/console/qtconsoleapp.py
@@ -339,148 +339,115 @@ def init_menu_bar(self):
# sould wrap every line of the following block into a try/except,
# as we are not sure of instanciating a _frontend which support all
# theses actions, but there might be a better way
- try:
- self.print_action = QtGui.QAction("&Print",
- self,
- shortcut="Ctrl+P",
- triggered=self.print_action_active_frontend)
- self.file_menu.addAction(self.print_action)
- except AttributeError:
- self.log.error("trying to add unexisting action (print), skipping")
-
- try:
- self.export_action=QtGui.QAction("E&xport",
- self,
- shortcut="Ctrl+S",
- triggered=self.export_action_active_frontend
- )
- self.file_menu.addAction(self.export_action)
- except AttributeError:
- self.log.error("trying to add unexisting action (Export), skipping")
-
- try:
- self.select_all_action = QtGui.QAction("Select &All",
- self,
- shortcut="Ctrl+A",
- triggered=self.select_all_active_frontend
- )
- self.file_menu.addAction(self.select_all_action)
- except AttributeError:
- self.log.error("trying to add unexisting action (select all), skipping")
-
- try:
- self.undo_action = QtGui.QAction("&Undo",
- self,
- shortcut="Ctrl+Z",
- statusTip="Undo last action if possible",
- triggered=self.undo_active_frontend
- )
- self.edit_menu.addAction(self.undo_action)
- except AttributeError:
- self.log.error("trying to add unexisting action (undo), skipping")
-
- try:
- self.redo_action = QtGui.QAction("&Redo",
- self,
- shortcut="Ctrl+Shift+Z",
- statusTip="Redo last action if possible",
- triggered=self.redo_active_frontend)
- self.edit_menu.addAction(self.redo_action)
- except AttributeError:
- self.log.error("trying to add unexisting action (redo), skipping")
-
- try:
- self.increase_font_size = QtGui.QAction("&Increase Font Size",
- self,
- shortcut="Ctrl++",
- triggered=self.increase_font_size_active_frontend
- )
- self.font_menu.addAction(self.increase_font_size)
- except AttributeError:
- self.log.error("trying to add unexisting action (increase font size), skipping")
-
- try:
- self.decrease_font_size = QtGui.QAction("&Decrease Font Size",
- self,
- shortcut="Ctrl+-",
- triggered=self.decrease_font_size_active_frontend
- )
- self.font_menu.addAction(self.decrease_font_size)
- except AttributeError:
- self.log.error("trying to add unexisting action (decrease font size), skipping")
-
- try:
- self.reset_font_size = QtGui.QAction("&Reset Font Size",
- self,
- shortcut="Ctrl+0",
- triggered=self.reset_font_size_active_frontend
- )
- self.font_menu.addAction(self.reset_font_size)
- except AttributeError:
- self.log.error("trying to add unexisting action (reset font size), skipping")
-
- try:
- self.reset_action = QtGui.QAction("&Reset",
- self,
- statusTip="Clear all varible from workspace",
- triggered=self.reset_magic_active_frontend)
- self.magic_menu.addAction(self.reset_action)
- except AttributeError:
- self.log.error("trying to add unexisting action (reset), skipping")
-
- try:
- self.history_action = QtGui.QAction("&History",
- self,
- statusTip="show command history",
- triggered=self.history_magic_active_frontend)
- self.magic_menu.addAction(self.history_action)
- except AttributeError:
- self.log.error("trying to add unexisting action (history), skipping")
+ self.print_action = QtGui.QAction("&Print",
+ self,
+ shortcut="Ctrl+P",
+ triggered=self.print_action_active_frontend)
+ self.file_menu.addAction(self.print_action)
+
+ self.export_action=QtGui.QAction("E&xport",
+ self,
+ shortcut="Ctrl+S",
+ triggered=self.export_action_active_frontend
+ )
+ self.file_menu.addAction(self.export_action)
- try:
- self.save_action = QtGui.QAction("E&xport History ",
- self,
- statusTip="Export History as Python File",
- triggered=self.save_magic_active_frontend)
- self.magic_menu.addAction(self.save_action)
- except AttributeError:
- self.log.error("trying to add unexisting action (save), skipping")
+ self.select_all_action = QtGui.QAction("Select &All",
+ self,
+ shortcut="Ctrl+A",
+ triggered=self.select_all_active_frontend
+ )
+ self.file_menu.addAction(self.select_all_action)
- try:
- self.clear_action = QtGui.QAction("&Clear",
- self,
- statusTip="Clear the console",
- triggered=self.clear_magic_active_frontend)
- self.magic_menu.addAction(self.clear_action)
- except AttributeError:
- self.log.error("trying to add unexisting action, skipping")
+ self.undo_action = QtGui.QAction("&Undo",
+ self,
+ shortcut="Ctrl+Z",
+ statusTip="Undo last action if possible",
+ triggered=self.undo_active_frontend
+ )
+ self.edit_menu.addAction(self.undo_action)
+
+ self.redo_action = QtGui.QAction("&Redo",
+ self,
+ shortcut="Ctrl+Shift+Z",
+ statusTip="Redo last action if possible",
+ triggered=self.redo_active_frontend)
+ self.edit_menu.addAction(self.redo_action)
+
+ self.increase_font_size = QtGui.QAction("&Increase Font Size",
+ self,
+ shortcut="Ctrl++",
+ triggered=self.increase_font_size_active_frontend
+ )
+ self.font_menu.addAction(self.increase_font_size)
- try:
- self.who_action = QtGui.QAction("&Who",
- self,
- statusTip="List interactive variable",
- triggered=self.who_magic_active_frontend)
- self.magic_menu.addAction(self.who_action)
- except AttributeError:
- self.log.error("trying to add unexisting action (who), skipping")
+ self.decrease_font_size = QtGui.QAction("&Decrease Font Size",
+ self,
+ shortcut="Ctrl+-",
+ triggered=self.decrease_font_size_active_frontend
+ )
+ self.font_menu.addAction(self.decrease_font_size)
- try:
- self.who_ls_action = QtGui.QAction("Wh&o ls",
- self,
- statusTip="Return a list of interactive variable",
- triggered=self.who_ls_magic_active_frontend)
- self.magic_menu.addAction(self.who_ls_action)
- except AttributeError:
- self.log.error("trying to add unexisting action (who_ls), skipping")
+ self.reset_font_size = QtGui.QAction("&Reset Font Size",
+ self,
+ shortcut="Ctrl+0",
+ triggered=self.reset_font_size_active_frontend
+ )
+ self.font_menu.addAction(self.reset_font_size)
+
+ self.reset_action = QtGui.QAction("&Reset",
+ self,
+ statusTip="Clear all varible from workspace",
+ triggered=self.reset_magic_active_frontend)
+ self.magic_menu.addAction(self.reset_action)
+
+ self.history_action = QtGui.QAction("&History",
+ self,
+ statusTip="show command history",
+ triggered=self.history_magic_active_frontend)
+ self.magic_menu.addAction(self.history_action)
+
+ self.save_action = QtGui.QAction("E&xport History ",
+ self,
+ statusTip="Export History as Python File",
+ triggered=self.save_magic_active_frontend)
+ self.magic_menu.addAction(self.save_action)
+
+ self.clear_action = QtGui.QAction("&Clear",
+ self,
+ statusTip="Clear the console",
+ triggered=self.clear_magic_active_frontend)
+ self.magic_menu.addAction(self.clear_action)
+
+ self.who_action = QtGui.QAction("&Who",
+ self,
+ statusTip="List interactive variable",
+ triggered=self.who_magic_active_frontend)
+ self.magic_menu.addAction(self.who_action)
+
+ self.who_ls_action = QtGui.QAction("Wh&o ls",
+ self,
+ statusTip="Return a list of interactive variable",
+ triggered=self.who_ls_magic_active_frontend)
+ self.magic_menu.addAction(self.who_ls_action)
+
+ self.whos_action = QtGui.QAction("Who&s",
+ self,
+ statusTip="List interactive variable with detail",
+ triggered=self.whos_magic_active_frontend)
+ self.magic_menu.addAction(self.whos_action)
+
+ self.intro_active_frontend_action = QtGui.QAction("intro",
+ self,
+ triggered=self.intro_active_frontend
+ )
+ self.help_menu.addAction(self.intro_active_frontend_action)
- try:
- self.whos_action = QtGui.QAction("Who&s",
- self,
- statusTip="List interactive variable with detail",
- triggered=self.whos_magic_active_frontend)
- self.magic_menu.addAction(self.whos_action)
- except AttributeError:
- self.log.error("trying to add unexisting action (whos), skipping")
+ self.guiref_active_frontend_action = QtGui.QAction("guiref",
+ self,
+ triggered=self.guiref_active_frontend
+ )
+ self.help_menu.addAction(self.guiref_active_frontend_action)
def undo_active_frontend(self):
self.active_frontend.undo()
@@ -517,6 +484,12 @@ def decrease_font_size_active_frontend(self):
self.active_frontend.decrease_font_size.trigger()
def reset_font_size_active_frontend(self):
self.active_frontend.reset_font_size.trigger()
+
+ def guiref_active_frontend(self):
+ self.active_frontend.execute("%guiref")
+
+ def intro_active_frontend(self):
+ self.active_frontend.execute("?")
#---------------------------------------------------------------------------
# QWidget interface
#---------------------------------------------------------------------------

0 comments on commit c48eab0

Please sign in to comment.