Skip to content

Commit

Permalink
Add Slot decorator to all slots of actions and buttons in spyder.py
Browse files Browse the repository at this point in the history
- This is for PyQt4 compatibility
  • Loading branch information
ccordoba12 committed Dec 9, 2014
1 parent 5afc3e1 commit 0c485fd
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 19 deletions.
3 changes: 2 additions & 1 deletion spyderlib/plugins/inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,8 @@ def show_plain_text(self, text):
self.raise_()
self.switch_to_plain_text()
self.set_plain_text(text, is_code=False)


@Slot()
def show_tutorial(self):
tutorial_path = get_module_source_path('spyderlib.utils.inspector')
img_path = osp.join(tutorial_path, 'static', 'images')
Expand Down
9 changes: 6 additions & 3 deletions spyderlib/plugins/ipythonconsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -1170,17 +1170,20 @@ def go_to_error(self, text):
if match:
fname, lnb = match.groups()
self.edit_goto.emit(osp.abspath(fname), int(lnb), '')


@Slot()
def show_intro(self):
"""Show intro to IPython help"""
from IPython.core.usage import interactive_usage
self.inspector.show_rich_text(interactive_usage)


@Slot()
def show_guiref(self):
"""Show qtconsole help"""
from IPython.core.usage import gui_reference
self.inspector.show_rich_text(gui_reference, collapse=True)


@Slot()
def show_quickref(self):
"""Show IPython Cheat Sheet"""
from IPython.core.usage import quick_reference
Expand Down
51 changes: 36 additions & 15 deletions spyderlib/spyder.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@
QPixmap, QMessageBox, QMenu, QColor, QShortcut,
QKeySequence, QDockWidget, QAction,
QDesktopServices)
from spyderlib.qt.QtCore import Signal, QPoint, Qt, QSize, QByteArray, QUrl
from spyderlib.qt.QtCore import (Signal, QPoint, Qt, QSize, QByteArray, QUrl,
Slot)
from spyderlib.qt.compat import (from_qvariant, getopenfilename,
getsavefilename)
# Avoid a "Cannot mix incompatible Qt library" error on Windows platforms
Expand Down Expand Up @@ -656,7 +657,8 @@ def create_edit_action(text, tr_text, icon_name):
menurole=QAction.ApplicationSpecificRole)
update_modules_action = create_action(self,
_("Update module names list"),
triggered=module_completion.reset,
triggered=lambda:
module_completion.reset(),
tip=_("Refresh list of module names "
"available in PYTHONPATH"))
self.tools_menu_actions = [prefs_action, spyder_path_action]
Expand Down Expand Up @@ -1074,7 +1076,8 @@ def add_xydoc(text, pathlist):
if set_attached_console_visible is not None:
cmd_act = create_action(self,
_("Attached console window (debugging)"),
toggled=set_attached_console_visible)
toggled=lambda state:
set_attached_console_visible(state))
cmd_act.setChecked(is_attached_console_visible())
add_actions(self.view_menu, (None, cmd_act))
add_actions(self.view_menu, (None, self.fullscreen_action,
Expand Down Expand Up @@ -1370,6 +1373,7 @@ def setup_layout(self, default=False):
for plugin in self.widgetlist:
plugin.initialize_plugin_in_mainwindow_layout()

@Slot()
def reset_window_layout(self):
"""Reset window layout to default"""
answer = QMessageBox.warning(self, _("Warning"),
Expand Down Expand Up @@ -1633,7 +1637,8 @@ def add_dockwidget(self, child):
QDockWidget.DockWidgetVerticalTitleBar)
self.addDockWidget(location, dockwidget)
self.widgetlist.append(child)


@Slot()
def close_current_dockwidget(self):
widget = QApplication.focusWidget()
for plugin in self.widgetlist:
Expand All @@ -1653,7 +1658,8 @@ def __update_maximize_action(self):
self.maximize_action.setText(text)
self.maximize_action.setIcon(get_icon(icon))
self.maximize_action.setToolTip(tip)


@Slot()
def maximize_dockwidget(self, restore=False):
"""Shortcut: Ctrl+Alt+Shift+M
First call: maximize current dockwidget
Expand Down Expand Up @@ -1698,7 +1704,8 @@ def __update_fullscreen_action(self):
else:
icon = "window_fullscreen.png"
self.fullscreen_action.setIcon(get_icon(icon))


@Slot()
def toggle_fullscreen(self):
if self.isFullScreen():
self.fullscreen_flag = False
Expand All @@ -1717,6 +1724,7 @@ def add_to_toolbar(self, toolbar, widget):
if actions is not None:
add_actions(toolbar, actions)

@Slot()
def about(self):
"""About Spyder"""
versions = get_versions()
Expand Down Expand Up @@ -1761,6 +1769,7 @@ def about(self):
versions['bitness'], versions['qt'], versions['qt_api'],
versions['qt_api_ver'], versions['system']))

@Slot()
def show_dependencies(self):
"""Show Spyder's Optional Dependencies dialog box"""
from spyderlib.widgets.dependencies import DependenciesDialog
Expand All @@ -1769,6 +1778,7 @@ def show_dependencies(self):
dlg.show()
dlg.exec_()

@Slot()
def report_issue(self):
if PY3:
from urllib.parse import quote
Expand Down Expand Up @@ -1809,7 +1819,8 @@ def report_issue(self):
url = QUrl("http://code.google.com/p/spyderlib/issues/entry")
url.addEncodedQueryItem("comment", quote(issue_template))
QDesktopServices.openUrl(url)


@Slot()
def google_group(self):
url = QUrl("http://groups.google.com/group/spyderlib")
QDesktopServices.openUrl(url)
Expand All @@ -1835,33 +1846,38 @@ def get_current_editor_plugin(self):
while not isinstance(plugin, EditorWidget):
plugin = plugin.parent()
return plugin


@Slot()
def find(self):
"""Global find callback"""
plugin = self.get_current_editor_plugin()
if plugin is not None:
plugin.find_widget.show()
plugin.find_widget.search_text.setFocus()
return plugin


@Slot()
def find_next(self):
"""Global find next callback"""
plugin = self.get_current_editor_plugin()
if plugin is not None:
plugin.find_widget.find_next()


@Slot()
def find_previous(self):
"""Global find previous callback"""
plugin = self.get_current_editor_plugin()
if plugin is not None:
plugin.find_widget.find_previous()


@Slot()
def replace(self):
"""Global replace callback"""
plugin = self.find()
if plugin is not None:
plugin.find_widget.show_replace()

@Slot()
def global_callback(self):
"""Global callback"""
widget = QApplication.focusWidget()
Expand Down Expand Up @@ -1961,7 +1977,8 @@ def remove_path_from_sys_path(self):
sys_path = sys.path
while sys_path[1] in self.get_spyder_pythonpath():
sys_path.pop(1)


@Slot()
def path_manager_callback(self):
"""Spyder path manager"""
from spyderlib.widgets.pathmanager import PathManager
Expand All @@ -1980,7 +1997,8 @@ def pythonpath_changed(self):
self.project_path = self.projectexplorer.get_pythonpath()
self.add_path_to_sys_path()
self.sig_pythonpath_changed.emit()


@Slot()
def win_env(self):
"""Show Windows current user environment variables"""
self.dialog_manager.show(WinUserEnvDialog(self))
Expand Down Expand Up @@ -2014,7 +2032,8 @@ def apply_statusbar_settings(self):
if widget is not None:
widget.setVisible(CONF.get('main', '%s/enable' % name))
widget.set_interval(CONF.get('main', '%s/timeout' % name))


@Slot()
def edit_preferences(self):
"""Edit Spyder preferences"""
from spyderlib.plugins.configdialog import ConfigDialog
Expand Down Expand Up @@ -2085,6 +2104,7 @@ def apply_shortcuts(self):
self.shortcut_data.pop(index)

#---- Sessions
@Slot()
def load_session(self, filename=None):
"""Load session"""
if filename is None:
Expand All @@ -2096,7 +2116,8 @@ def load_session(self, filename=None):
return
if self.close():
self.next_session_name = filename


@Slot()
def save_session(self):
"""Save session and quit application"""
self.redirect_internalshell_stdio(False)
Expand Down

0 comments on commit 0c485fd

Please sign in to comment.