Skip to content

Commit

Permalink
unwrap adding action from try/except, add %guiref and '?' in help menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Carreau authored and fperez committed Oct 17, 2011
1 parent 564d1ca commit c48eab0
Showing 1 changed file with 110 additions and 137 deletions.
247 changes: 110 additions & 137 deletions IPython/frontend/qt/console/qtconsoleapp.py
Expand Up @@ -339,148 +339,115 @@ def init_menu_bar(self):
# sould wrap every line of the following block into a try/except, # sould wrap every line of the following block into a try/except,
# as we are not sure of instanciating a _frontend which support all # as we are not sure of instanciating a _frontend which support all
# theses actions, but there might be a better way # theses actions, but there might be a better way
try: self.print_action = QtGui.QAction("&Print",
self.print_action = QtGui.QAction("&Print", self,
self, shortcut="Ctrl+P",
shortcut="Ctrl+P", triggered=self.print_action_active_frontend)
triggered=self.print_action_active_frontend) self.file_menu.addAction(self.print_action)
self.file_menu.addAction(self.print_action)
except AttributeError: self.export_action=QtGui.QAction("E&xport",
self.log.error("trying to add unexisting action (print), skipping") self,

shortcut="Ctrl+S",
try: triggered=self.export_action_active_frontend
self.export_action=QtGui.QAction("E&xport", )
self, self.file_menu.addAction(self.export_action)
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")


try: self.select_all_action = QtGui.QAction("Select &All",
self.save_action = QtGui.QAction("E&xport History ", self,
self, shortcut="Ctrl+A",
statusTip="Export History as Python File", triggered=self.select_all_active_frontend
triggered=self.save_magic_active_frontend) )
self.magic_menu.addAction(self.save_action) self.file_menu.addAction(self.select_all_action)
except AttributeError:
self.log.error("trying to add unexisting action (save), skipping")


try: self.undo_action = QtGui.QAction("&Undo",
self.clear_action = QtGui.QAction("&Clear", self,
self, shortcut="Ctrl+Z",
statusTip="Clear the console", statusTip="Undo last action if possible",
triggered=self.clear_magic_active_frontend) triggered=self.undo_active_frontend
self.magic_menu.addAction(self.clear_action) )
except AttributeError: self.edit_menu.addAction(self.undo_action)
self.log.error("trying to add unexisting action, skipping")
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.decrease_font_size = QtGui.QAction("&Decrease Font Size",
self.who_action = QtGui.QAction("&Who", self,
self, shortcut="Ctrl+-",
statusTip="List interactive variable", triggered=self.decrease_font_size_active_frontend
triggered=self.who_magic_active_frontend) )
self.magic_menu.addAction(self.who_action) self.font_menu.addAction(self.decrease_font_size)
except AttributeError:
self.log.error("trying to add unexisting action (who), skipping")


try: self.reset_font_size = QtGui.QAction("&Reset Font Size",
self.who_ls_action = QtGui.QAction("Wh&o ls", self,
self, shortcut="Ctrl+0",
statusTip="Return a list of interactive variable", triggered=self.reset_font_size_active_frontend
triggered=self.who_ls_magic_active_frontend) )
self.magic_menu.addAction(self.who_ls_action) self.font_menu.addAction(self.reset_font_size)
except AttributeError:
self.log.error("trying to add unexisting action (who_ls), skipping") 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.guiref_active_frontend_action = QtGui.QAction("guiref",
self.whos_action = QtGui.QAction("Who&s", self,
self, triggered=self.guiref_active_frontend
statusTip="List interactive variable with detail", )
triggered=self.whos_magic_active_frontend) self.help_menu.addAction(self.guiref_active_frontend_action)
self.magic_menu.addAction(self.whos_action)
except AttributeError:
self.log.error("trying to add unexisting action (whos), skipping")


def undo_active_frontend(self): def undo_active_frontend(self):
self.active_frontend.undo() self.active_frontend.undo()
Expand Down Expand Up @@ -517,6 +484,12 @@ def decrease_font_size_active_frontend(self):
self.active_frontend.decrease_font_size.trigger() self.active_frontend.decrease_font_size.trigger()
def reset_font_size_active_frontend(self): def reset_font_size_active_frontend(self):
self.active_frontend.reset_font_size.trigger() 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 # QWidget interface
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
Expand Down

0 comments on commit c48eab0

Please sign in to comment.