diff --git a/external-deps/qdarkstyle/qdarkstyle/example/__main__.py b/external-deps/qdarkstyle/qdarkstyle/example/__main__.py
index b3d84e497d4..6e133c9e17b 100644
--- a/external-deps/qdarkstyle/qdarkstyle/example/__main__.py
+++ b/external-deps/qdarkstyle/qdarkstyle/example/__main__.py
@@ -160,11 +160,11 @@ def main():
dw_buttons = QtWidgets.QDockWidget()
dw_buttons.setObjectName('buttons')
uic.loadUi(os.path.join(here, 'ui/dw_buttons.ui'), dw_buttons)
- window.addDockWidget(QtCore.Qt.RightDockWidgetArea, dw_buttons)
+ window.addDockWidget(QtCore.Qt.DockWidgetArea.RightDockWidgetArea, dw_buttons)
# Set state indeterminate #275
dw_buttons.checkBoxTristate.stateChanged.connect(dw_buttons.checkBoxTristateDis.setCheckState)
- dw_buttons.checkBoxTristate.setCheckState(QtCore.Qt.PartiallyChecked)
+ dw_buttons.checkBoxTristate.setCheckState(QtCore.Qt.CheckState.PartiallyChecked)
# Add actions on popup toolbuttons
menu = QtWidgets.QMenu()
@@ -199,43 +199,43 @@ def main():
dw_displays = QtWidgets.QDockWidget()
dw_displays.setObjectName('displays')
uic.loadUi(os.path.join(here, 'ui/dw_displays.ui'), dw_displays)
- window.addDockWidget(QtCore.Qt.RightDockWidgetArea, dw_displays)
+ window.addDockWidget(QtCore.Qt.DockWidgetArea.RightDockWidgetArea, dw_displays)
# Create docks for inputs - no fields
dw_inputs_no_fields = QtWidgets.QDockWidget()
dw_inputs_no_fields.setObjectName('inputs_no_fields')
uic.loadUi(os.path.join(here, 'ui/dw_inputs_no_fields.ui'), dw_inputs_no_fields)
- window.addDockWidget(QtCore.Qt.RightDockWidgetArea, dw_inputs_no_fields)
+ window.addDockWidget(QtCore.Qt.DockWidgetArea.RightDockWidgetArea, dw_inputs_no_fields)
# Create docks for inputs - fields
dw_inputs_fields = QtWidgets.QDockWidget()
dw_inputs_fields.setObjectName('inputs_fields')
uic.loadUi(os.path.join(here, 'ui/dw_inputs_fields.ui'), dw_inputs_fields)
- window.addDockWidget(QtCore.Qt.RightDockWidgetArea, dw_inputs_fields)
+ window.addDockWidget(QtCore.Qt.DockWidgetArea.RightDockWidgetArea, dw_inputs_fields)
# Create docks for widgets
dw_widgets = QtWidgets.QDockWidget()
dw_widgets.setObjectName('widgets')
uic.loadUi(os.path.join(here, 'ui/dw_widgets.ui'), dw_widgets)
- window.addDockWidget(QtCore.Qt.LeftDockWidgetArea, dw_widgets)
+ window.addDockWidget(QtCore.Qt.DockWidgetArea.LeftDockWidgetArea, dw_widgets)
# Create docks for views
dw_views = QtWidgets.QDockWidget()
dw_views.setObjectName('views')
uic.loadUi(os.path.join(here, 'ui/dw_views.ui'), dw_views)
- window.addDockWidget(QtCore.Qt.LeftDockWidgetArea, dw_views)
+ window.addDockWidget(QtCore.Qt.DockWidgetArea.LeftDockWidgetArea, dw_views)
# Create docks for containers - no tabs
dw_containers_no_tabs = QtWidgets.QDockWidget()
dw_containers_no_tabs.setObjectName('containers_no_tabs')
uic.loadUi(os.path.join(here, 'ui/dw_containers_no_tabs.ui'), dw_containers_no_tabs)
- window.addDockWidget(QtCore.Qt.LeftDockWidgetArea, dw_containers_no_tabs)
+ window.addDockWidget(QtCore.Qt.DockWidgetArea.LeftDockWidgetArea, dw_containers_no_tabs)
# Create docks for containters - tabs
dw_containers_tabs = QtWidgets.QDockWidget()
dw_containers_tabs.setObjectName('containers_tabs')
uic.loadUi(os.path.join(here, 'ui/dw_containers_tabs.ui'), dw_containers_tabs)
- window.addDockWidget(QtCore.Qt.LeftDockWidgetArea, dw_containers_tabs)
+ window.addDockWidget(QtCore.Qt.DockWidgetArea.LeftDockWidgetArea, dw_containers_tabs)
# Tabify right docks
window.tabifyDockWidget(dw_buttons, dw_displays)
diff --git a/external-deps/qtconsole/qtconsole/call_tip_widget.py b/external-deps/qtconsole/qtconsole/call_tip_widget.py
index c66a6beee36..38f35dc0537 100644
--- a/external-deps/qtconsole/qtconsole/call_tip_widget.py
+++ b/external-deps/qtconsole/qtconsole/call_tip_widget.py
@@ -32,7 +32,7 @@ def __init__(self, text_edit):
self.setBackgroundRole(QtGui.QPalette.ToolTipBase)
self.setPalette(QtWidgets.QToolTip.palette())
- self.setAlignment(QtCore.Qt.AlignLeft)
+ self.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeft)
self.setIndent(1)
self.setFrameStyle(QtWidgets.QFrame.NoFrame)
self.setMargin(1 + self.style().pixelMetric(
diff --git a/external-deps/qtconsole/qtconsole/completion_widget.py b/external-deps/qtconsole/qtconsole/completion_widget.py
index 26e292caa1b..6944ffa132c 100644
--- a/external-deps/qtconsole/qtconsole/completion_widget.py
+++ b/external-deps/qtconsole/qtconsole/completion_widget.py
@@ -36,7 +36,7 @@ def __init__(self, console_widget, height=0):
self.setAttribute(QtCore.Qt.WA_StaticContents)
original_policy = text_edit.focusPolicy()
- self.setFocusPolicy(QtCore.Qt.NoFocus)
+ self.setFocusPolicy(QtCore.Qt.FocusPolicy.NoFocus)
text_edit.setFocusPolicy(original_policy)
# Ensure that the text edit keeps focus when widget is displayed.
diff --git a/external-deps/qtconsole/qtconsole/console_widget.py b/external-deps/qtconsole/qtconsole/console_widget.py
index 447be581e2b..b606bea5624 100644
--- a/external-deps/qtconsole/qtconsole/console_widget.py
+++ b/external-deps/qtconsole/qtconsole/console_widget.py
@@ -253,9 +253,9 @@ def __init__(self, parent=None, **kw):
if self.paging in ('hsplit', 'vsplit'):
self._splitter = QtWidgets.QSplitter()
if self.paging == 'hsplit':
- self._splitter.setOrientation(QtCore.Qt.Horizontal)
+ self._splitter.setOrientation(QtCore.Qt.Orientation.Horizontal)
else:
- self._splitter.setOrientation(QtCore.Qt.Vertical)
+ self._splitter.setOrientation(QtCore.Qt.Orientation.Vertical)
self._splitter.addWidget(self._control)
layout.addWidget(self._splitter)
else:
@@ -324,14 +324,14 @@ def __init__(self, parent=None, **kw):
# Qt ctrl = cmd on OSX, so the match gets a false positive on OSX.
printkey = "Ctrl+Shift+P"
action.setShortcut(printkey)
- action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
+ action.setShortcutContext(QtCore.Qt.ShortcutContext.WidgetWithChildrenShortcut)
action.triggered.connect(self.print_)
self.addAction(action)
self.print_action = action
action = QtWidgets.QAction('Save as HTML/XML', None)
action.setShortcut(QtGui.QKeySequence.Save)
- action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
+ action.setShortcutContext(QtCore.Qt.ShortcutContext.WidgetWithChildrenShortcut)
action.triggered.connect(self.export_html)
self.addAction(action)
self.export_action = action
@@ -344,7 +344,7 @@ def __init__(self, parent=None, **kw):
# Qt ctrl = cmd on OSX, so the match gets a false positive on OSX.
selectall = "Ctrl+Shift+A"
action.setShortcut(selectall)
- action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
+ action.setShortcutContext(QtCore.Qt.ShortcutContext.WidgetWithChildrenShortcut)
action.triggered.connect(self.select_all_smart)
self.addAction(action)
self.select_all_action = action
@@ -352,7 +352,7 @@ def __init__(self, parent=None, **kw):
self.increase_font_size = QtWidgets.QAction("Bigger Font",
self,
shortcut=QtGui.QKeySequence.ZoomIn,
- shortcutContext=QtCore.Qt.WidgetWithChildrenShortcut,
+ shortcutContext=QtCore.Qt.ShortcutContext.WidgetWithChildrenShortcut,
statusTip="Increase the font size by one point",
triggered=self._increase_font_size)
self.addAction(self.increase_font_size)
@@ -360,7 +360,7 @@ def __init__(self, parent=None, **kw):
self.decrease_font_size = QtWidgets.QAction("Smaller Font",
self,
shortcut=QtGui.QKeySequence.ZoomOut,
- shortcutContext=QtCore.Qt.WidgetWithChildrenShortcut,
+ shortcutContext=QtCore.Qt.ShortcutContext.WidgetWithChildrenShortcut,
statusTip="Decrease the font size by one point",
triggered=self._decrease_font_size)
self.addAction(self.decrease_font_size)
@@ -368,7 +368,7 @@ def __init__(self, parent=None, **kw):
self.reset_font_size = QtWidgets.QAction("Normal Font",
self,
shortcut="Ctrl+0",
- shortcutContext=QtCore.Qt.WidgetWithChildrenShortcut,
+ shortcutContext=QtCore.Qt.ShortcutContext.WidgetWithChildrenShortcut,
statusTip="Restore the Normal font size",
triggered=self.reset_font)
self.addAction(self.reset_font_size)
@@ -432,7 +432,7 @@ def eventFilter(self, obj, event):
key in self._ctrl_down_remap:
new_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress,
self._ctrl_down_remap[key],
- QtCore.Qt.NoModifier)
+ QtCore.Qt.KeyboardModifier.NoModifier)
QtWidgets.QApplication.instance().sendEvent(obj, new_event)
return True
@@ -445,7 +445,7 @@ def eventFilter(self, obj, event):
# Make middle-click paste safe.
elif getattr(event, 'button', False) and \
etype == QtCore.QEvent.MouseButtonRelease and \
- event.button() == QtCore.Qt.MiddleButton and \
+ event.button() == QtCore.Qt.MouseButton.MiddleButton and \
obj == self._control.viewport():
cursor = self._control.cursorForPosition(event.pos())
self._control.setTextCursor(cursor)
@@ -1381,13 +1381,13 @@ def callback(complete, indent):
self._control.textCursor().insertText(chr(4))
new_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress,
QtCore.Qt.Key_Return,
- QtCore.Qt.NoModifier)
+ QtCore.Qt.KeyboardModifier.NoModifier)
QtWidgets.QApplication.instance().sendEvent(self._control, new_event)
intercepted = True
else:
new_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress,
QtCore.Qt.Key_Delete,
- QtCore.Qt.NoModifier)
+ QtCore.Qt.KeyboardModifier.NoModifier)
QtWidgets.QApplication.instance().sendEvent(self._control, new_event)
intercepted = True
@@ -1627,14 +1627,14 @@ def _event_filter_page_keypress(self, event):
QtCore.Qt.Key_Tab):
new_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress,
QtCore.Qt.Key_PageDown,
- QtCore.Qt.NoModifier)
+ QtCore.Qt.KeyboardModifier.NoModifier)
QtWidgets.QApplication.instance().sendEvent(self._page_control, new_event)
return True
elif key == QtCore.Qt.Key_Backspace:
new_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress,
QtCore.Qt.Key_PageUp,
- QtCore.Qt.NoModifier)
+ QtCore.Qt.KeyboardModifier.NoModifier)
QtWidgets.QApplication.instance().sendEvent(self._page_control, new_event)
return True
@@ -1642,7 +1642,7 @@ def _event_filter_page_keypress(self, event):
elif key == QtCore.Qt.Key_J:
new_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress,
QtCore.Qt.Key_Down,
- QtCore.Qt.NoModifier)
+ QtCore.Qt.KeyboardModifier.NoModifier)
QtWidgets.QApplication.instance().sendEvent(self._page_control, new_event)
return True
@@ -1650,7 +1650,7 @@ def _event_filter_page_keypress(self, event):
elif key == QtCore.Qt.Key_K:
new_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress,
QtCore.Qt.Key_Up,
- QtCore.Qt.NoModifier)
+ QtCore.Qt.KeyboardModifier.NoModifier)
QtWidgets.QApplication.instance().sendEvent(self._page_control, new_event)
return True
@@ -2352,9 +2352,9 @@ def _set_paging(self, paging):
raise NotImplementedError("""can only switch if --paging=hsplit or
--paging=vsplit is used.""")
if paging == 'hsplit':
- self._splitter.setOrientation(QtCore.Qt.Horizontal)
+ self._splitter.setOrientation(QtCore.Qt.Orientation.Horizontal)
elif paging == 'vsplit':
- self._splitter.setOrientation(QtCore.Qt.Vertical)
+ self._splitter.setOrientation(QtCore.Qt.Orientation.Vertical)
elif paging == 'inside':
raise NotImplementedError("""switching to 'inside' paging not
supported yet.""")
diff --git a/external-deps/qtconsole/qtconsole/frontend_widget.py b/external-deps/qtconsole/qtconsole/frontend_widget.py
index 02860bb6fd6..31465d64107 100644
--- a/external-deps/qtconsole/qtconsole/frontend_widget.py
+++ b/external-deps/qtconsole/qtconsole/frontend_widget.py
@@ -192,7 +192,7 @@ def __init__(self, local_kernel=_local_kernel, *args, **kw):
key = QtCore.Qt.CTRL | QtCore.Qt.SHIFT | QtCore.Qt.Key_C
action.setEnabled(False)
action.setShortcut(QtGui.QKeySequence(key))
- action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
+ action.setShortcutContext(QtCore.Qt.ShortcutContext.WidgetWithChildrenShortcut)
action.triggered.connect(self.copy_raw)
self.copy_available.connect(action.setEnabled)
self.addAction(action)
diff --git a/external-deps/qtconsole/qtconsole/mainwindow.py b/external-deps/qtconsole/qtconsole/mainwindow.py
index b5b0476a99c..7fb65240a5e 100644
--- a/external-deps/qtconsole/qtconsole/mainwindow.py
+++ b/external-deps/qtconsole/qtconsole/mainwindow.py
@@ -73,7 +73,7 @@ def __init__(self, app,
# hide tab bar at first, since we have no tabs:
self.tab_widget.tabBar().setVisible(False)
# prevent focus in tab bar
- self.tab_widget.setFocusPolicy(QtCore.Qt.NoFocus)
+ self.tab_widget.setFocusPolicy(QtCore.Qt.FocusPolicy.NoFocus)
def update_tab_bar_visibility(self):
""" update visibility of the tabBar depending of the number of tab
@@ -375,7 +375,7 @@ def add_menu_action(self, menu, action, defer_shortcut=False):
self.addAction(action)
if defer_shortcut:
- action.setShortcutContext(QtCore.Qt.WidgetShortcut)
+ action.setShortcutContext(QtCore.Qt.ShortcutContext.WidgetShortcut)
def init_menu_bar(self):
#create menu in the order they should appear in the menu bar
diff --git a/external-deps/qtconsole/qtconsole/tests/test_00_console_widget.py b/external-deps/qtconsole/qtconsole/tests/test_00_console_widget.py
index 40f9a0d7da9..d2d0c67b94a 100644
--- a/external-deps/qtconsole/qtconsole/tests/test_00_console_widget.py
+++ b/external-deps/qtconsole/qtconsole/tests/test_00_console_widget.py
@@ -328,9 +328,9 @@ def test_erase_in_line(self):
cursor.insertText('')
def test_link_handling(self):
- noButton = QtCore.Qt.NoButton
- noButtons = QtCore.Qt.NoButton
- noModifiers = QtCore.Qt.NoModifier
+ noButton = QtCore.Qt.MouseButton.NoButton
+ noButtons = QtCore.Qt.MouseButton.NoButton
+ noModifiers = QtCore.Qt.KeyboardModifier.NoModifier
MouseMove = QtCore.QEvent.MouseMove
QMouseEvent = QtGui.QMouseEvent
diff --git a/external-deps/qtconsole/qtconsole/tests/test_completion_widget.py b/external-deps/qtconsole/qtconsole/tests/test_completion_widget.py
index 506b13ee56d..c626edb1176 100644
--- a/external-deps/qtconsole/qtconsole/tests/test_completion_widget.py
+++ b/external-deps/qtconsole/qtconsole/tests/test_completion_widget.py
@@ -68,7 +68,7 @@ def test_droplist_completer_keyboard(self):
self.assertEqual(self.text_edit.toPlainText(), "item3")
def test_droplist_completer_mousepick(self):
- leftButton = QtCore.Qt.LeftButton
+ leftButton = QtCore.Qt.MouseButton.LeftButton
w = CompletionWidget(self.console)
w.show_items(self.text_edit.textCursor(), ["item1", "item2", "item3"])
diff --git a/scripts/spyder.bat b/scripts/spyder.bat
index 6519a3a5f45..352b3bfa737 100644
--- a/scripts/spyder.bat
+++ b/scripts/spyder.bat
@@ -1,6 +1,6 @@
-@echo off
-IF EXIST "%~dpn0\..\..\python.exe" (
- "%~dpn0\..\..\python.exe" "%~dpn0" %*
-) ELSE (
- python.exe "%~dpn0" %*
-)
+@echo off
+IF EXIST "%~dpn0\..\..\python.exe" (
+ "%~dpn0\..\..\python.exe" "%~dpn0" %*
+) ELSE (
+ python.exe "%~dpn0" %*
+)
diff --git a/spyder/api/plugins/new_api.py b/spyder/api/plugins/new_api.py
index b0b8a0a1113..24176ba65ee 100644
--- a/spyder/api/plugins/new_api.py
+++ b/spyder/api/plugins/new_api.py
@@ -622,7 +622,7 @@ def show_status_message(self, message, timeout=0):
def before_long_process(self, message):
"""
Show a message in main window's status bar and change the mouse
- pointer to Qt.WaitCursor when starting a long process.
+ pointer to Qt.CursorShape.WaitCursor when starting a long process.
Parameters
----------
@@ -632,7 +632,7 @@ def before_long_process(self, message):
if message:
self.show_status_message(message)
- QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
+ QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
QApplication.processEvents()
def after_long_process(self, message=""):
@@ -1020,7 +1020,7 @@ def __init__(self, parent, configuration):
def before_long_process(self, message):
"""
Show a message in main window's status bar, change the mouse pointer
- to Qt.WaitCursor and start spinner when starting a long process.
+ to Qt.CursorShape.WaitCursor and start spinner when starting a long process.
Parameters
----------
diff --git a/spyder/api/plugins/old_api.py b/spyder/api/plugins/old_api.py
index d86c3df1a6d..955bb2f10ff 100644
--- a/spyder/api/plugins/old_api.py
+++ b/spyder/api/plugins/old_api.py
@@ -127,7 +127,7 @@ def remove_option(self, option, section=None):
def starting_long_process(self, message):
"""
Show a message in main window's status bar and changes the
- mouse to Qt.WaitCursor when starting a long process.
+ mouse to Qt.CursorShape.WaitCursor when starting a long process.
Parameters
----------
@@ -140,7 +140,7 @@ def starting_long_process(self, message):
def ending_long_process(self, message=""):
"""
Clear main window's status bar after a long process and restore
- mouse to the OS deault.
+ mouse to the OS default.
Parameters
----------
diff --git a/spyder/api/widgets/main_widget.py b/spyder/api/widgets/main_widget.py
index b336742acda..10df81dad3e 100644
--- a/spyder/api/widgets/main_widget.py
+++ b/spyder/api/widgets/main_widget.py
@@ -376,7 +376,7 @@ def _setup(self):
name='switch to ' + self._name,
text=self.get_title(),
toggled=lambda checked: self.toggle_view(checked),
- context=Qt.WidgetWithChildrenShortcut,
+ context=Qt.ShortcutContext.WidgetWithChildrenShortcut,
shortcut_context='_',
)
@@ -440,7 +440,7 @@ def _on_top_level_change(self, top_level):
# Change the cursor shape when dragging
if top_level:
- QApplication.setOverrideCursor(Qt.ClosedHandCursor)
+ QApplication.setOverrideCursor(Qt.CursorShape.ClosedHandCursor)
else:
QApplication.restoreOverrideCursor()
diff --git a/spyder/api/widgets/mixins.py b/spyder/api/widgets/mixins.py
index 0aba120d725..6263862dfce 100644
--- a/spyder/api/widgets/mixins.py
+++ b/spyder/api/widgets/mixins.py
@@ -351,7 +351,7 @@ def _update_action_state(self, action_name, value):
# name where it is applied).
def create_action(self, name, text, icon=None, icon_text='', tip=None,
toggled=None, triggered=None, shortcut_context=None,
- context=Qt.WidgetWithChildrenShortcut, initial=None,
+ context=Qt.ShortcutContext.WidgetWithChildrenShortcut, initial=None,
register_shortcut=False, section=None, option=None,
parent=None, register_action=True, overwrite=False,
context_name=None, menurole=None):
diff --git a/spyder/api/widgets/status.py b/spyder/api/widgets/status.py
index 9c1bc35aeec..b781199ca75 100644
--- a/spyder/api/widgets/status.py
+++ b/spyder/api/widgets/status.py
@@ -113,7 +113,7 @@ def set_layout(self):
# See spyder-ide/spyder#9044.
self.text_font = QFont(QFont().defaultFamily(),
weight=QFont.Normal)
- self.label_value.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
+ self.label_value.setAlignment(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter)
self.label_value.setFont(self.text_font)
# Custom widget
@@ -143,7 +143,7 @@ def set_layout(self):
layout.addSpacing(0)
layout.setContentsMargins(0, 0, 0, 0)
- layout.setAlignment(Qt.AlignVCenter)
+ layout.setAlignment(Qt.AlignmentFlag.AlignVCenter)
# Setup
self.update_tooltip()
diff --git a/spyder/api/widgets/toolbars.py b/spyder/api/widgets/toolbars.py
index 8a4bda14ef4..18db5fd64e3 100644
--- a/spyder/api/widgets/toolbars.py
+++ b/spyder/api/widgets/toolbars.py
@@ -40,8 +40,8 @@
# ---- Constants
# ----------------------------------------------------------------------------
class ToolbarLocation:
- Top = Qt.TopToolBarArea
- Bottom = Qt.BottomToolBarArea
+ Top = Qt.ToolBarArea.TopToolBarArea
+ Bottom = Qt.ToolBarArea.BottomToolBarArea
# ---- Event filters
@@ -253,7 +253,7 @@ def _render(self):
widget = self.widgetForAction(item)
if text_beside_icon:
- widget.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
+ widget.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
if item.isCheckable():
widget.setCheckable(True)
@@ -352,7 +352,7 @@ def _render(self):
text_beside_icon = getattr(item, 'text_beside_icon', False)
if text_beside_icon:
- widget.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
+ widget.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
if item.isCheckable():
widget.setCheckable(True)
diff --git a/spyder/app/mainwindow.py b/spyder/app/mainwindow.py
index 0e0ab3e27e7..b07d630dd21 100644
--- a/spyder/app/mainwindow.py
+++ b/spyder/app/mainwindow.py
@@ -168,7 +168,7 @@ def __init__(self, splash=None, options=None):
self._proxy_style = SpyderProxyStyle(None)
# Enabling scaling for high dpi
- qapp.setAttribute(Qt.AA_UseHighDpiPixmaps)
+ qapp.setAttribute(Qt.ApplicationAttribute.AA_UseHighDpiPixmaps)
# Set Windows app icon to use .ico file
if os.name == "nt":
@@ -338,7 +338,7 @@ def signal_handler(signum, frame=None):
# To set all dockwidgets tabs to be on top (in case we want to do it
# in the future)
- # self.setTabPosition(Qt.AllDockWidgetAreas, QTabWidget.North)
+ # self.setTabPosition(Qt.DockWidgetArea.AllDockWidgetAreas, QTabWidget.North)
logger.info("End of MainWindow constructor")
@@ -476,7 +476,7 @@ def register_plugin(self, plugin_name, external=False, omit_conf=False):
sc = QShortcut(QKeySequence(), self,
lambda: self.switch_to_plugin(plugin))
- sc.setContext(Qt.ApplicationShortcut)
+ sc.setContext(Qt.ShortcutContext.ApplicationShortcut)
plugin._shortcut = sc
if Plugins.Shortcuts in PLUGIN_REGISTRY:
@@ -850,7 +850,7 @@ def setup(self):
icon=ima.icon('filelist'),
tip=_('Fast switch between files'),
triggered=self.open_switcher,
- context=Qt.ApplicationShortcut,
+ context=Qt.ShortcutContext.ApplicationShortcut,
id_='file_switcher'
)
self.register_shortcut(self.file_switcher_action, context="_",
@@ -860,7 +860,7 @@ def setup(self):
icon=ima.icon('symbol_find'),
tip=_('Fast symbol search in file'),
triggered=self.open_symbolfinder,
- context=Qt.ApplicationShortcut,
+ context=Qt.ShortcutContext.ApplicationShortcut,
id_='symbol_finder'
)
self.register_shortcut(self.symbol_finder_action, context="_",
@@ -873,7 +873,7 @@ def create_edit_action(text, tr_text, icon):
icon=icon,
triggered=self.global_callback,
data=method_name,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(action, "Editor", text)
return action
@@ -1370,9 +1370,9 @@ def set_splash(self, message):
logger.info(message)
self.splash.show()
self.splash.showMessage(message,
- int(Qt.AlignBottom | Qt.AlignCenter |
- Qt.AlignAbsolute),
- QColor(Qt.white))
+ int(Qt.AlignmentFlag.AlignBottom | Qt.AlignmentFlag.AlignCenter |
+ Qt.AlignmentFlag.AlignAbsolute),
+ QColor(Qt.GlobalColor.white))
QApplication.processEvents()
def change_last_focused_widget(self, old, now):
@@ -1708,11 +1708,11 @@ def create_switcher(self):
def _test_setting_opengl(self, option):
"""Get the current OpenGL implementation in use"""
if option == 'software':
- return QCoreApplication.testAttribute(Qt.AA_UseSoftwareOpenGL)
+ return QCoreApplication.testAttribute(Qt.ApplicationAttribute.AA_UseSoftwareOpenGL)
elif option == 'desktop':
- return QCoreApplication.testAttribute(Qt.AA_UseDesktopOpenGL)
+ return QCoreApplication.testAttribute(Qt.ApplicationAttribute.AA_UseDesktopOpenGL)
elif option == 'gles':
- return QCoreApplication.testAttribute(Qt.AA_UseOpenGLES)
+ return QCoreApplication.testAttribute(Qt.ApplicationAttribute.AA_UseOpenGLES)
#==============================================================================
@@ -1757,7 +1757,7 @@ def main(options, args):
# **** Set high DPI scaling ****
# This attribute must be set before creating the application.
if hasattr(Qt, 'AA_EnableHighDpiScaling'):
- QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling,
+ QCoreApplication.setAttribute(Qt.ApplicationAttribute.AA_EnableHighDpiScaling,
CONF.get('main', 'high_dpi_scaling'))
# **** Set debugging info ****
@@ -1774,8 +1774,8 @@ def main(options, args):
splash.show()
splash.showMessage(
_("Initializing..."),
- int(Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute),
- QColor(Qt.white)
+ int(Qt.AlignmentFlag.AlignBottom | Qt.AlignmentFlag.AlignCenter | Qt.AlignmentFlag.AlignAbsolute),
+ QColor(Qt.GlobalColor.white)
)
QApplication.processEvents()
diff --git a/spyder/app/restart.py b/spyder/app/restart.py
index b85dd03cb1e..c696b41a30a 100644
--- a/spyder/app/restart.py
+++ b/spyder/app/restart.py
@@ -103,9 +103,9 @@ def __init__(self):
def _show_message(self, text):
"""Show message on splash screen."""
self.splash.showMessage(text,
- int(Qt.AlignBottom | Qt.AlignCenter |
- Qt.AlignAbsolute),
- QColor(Qt.white))
+ int(Qt.AlignmentFlag.AlignBottom | Qt.AlignmentFlag.AlignCenter |
+ Qt.AlignmentFlag.AlignAbsolute),
+ QColor(Qt.GlobalColor.white))
def animate_ellipsis(self):
"""Animate dots at the end of the splash screen message."""
diff --git a/spyder/app/tests/conftest.py b/spyder/app/tests/conftest.py
index eed1a5f2876..c05ed7fe02b 100755
--- a/spyder/app/tests/conftest.py
+++ b/spyder/app/tests/conftest.py
@@ -68,7 +68,7 @@ def open_file_in_editor(main_window, fname, directory=None):
w.setDirectory(directory)
input_field = w.findChildren(QLineEdit)[0]
input_field.setText(fname)
- QTest.keyClick(w, Qt.Key_Enter)
+ QTest.keyClick(w, Qt.Key.Key_Enter)
def reset_run_code(qtbot, shell, code_editor, nsb):
@@ -79,7 +79,7 @@ def reset_run_code(qtbot, shell, code_editor, nsb):
qtbot.waitUntil(
lambda: nsb.editor.source_model.rowCount() == 0, timeout=EVAL_TIMEOUT)
code_editor.setFocus()
- qtbot.keyClick(code_editor, Qt.Key_Home, modifier=Qt.ControlModifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Home, modifier=Qt.ControlModifier)
def start_new_kernel(startup_timeout=60, kernel_name='python', spykernel=False,
diff --git a/spyder/app/tests/test_mainwindow.py b/spyder/app/tests/test_mainwindow.py
index 94c55770141..34008987f7d 100644
--- a/spyder/app/tests/test_mainwindow.py
+++ b/spyder/app/tests/test_mainwindow.py
@@ -402,7 +402,7 @@ def test_get_help_ipython_console_dot_notation(main_window, qtbot, tmpdir):
code_editor = main_window.editor.get_focus_widget()
# Run test file
- qtbot.keyClick(code_editor, Qt.Key_F5)
+ qtbot.keyClick(code_editor, Qt.Key.Key_F5)
qtbot.wait(500)
help_plugin = main_window.help
@@ -443,7 +443,7 @@ def test_get_help_ipython_console_special_characters(
code_editor = main_window.editor.get_focus_widget()
# Run test file
- qtbot.keyClick(code_editor, Qt.Key_F5)
+ qtbot.keyClick(code_editor, Qt.Key.Key_F5)
qtbot.wait(500)
help_plugin = main_window.help
@@ -600,13 +600,13 @@ def test_move_to_first_breakpoint(main_window, qtbot, debugcell):
if debugcell:
# Advance 2 cells
for i in range(2):
- qtbot.keyClick(code_editor, Qt.Key_Return,
+ qtbot.keyClick(code_editor, Qt.Key.Key_Return,
modifier=Qt.ShiftModifier)
qtbot.wait(500)
# Debug the cell
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(code_editor, Qt.Key_Return,
+ qtbot.keyClick(code_editor, Qt.Key.Key_Return,
modifier=Qt.AltModifier | Qt.ShiftModifier)
# Make sure everything is ready
@@ -624,7 +624,7 @@ def test_move_to_first_breakpoint(main_window, qtbot, debugcell):
else:
# Click the debug button
with qtbot.waitSignal(shell.executed):
- qtbot.mouseClick(debug_button, Qt.LeftButton)
+ qtbot.mouseClick(debug_button, Qt.MouseButton.LeftButton)
# Verify that we are at first breakpoint
shell.clear_console()
@@ -642,7 +642,7 @@ def test_move_to_first_breakpoint(main_window, qtbot, debugcell):
# Click the debug button
with qtbot.waitSignal(shell.executed):
- qtbot.mouseClick(debug_button, Qt.LeftButton)
+ qtbot.mouseClick(debug_button, Qt.MouseButton.LeftButton)
# Wait until continue and stop on the breakpoint
qtbot.waitUntil(lambda: "IPdb [2]:" in control.toPlainText())
@@ -680,7 +680,7 @@ def test_runconfig_workdir(main_window, qtbot, tmpdir):
shell = main_window.ipyconsole.get_current_shellwidget()
qtbot.waitUntil(
lambda: shell._prompt_html is not None, timeout=SHELL_TIMEOUT)
- qtbot.keyClick(code_editor, Qt.Key_F5)
+ qtbot.keyClick(code_editor, Qt.Key.Key_F5)
qtbot.wait(500)
# --- Assert we're in cwd after execution ---
@@ -701,7 +701,7 @@ def test_runconfig_workdir(main_window, qtbot, tmpdir):
shell = main_window.ipyconsole.get_current_shellwidget()
qtbot.waitUntil(
lambda: shell._prompt_html is not None, timeout=SHELL_TIMEOUT)
- qtbot.keyClick(code_editor, Qt.Key_F5)
+ qtbot.keyClick(code_editor, Qt.Key.Key_F5)
qtbot.wait(500)
# --- Assert we're in fixed dir after execution ---
@@ -739,7 +739,7 @@ def test_dedicated_consoles(main_window, qtbot):
CONF.set('run', 'configurations', [config_entry])
# --- Run test file and assert that we get a dedicated console ---
- qtbot.keyClick(code_editor, Qt.Key_F5)
+ qtbot.keyClick(code_editor, Qt.Key.Key_F5)
qtbot.wait(500)
shell = main_window.ipyconsole.get_current_shellwidget()
control = shell._control
@@ -763,7 +763,7 @@ def test_dedicated_consoles(main_window, qtbot):
with qtbot.waitSignal(shell.executed):
shell.execute('zz = -1')
- qtbot.keyClick(code_editor, Qt.Key_F5)
+ qtbot.keyClick(code_editor, Qt.Key.Key_F5)
qtbot.waitUntil(lambda: shell.is_defined('zz'))
assert shell.is_defined('zz')
@@ -776,7 +776,7 @@ def test_dedicated_consoles(main_window, qtbot):
CONF.set('run', 'configurations', [config_entry])
qtbot.wait(500)
- qtbot.keyClick(code_editor, Qt.Key_F5)
+ qtbot.keyClick(code_editor, Qt.Key.Key_F5)
qtbot.waitUntil(lambda: not shell.is_defined('zz'))
assert not shell.is_defined('zz')
@@ -840,7 +840,7 @@ def test_connection_to_external_kernel(main_window, qtbot):
# Start running
with qtbot.waitSignal(shell.executed):
- qtbot.mouseClick(run_button, Qt.LeftButton)
+ qtbot.mouseClick(run_button, Qt.MouseButton.LeftButton)
assert "runfile" in shell._control.toPlainText()
assert "3" in shell._control.toPlainText()
@@ -885,7 +885,7 @@ def test_change_types_in_varexp(main_window, qtbot):
# Try to change types
qtbot.keyClicks(QApplication.focusWidget(), "'s'")
- qtbot.keyClick(QApplication.focusWidget(), Qt.Key_Enter)
+ qtbot.keyClick(QApplication.focusWidget(), Qt.Key.Key_Enter)
qtbot.wait(1000)
# Assert object remains the same
@@ -988,7 +988,7 @@ def test_run_cython_code(main_window, qtbot):
main_window.editor.load(osp.join(LOCATION, 'pyx_script.pyx'))
# Run file
- qtbot.keyClick(code_editor, Qt.Key_F5)
+ qtbot.keyClick(code_editor, Qt.Key.Key_F5)
# Get a reference to the namespace browser widget
nsb = main_window.variableexplorer.current_widget()
@@ -1010,7 +1010,7 @@ def test_run_cython_code(main_window, qtbot):
main_window.editor.load(osp.join(LOCATION, 'pyx_lib_import.py'))
# Run file
- qtbot.keyClick(code_editor, Qt.Key_F5)
+ qtbot.keyClick(code_editor, Qt.Key.Key_F5)
# Wait until all objects have appeared in the variable explorer
qtbot.waitUntil(lambda: nsb.editor.source_model.rowCount() == 1,
@@ -1100,7 +1100,7 @@ def test_open_notebooks_from_project_explorer(main_window, qtbot, tmpdir):
projects.get_widget().treewidget.setCurrentIndex(idx)
# Prese Enter there
- qtbot.keyClick(projects.get_widget().treewidget, Qt.Key_Enter)
+ qtbot.keyClick(projects.get_widget().treewidget, Qt.Key.Key_Enter)
# Assert that notebook was open
assert 'notebook.ipynb' in editorstack.get_current_filename()
@@ -1155,7 +1155,7 @@ def test_runfile_from_project_explorer(main_window, qtbot, tmpdir):
projects.get_widget().treewidget.setCurrentIndex(idx)
# Press Enter there
- qtbot.keyClick(projects.get_widget().treewidget, Qt.Key_Enter)
+ qtbot.keyClick(projects.get_widget().treewidget, Qt.Key.Key_Enter)
# Assert that the file was open
assert 'script.py' in editorstack.get_current_filename()
@@ -1206,7 +1206,7 @@ def test_set_new_breakpoints(main_window, qtbot):
debug_action = main_window.debug_toolbar_actions[0]
debug_button = main_window.debug_toolbar.widgetForAction(debug_action)
with qtbot.waitSignal(shell.executed):
- qtbot.mouseClick(debug_button, Qt.LeftButton)
+ qtbot.mouseClick(debug_button, Qt.MouseButton.LeftButton)
# Set a breakpoint
code_editor = main_window.editor.get_focus_widget()
@@ -1245,7 +1245,7 @@ def test_run_code(main_window, qtbot, tmpdir):
editor = main_window.editor
code_editor = editor.get_focus_widget()
code_editor.setFocus()
- qtbot.keyClick(code_editor, Qt.Key_Home, modifier=Qt.ControlModifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Home, modifier=Qt.ControlModifier)
# Get a reference to the namespace browser widget
nsb = main_window.variableexplorer.current_widget()
@@ -1256,7 +1256,7 @@ def test_run_code(main_window, qtbot, tmpdir):
modifier = Qt.MetaModifier
# ---- Run file ----
- qtbot.keyClick(code_editor, Qt.Key_F5)
+ qtbot.keyClick(code_editor, Qt.Key.Key_F5)
# Wait until all objects have appeared in the variable explorer
qtbot.waitUntil(lambda: nsb.editor.source_model.rowCount() == 4,
@@ -1273,7 +1273,7 @@ def test_run_code(main_window, qtbot, tmpdir):
# ---- Run lines ----
# Run the whole file line by line
for _ in range(code_editor.blockCount()):
- qtbot.keyClick(code_editor, Qt.Key_F9)
+ qtbot.keyClick(code_editor, Qt.Key.Key_F9)
qtbot.wait(200)
# Wait until all objects have appeared in the variable explorer
@@ -1293,8 +1293,8 @@ def test_run_code(main_window, qtbot, tmpdir):
# Move to line 10 then move one characters into the line and
# run lines above
editor.go_to_line(10)
- qtbot.keyClick(code_editor, Qt.Key_Right)
- qtbot.keyClick(code_editor, Qt.Key_F9, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Right)
+ qtbot.keyClick(code_editor, Qt.Key.Key_F9, modifier=Qt.ShiftModifier)
qtbot.wait(500)
assert shell.get_value('a') == 10
@@ -1311,8 +1311,8 @@ def test_run_code(main_window, qtbot, tmpdir):
# Set 'a' to a different value before hand to avoid errors in shell
shell.execute('a = 100')
editor.go_to_line(6)
- qtbot.keyClick(code_editor, Qt.Key_Right)
- qtbot.keyClick(code_editor, Qt.Key_F9, modifier=modifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Right)
+ qtbot.keyClick(code_editor, Qt.Key.Key_F9, modifier=modifier)
qtbot.wait(500)
assert shell.get_value('s') == "Z:\\escape\\test\\string\n"
@@ -1327,10 +1327,10 @@ def test_run_code(main_window, qtbot, tmpdir):
# Run the five cells present in file
# Add an unnamed cell at the top of the file
qtbot.keyClicks(code_editor, 'a = 10')
- qtbot.keyClick(code_editor, Qt.Key_Return)
- qtbot.keyClick(code_editor, Qt.Key_Up)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Return)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Up)
for _ in range(5):
- qtbot.keyClick(code_editor, Qt.Key_Return, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Return, modifier=Qt.ShiftModifier)
qtbot.wait(500)
# Check for errors and the runcell function
@@ -1340,9 +1340,9 @@ def test_run_code(main_window, qtbot, tmpdir):
# Rerun
shell.setFocus()
- qtbot.keyClick(shell._control, Qt.Key_Up)
+ qtbot.keyClick(shell._control, Qt.Key.Key_Up)
qtbot.wait(500)
- qtbot.keyClick(shell._control, Qt.Key_Enter, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(shell._control, Qt.Key.Key_Enter, modifier=Qt.ShiftModifier)
qtbot.wait(500)
code_editor.setFocus()
@@ -1367,7 +1367,7 @@ def test_run_code(main_window, qtbot, tmpdir):
# ---- Run cell ----
# Run the first cell in file
- qtbot.keyClick(code_editor, Qt.Key_Return, modifier=modifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Return, modifier=modifier)
# Wait until the object has appeared in the variable explorer
qtbot.waitUntil(lambda: nsb.editor.source_model.rowCount() == 1,
@@ -1378,17 +1378,17 @@ def test_run_code(main_window, qtbot, tmpdir):
# Press Ctrl+Enter a second time to verify that we're *not* advancing
# to the next cell
- qtbot.keyClick(code_editor, Qt.Key_Return, modifier=modifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Return, modifier=modifier)
assert nsb.editor.source_model.rowCount() == 1
reset_run_code(qtbot, shell, code_editor, nsb)
# ---- Debug cell ------
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(code_editor, Qt.Key_Return,
+ qtbot.keyClick(code_editor, Qt.Key.Key_Return,
modifier=Qt.AltModifier | Qt.ShiftModifier)
qtbot.keyClicks(shell._control, '!c')
- qtbot.keyClick(shell._control, Qt.Key_Enter)
+ qtbot.keyClick(shell._control, Qt.Key.Key_Enter)
# Wait until the object has appeared in the variable explorer
qtbot.waitUntil(lambda: nsb.editor.source_model.rowCount() == 1,
@@ -1398,11 +1398,11 @@ def test_run_code(main_window, qtbot, tmpdir):
# ---- Re-run last cell ----
# Run the first three cells in file
- qtbot.keyClick(code_editor, Qt.Key_Return, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Return, modifier=Qt.ShiftModifier)
qtbot.wait(500)
- qtbot.keyClick(code_editor, Qt.Key_Return, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Return, modifier=Qt.ShiftModifier)
qtbot.wait(500)
- qtbot.keyClick(code_editor, Qt.Key_Return, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Return, modifier=Qt.ShiftModifier)
# Wait until objects have appeared in the variable explorer
qtbot.waitUntil(lambda: nsb.editor.source_model.rowCount() == 2,
@@ -1417,7 +1417,7 @@ def test_run_code(main_window, qtbot, tmpdir):
timeout=EVAL_TIMEOUT)
# Re-run last cell
- qtbot.keyClick(code_editor, Qt.Key_Return, modifier=Qt.AltModifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Return, modifier=Qt.AltModifier)
# Wait until the object has appeared in the variable explorer
qtbot.waitUntil(lambda: nsb.editor.source_model.rowCount() == 1,
@@ -1467,7 +1467,7 @@ def test_run_cell_copy(main_window, qtbot, tmpdir):
# Move to the editor's first line
code_editor = main_window.editor.get_focus_widget()
code_editor.setFocus()
- qtbot.keyClick(code_editor, Qt.Key_Home, modifier=Qt.ControlModifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Home, modifier=Qt.ControlModifier)
# Get a reference to the namespace browser widget
nsb = main_window.variableexplorer.current_widget()
@@ -1475,7 +1475,7 @@ def test_run_cell_copy(main_window, qtbot, tmpdir):
# ---- Run cell and advance ----
# Run the three cells present in file
for _ in range(4):
- qtbot.keyClick(code_editor, Qt.Key_Return, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Return, modifier=Qt.ShiftModifier)
qtbot.wait(500)
# Check for errors and the copied code
@@ -1583,7 +1583,7 @@ def get_random_plugin():
# Maximize a random plugin
plugin_1 = get_random_plugin()
- qtbot.mouseClick(max_button, Qt.LeftButton)
+ qtbot.mouseClick(max_button, Qt.MouseButton.LeftButton)
# Load test file
test_file = osp.join(LOCATION, 'script.py')
@@ -1597,15 +1597,15 @@ def get_random_plugin():
plugin_1.toggle_view(False)
# Maximize editor
- qtbot.mouseClick(max_button, Qt.LeftButton)
+ qtbot.mouseClick(max_button, Qt.MouseButton.LeftButton)
assert main_window.editor._ismaximized
# Verify that the action minimizes the plugin too
- qtbot.mouseClick(max_button, Qt.LeftButton)
+ qtbot.mouseClick(max_button, Qt.MouseButton.LeftButton)
assert not main_window.editor._ismaximized
# Don't call switch_to_plugin when the IPython console is undocked
- qtbot.mouseClick(max_button, Qt.LeftButton)
+ qtbot.mouseClick(max_button, Qt.MouseButton.LeftButton)
assert main_window.editor._ismaximized
ipyconsole = main_window.get_plugin(Plugins.IPythonConsole)
ipyconsole.create_window()
@@ -1620,11 +1620,11 @@ def get_random_plugin():
# Maximize a plugin and check that it's unmaximized after clicking the
# debug button
plugin_2 = get_random_plugin()
- qtbot.mouseClick(max_button, Qt.LeftButton)
+ qtbot.mouseClick(max_button, Qt.MouseButton.LeftButton)
debug_action = main_window.debug_toolbar_actions[0]
debug_button = main_window.debug_toolbar.widgetForAction(debug_action)
with qtbot.waitSignal(shell.executed):
- qtbot.mouseClick(debug_button, Qt.LeftButton)
+ qtbot.mouseClick(debug_button, Qt.MouseButton.LeftButton)
qtbot.waitUntil(lambda: 'IPdb' in shell._control.toPlainText())
assert not plugin_2.get_widget().get_maximized_state()
assert not max_action.isChecked()
@@ -1635,15 +1635,15 @@ def get_random_plugin():
debug_next_button = main_window.debug_toolbar.widgetForAction(
debug_next_action)
with qtbot.waitSignal(shell.executed):
- qtbot.mouseClick(debug_next_button, Qt.LeftButton)
+ qtbot.mouseClick(debug_next_button, Qt.MouseButton.LeftButton)
assert not main_window.editor._ismaximized
assert not max_action.isChecked()
# Check that running debugging actions unmaximizes plugins
plugin_2.get_widget().get_focus_widget().setFocus()
- qtbot.mouseClick(max_button, Qt.LeftButton)
+ qtbot.mouseClick(max_button, Qt.MouseButton.LeftButton)
with qtbot.waitSignal(shell.executed):
- qtbot.mouseClick(debug_next_button, Qt.LeftButton)
+ qtbot.mouseClick(debug_next_button, Qt.MouseButton.LeftButton)
assert not plugin_2.get_widget().get_maximized_state()
assert not max_action.isChecked()
if hasattr(plugin_2, '_hide_after_test'):
@@ -1654,12 +1654,12 @@ def get_random_plugin():
stop_debug_button = main_window.debug_toolbar.widgetForAction(
stop_debug_action)
with qtbot.waitSignal(shell.executed):
- qtbot.mouseClick(stop_debug_button, Qt.LeftButton)
+ qtbot.mouseClick(stop_debug_button, Qt.MouseButton.LeftButton)
# Maximize a plugin and check that it's unmaximized after running a file
plugin_3 = get_random_plugin()
- qtbot.mouseClick(max_button, Qt.LeftButton)
- qtbot.mouseClick(run_button, Qt.LeftButton)
+ qtbot.mouseClick(max_button, Qt.MouseButton.LeftButton)
+ qtbot.mouseClick(run_button, Qt.MouseButton.LeftButton)
assert not plugin_3.get_widget().get_maximized_state()
assert not max_action.isChecked()
if hasattr(plugin_3, '_hide_after_test'):
@@ -1669,8 +1669,8 @@ def get_random_plugin():
plugin_4 = get_random_plugin()
run_cell_action = main_window.run_toolbar_actions[1]
run_cell_button = main_window.run_toolbar.widgetForAction(run_cell_action)
- qtbot.mouseClick(max_button, Qt.LeftButton)
- qtbot.mouseClick(run_cell_button, Qt.LeftButton)
+ qtbot.mouseClick(max_button, Qt.MouseButton.LeftButton)
+ qtbot.mouseClick(run_cell_button, Qt.MouseButton.LeftButton)
assert not plugin_4.get_widget().get_maximized_state()
assert not max_action.isChecked()
if hasattr(plugin_4, '_hide_after_test'):
@@ -1682,8 +1682,8 @@ def get_random_plugin():
run_selection_action = main_window.run_toolbar_actions[3]
run_selection_button = main_window.run_toolbar.widgetForAction(
run_selection_action)
- qtbot.mouseClick(max_button, Qt.LeftButton)
- qtbot.mouseClick(run_selection_button, Qt.LeftButton)
+ qtbot.mouseClick(max_button, Qt.MouseButton.LeftButton)
+ qtbot.mouseClick(run_selection_button, Qt.MouseButton.LeftButton)
assert not plugin_5.get_widget().get_maximized_state()
assert not max_action.isChecked()
if hasattr(plugin_5, '_hide_after_test'):
@@ -1729,7 +1729,7 @@ def test_issue_4066(main_window, qtbot):
# Close editor
ok_widget = obj_editor.btn_close
- qtbot.mouseClick(ok_widget, Qt.LeftButton)
+ qtbot.mouseClick(ok_widget, Qt.MouseButton.LeftButton)
# Wait for the segfault
qtbot.wait(3000)
@@ -1795,7 +1795,7 @@ def test_c_and_n_pdb_commands(main_window, qtbot):
debug_action = main_window.debug_toolbar_actions[0]
debug_button = main_window.debug_toolbar.widgetForAction(debug_action)
with qtbot.waitSignal(shell.executed):
- qtbot.mouseClick(debug_button, Qt.LeftButton)
+ qtbot.mouseClick(debug_button, Qt.MouseButton.LeftButton)
# Set a breakpoint
code_editor = main_window.editor.get_focus_widget()
@@ -1805,14 +1805,14 @@ def test_c_and_n_pdb_commands(main_window, qtbot):
# Verify that c works
with qtbot.waitSignal(shell.executed):
qtbot.keyClicks(control, '!c')
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
qtbot.waitUntil(
lambda: nsb.editor.source_model.rowCount() == 1)
# Verify that n works
with qtbot.waitSignal(shell.executed):
qtbot.keyClicks(control, '!n')
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
qtbot.waitUntil(
lambda: nsb.editor.source_model.rowCount() == 2)
@@ -1820,25 +1820,25 @@ def test_c_and_n_pdb_commands(main_window, qtbot):
# the debugging session.
with qtbot.waitSignal(shell.executed):
qtbot.keyClicks(control, '!n')
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
with qtbot.waitSignal(shell.executed):
qtbot.keyClicks(control, '!n')
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
qtbot.waitUntil(
lambda: nsb.editor.source_model.rowCount() == 3)
with qtbot.waitSignal(shell.executed):
qtbot.keyClicks(control, '!n')
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
with qtbot.waitSignal(shell.executed):
qtbot.keyClicks(control, '!n')
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
with qtbot.waitSignal(shell.executed):
qtbot.keyClicks(control, '!n')
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
# Assert that the prompt appear
shell.clear_console()
@@ -1871,7 +1871,7 @@ def test_stop_dbg(main_window, qtbot):
debug_action = main_window.debug_toolbar_actions[0]
debug_button = main_window.debug_toolbar.widgetForAction(debug_action)
with qtbot.waitSignal(shell.executed):
- qtbot.mouseClick(debug_button, Qt.LeftButton)
+ qtbot.mouseClick(debug_button, Qt.MouseButton.LeftButton)
# Move to the next line
with qtbot.waitSignal(shell.executed):
@@ -1882,7 +1882,7 @@ def test_stop_dbg(main_window, qtbot):
stop_debug_button = main_window.debug_toolbar.widgetForAction(
stop_debug_action)
with qtbot.waitSignal(shell.executed):
- qtbot.mouseClick(stop_debug_button, Qt.LeftButton)
+ qtbot.mouseClick(stop_debug_button, Qt.MouseButton.LeftButton)
# Assert there are only two ipdb prompts in the console
assert shell._control.toPlainText().count('IPdb') == 2
@@ -1916,7 +1916,7 @@ def test_change_cwd_dbg(main_window, qtbot):
# Click the debug button
debug_action = main_window.debug_toolbar_actions[0]
debug_button = main_window.debug_toolbar.widgetForAction(debug_action)
- qtbot.mouseClick(debug_button, Qt.LeftButton)
+ qtbot.mouseClick(debug_button, Qt.MouseButton.LeftButton)
qtbot.waitUntil(lambda: 'IPdb' in control.toPlainText())
# Set LOCATION as cwd
@@ -1928,7 +1928,7 @@ def test_change_cwd_dbg(main_window, qtbot):
# Get cwd in console
qtbot.keyClicks(control, 'import os; os.getcwd()')
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
# Assert cwd is the right one
qtbot.waitUntil(lambda: tempfile.gettempdir() in control.toPlainText())
@@ -1959,13 +1959,13 @@ def test_varexp_magic_dbg(main_window, qtbot):
debug_action = main_window.debug_toolbar_actions[0]
debug_button = main_window.debug_toolbar.widgetForAction(debug_action)
with qtbot.waitSignal(shell.executed):
- qtbot.mouseClick(debug_button, Qt.LeftButton)
+ qtbot.mouseClick(debug_button, Qt.MouseButton.LeftButton)
# Get to an object that can be plotted
for _ in range(3):
with qtbot.waitSignal(shell.executed):
qtbot.keyClicks(control, '!n')
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
# Generate the plot from the Variable Explorer
nsb.editor.plot('li', 'plot')
@@ -2575,7 +2575,7 @@ def test_pylint_follows_file(qtbot, tmpdir, main_window):
assert fname == pylint_plugin.get_filename()
# Create a editor split
- main_window.editor.editorsplitter.split(orientation=Qt.Vertical)
+ main_window.editor.editorsplitter.split(orientation=Qt.Orientation.Vertical)
qtbot.wait(500)
# Open other files
@@ -2654,12 +2654,12 @@ def test_break_while_running(main_window, qtbot, tmpdir):
# Click the debug button
with qtbot.waitSignal(shell.executed):
- qtbot.mouseClick(debug_button, Qt.LeftButton)
+ qtbot.mouseClick(debug_button, Qt.MouseButton.LeftButton)
qtbot.wait(1000)
# Continue debugging
qtbot.keyClicks(shell._control, '!c')
- qtbot.keyClick(shell._control, Qt.Key_Enter)
+ qtbot.keyClick(shell._control, Qt.Key.Key_Enter)
qtbot.wait(500)
with qtbot.waitSignal(shell.executed):
@@ -2669,7 +2669,7 @@ def test_break_while_running(main_window, qtbot, tmpdir):
with qtbot.waitSignal(shell.executed):
qtbot.keyClicks(shell._control, '!q')
- qtbot.keyClick(shell._control, Qt.Key_Enter)
+ qtbot.keyClick(shell._control, Qt.Key.Key_Enter)
# Clear all breakpoints
main_window.editor.clear_all_breakpoints()
@@ -2863,7 +2863,7 @@ def test_preferences_empty_shortcut_regression(main_window, qtbot):
code_editor.set_text(u'print(0)\nprint(ññ)')
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(code_editor, Qt.Key_Return, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Return, modifier=Qt.ShiftModifier)
qtbot.waitUntil(lambda: u'print(0)' in shell._control.toPlainText())
assert u'ññ' not in shell._control.toPlainText()
@@ -2880,7 +2880,7 @@ def test_preferences_empty_shortcut_regression(main_window, qtbot):
# Check shortcut run cell and advance reset
code_editor.setFocus()
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(code_editor, Qt.Key_Return, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Return, modifier=Qt.ShiftModifier)
qtbot.waitUntil(lambda: u'ññ' in shell._control.toPlainText(),
timeout=EVAL_TIMEOUT)
@@ -3062,7 +3062,7 @@ def test_debug_unsaved_file(main_window, qtbot):
qtbot.wait(500)
# Start debugging
- qtbot.mouseClick(debug_button, Qt.LeftButton)
+ qtbot.mouseClick(debug_button, Qt.MouseButton.LeftButton)
# There is a breakpoint, so it should continue
qtbot.waitUntil(
@@ -3160,14 +3160,14 @@ def test_varexp_rename(main_window, qtbot, tmpdir):
# Move to the editor's first line
code_editor = main_window.editor.get_focus_widget()
code_editor.setFocus()
- qtbot.keyClick(code_editor, Qt.Key_Home, modifier=Qt.ControlModifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Home, modifier=Qt.ControlModifier)
# Get a reference to the namespace browser widget
nsb = main_window.variableexplorer.current_widget()
# ---- Run file ----
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(code_editor, Qt.Key_F5)
+ qtbot.keyClick(code_editor, Qt.Key.Key_F5)
# Wait until all objects have appeared in the variable explorer
qtbot.waitUntil(lambda: nsb.editor.model.rowCount() == 4,
@@ -3190,7 +3190,7 @@ def data(cm, i, j):
# ---- Run file again ----
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(code_editor, Qt.Key_F5)
+ qtbot.keyClick(code_editor, Qt.Key.Key_F5)
# Wait until all objects have appeared in the variable explorer
qtbot.waitUntil(lambda: nsb.editor.model.rowCount() == 5,
@@ -3226,14 +3226,14 @@ def test_varexp_remove(main_window, qtbot, tmpdir):
# Move to the editor's first line
code_editor = main_window.editor.get_focus_widget()
code_editor.setFocus()
- qtbot.keyClick(code_editor, Qt.Key_Home, modifier=Qt.ControlModifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Home, modifier=Qt.ControlModifier)
# Get a reference to the namespace browser widget
nsb = main_window.variableexplorer.current_widget()
# ---- Run file ----
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(code_editor, Qt.Key_F5)
+ qtbot.keyClick(code_editor, Qt.Key.Key_F5)
# Wait until all objects have appeared in the variable explorer
qtbot.waitUntil(lambda: nsb.editor.model.rowCount() == 4,
@@ -3311,13 +3311,13 @@ def test_runcell_edge_cases(main_window, qtbot, tmpdir):
code_editor = main_window.editor.get_focus_widget()
# call runcell
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(code_editor, Qt.Key_Return, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Return, modifier=Qt.ShiftModifier)
qtbot.waitUntil(lambda: 'runcell(0' in shell._control.toPlainText(),
timeout=SHELL_TIMEOUT)
assert 'runcell(0' in shell._control.toPlainText()
assert 'cell is empty' not in shell._control.toPlainText()
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(code_editor, Qt.Key_Return, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Return, modifier=Qt.ShiftModifier)
qtbot.waitUntil(lambda: 'runcell(1' in shell._control.toPlainText(),
timeout=SHELL_TIMEOUT)
assert 'runcell(1' in shell._control.toPlainText()
@@ -3357,19 +3357,19 @@ def test_runcell_pdb(main_window, qtbot):
# Start debugging
with qtbot.waitSignal(shell.executed, timeout=SHELL_TIMEOUT):
- qtbot.mouseClick(debug_button, Qt.LeftButton)
+ qtbot.mouseClick(debug_button, Qt.MouseButton.LeftButton)
for key in ['!n', '!n', '!s', '!n', '!n']:
with qtbot.waitSignal(shell.executed, timeout=SHELL_TIMEOUT):
qtbot.keyClicks(shell._control, key)
- qtbot.keyClick(shell._control, Qt.Key_Enter)
+ qtbot.keyClick(shell._control, Qt.Key.Key_Enter)
assert shell.get_value('abba') == 27
code_editor.setFocus()
# call runcell
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(code_editor, Qt.Key_Return, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Return, modifier=Qt.ShiftModifier)
assert "runcell" in shell._control.toPlainText()
# Make sure the local variables are detected
@@ -3405,9 +3405,9 @@ def test_runcell_cache(main_window, qtbot, debug):
# Run the two cells
code_editor.setFocus()
code_editor.move_cursor(0)
- qtbot.keyClick(code_editor, Qt.Key_Return, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Return, modifier=Qt.ShiftModifier)
qtbot.wait(100)
- qtbot.keyClick(code_editor, Qt.Key_Return, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Return, modifier=Qt.ShiftModifier)
qtbot.wait(500)
qtbot.waitUntil(lambda: "Done" in shell._control.toPlainText())
@@ -3508,7 +3508,7 @@ def processEvents():
shell.execute('%debug')
with qtbot.waitSignal(shell.executed):
qtbot.keyClicks(control, '!u')
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
# Wait until both files are open
qtbot.waitUntil(
@@ -3574,14 +3574,14 @@ def test_pdb_step(main_window, qtbot, tmpdir, where):
# Run a random command, make sure we don't move
with qtbot.waitSignal(shell.executed):
qtbot.keyClicks(control, '!a')
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
qtbot.wait(1000)
assert current_filename == main_window.editor.get_current_editor().filename
# Go up and enter second file
with qtbot.waitSignal(shell.executed):
qtbot.keyClicks(control, '!u')
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
qtbot.waitUntil(
lambda: osp.samefile(
main_window.editor.get_current_editor().filename,
@@ -3601,7 +3601,7 @@ def test_pdb_step(main_window, qtbot, tmpdir, where):
# go back to the second file with where
with qtbot.waitSignal(shell.executed):
qtbot.keyClicks(control, '!w')
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
qtbot.wait(1000)
# Make sure we moved
@@ -3613,7 +3613,7 @@ def test_pdb_step(main_window, qtbot, tmpdir, where):
# Stay at the same place
with qtbot.waitSignal(shell.executed):
qtbot.keyClicks(control, '!a')
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
qtbot.wait(1000)
# Make sure we didn't move
@@ -3645,7 +3645,7 @@ def test_runcell_after_restart(main_window, qtbot):
# call runcell
code_editor.setFocus()
- qtbot.keyClick(code_editor, Qt.Key_Return, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Return, modifier=Qt.ShiftModifier)
qtbot.waitUntil(
lambda: "test_runcell_after_restart" in shell._control.toPlainText())
@@ -3741,7 +3741,7 @@ def test_running_namespace(main_window, qtbot, tmpdir):
# Start debugging
with qtbot.waitSignal(shell.executed):
- qtbot.mouseClick(debug_button, Qt.LeftButton)
+ qtbot.mouseClick(debug_button, Qt.MouseButton.LeftButton)
# b should not be there (running namespace) and the local a should be 5
qtbot.waitUntil(lambda: 'a' in nsb.editor.source_model._data and
@@ -3947,7 +3947,7 @@ def test_run_unsaved_file_multiprocessing(main_window, qtbot):
# This code should run even on windows
# Start running
- qtbot.mouseClick(run_button, Qt.LeftButton)
+ qtbot.mouseClick(run_button, Qt.MouseButton.LeftButton)
# Because multiprocessing is behaving strangly on windows, only some
# situations will work. This is one of these situations so it shouldn't
@@ -4088,7 +4088,7 @@ def hello():
# Start debugging
with qtbot.waitSignal(shell.executed):
- qtbot.mouseClick(debug_button, Qt.LeftButton)
+ qtbot.mouseClick(debug_button, Qt.MouseButton.LeftButton)
# Check `test` has a value of 1
# Here we use "waitUntil" because `shell.executed` is emitted twice
@@ -4222,7 +4222,7 @@ def test_tour_message(main_window, qtbot):
qtbot.waitUntil(lambda: tour_dialog.isVisible(), timeout=2000)
# Check that clicking dismiss hides the dialog and disables it
- qtbot.mouseClick(tour_dialog.dismiss_button, Qt.LeftButton)
+ qtbot.mouseClick(tour_dialog.dismiss_button, Qt.MouseButton.LeftButton)
qtbot.waitUntil(lambda: not tour_dialog.isVisible(),
timeout=2000)
assert not tours.get_conf('show_tour_message')
@@ -4237,7 +4237,7 @@ def test_tour_message(main_window, qtbot):
qtbot.waitUntil(lambda: tour_dialog.isVisible(), timeout=5000)
# Run the tour and confirm it's running and the dialog is closed
- qtbot.mouseClick(tour_dialog.launch_tour_button, Qt.LeftButton)
+ qtbot.mouseClick(tour_dialog.launch_tour_button, Qt.MouseButton.LeftButton)
qtbot.waitUntil(lambda: animated_tour.is_running, timeout=9000)
assert not tour_dialog.isVisible()
assert not tours.get_conf('show_tour_message')
@@ -4427,7 +4427,7 @@ def write_code(code, treewidget):
timeout=5000):
editor_stack.tabs.setCurrentIndex(i)
qtbot.mouseClick(editor_stack.tabs.currentWidget(),
- Qt.LeftButton)
+ Qt.MouseButton.LeftButton)
code_editor.set_text(code.format(i=i))
qtbot.wait(300) # Make changes visible
@@ -4445,7 +4445,7 @@ def editors_with_info(treewidget):
def move_across_tabs(editorstack):
for i in range(editorstack.tabs.count()):
editorstack.tabs.setCurrentIndex(i)
- qtbot.mouseClick(editorstack.tabs.currentWidget(), Qt.LeftButton)
+ qtbot.mouseClick(editorstack.tabs.currentWidget(), Qt.MouseButton.LeftButton)
qtbot.wait(300) # Make changes visible
# Wait until symbol services are up
@@ -4607,7 +4607,7 @@ def test_prevent_closing(main_window, qtbot):
# Start debugging
with qtbot.waitSignal(shell.executed):
- qtbot.mouseClick(debug_button, Qt.LeftButton)
+ qtbot.mouseClick(debug_button, Qt.MouseButton.LeftButton)
CONF.set('ipython_console', 'pdb_prevent_closing', False)
# Check we can close a file we debug if the option is disabled
@@ -4645,7 +4645,7 @@ def test_continue_first_line(main_window, qtbot):
CONF.set('ipython_console', 'pdb_stop_first_line', False)
# Start debugging
with qtbot.waitSignal(shell.executed):
- qtbot.mouseClick(debug_button, Qt.LeftButton)
+ qtbot.mouseClick(debug_button, Qt.MouseButton.LeftButton)
# The debugging should finish
qtbot.waitUntil(lambda: not shell.is_debugging())
CONF.set('ipython_console', 'pdb_stop_first_line', True)
@@ -4703,7 +4703,7 @@ def test_pdb_without_comm(main_window, qtbot):
qtbot.waitUntil(
lambda: shell._control.toPlainText().split()[-1] == 'ipdb>')
qtbot.keyClicks(control, "print('Two: ' + str(1+1))")
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
qtbot.waitUntil(
lambda: shell._control.toPlainText().split()[-1] == 'ipdb>')
@@ -4844,9 +4844,9 @@ def test_copy_paste(main_window, qtbot, tmpdir):
assert expected in shell._control.toPlainText()
# Test paste at zero indentation
- qtbot.keyClick(code_editor, Qt.Key_Backspace)
- qtbot.keyClick(code_editor, Qt.Key_Backspace)
- qtbot.keyClick(code_editor, Qt.Key_Backspace)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Backspace)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Backspace)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Backspace)
# Check again that the clipboard is ready
assert QApplication.clipboard().text() == (
"def c():\n print()\n")
@@ -4856,7 +4856,7 @@ def test_copy_paste(main_window, qtbot, tmpdir):
# Test paste at automatic indentation
qtbot.keyClick(code_editor, "z", modifier=Qt.ControlModifier)
- qtbot.keyClick(code_editor, Qt.Key_Tab)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Tab)
qtbot.keyClick(code_editor, "v", modifier=Qt.ControlModifier)
expected = (
"\n"
@@ -4914,7 +4914,7 @@ def test_func():
run_action = main_window.run_toolbar_actions[0]
run_button = main_window.run_toolbar.widgetForAction(run_action)
with qtbot.waitSignal(shell.executed):
- qtbot.mouseClick(run_button, Qt.LeftButton)
+ qtbot.mouseClick(run_button, Qt.MouseButton.LeftButton)
qtbot.wait(1000)
assert 'Test stdout' in control.toPlainText()
@@ -4946,7 +4946,7 @@ def crash_func():
# Click the run button
run_action = main_window.run_toolbar_actions[0]
run_button = main_window.run_toolbar.widgetForAction(run_action)
- qtbot.mouseClick(run_button, Qt.LeftButton)
+ qtbot.mouseClick(run_button, Qt.MouseButton.LeftButton)
qtbot.waitUntil(lambda: 'Segmentation fault' in control.toPlainText(),
timeout=SHELL_TIMEOUT)
@@ -4973,10 +4973,10 @@ def check_focus(button):
wait=1000
):
with qtbot.waitSignal(shell.executed):
- qtbot.mouseClick(button, Qt.LeftButton)
+ qtbot.mouseClick(button, Qt.MouseButton.LeftButton)
else:
with qtbot.waitSignal(shell.executed):
- qtbot.mouseClick(button, Qt.LeftButton)
+ qtbot.mouseClick(button, Qt.MouseButton.LeftButton)
# Check the right widget has focus
focus_widget = QApplication.focusWidget()
@@ -5190,7 +5190,7 @@ def test_debug_unsaved_function(main_window, qtbot):
# run file
with qtbot.waitSignal(shell.executed):
- qtbot.mouseClick(run_button, Qt.LeftButton)
+ qtbot.mouseClick(run_button, Qt.MouseButton.LeftButton)
# debug foo
with qtbot.waitSignal(shell.executed):
@@ -5450,13 +5450,13 @@ def test_switch_to_plugin(main_window, qtbot):
timeout=SHELL_TIMEOUT)
# Switch to the IPython console and check the focus is there
- qtbot.keyClick(main_window, Qt.Key_I,
+ qtbot.keyClick(main_window, Qt.Key.Key_I,
modifier=Qt.ControlModifier | Qt.ShiftModifier)
control = main_window.ipyconsole.get_widget().get_focus_widget()
assert QApplication.focusWidget() is control
# Switch to the editor and assert the focus is there
- qtbot.keyClick(main_window, Qt.Key_E,
+ qtbot.keyClick(main_window, Qt.Key.Key_E,
modifier=Qt.ControlModifier | Qt.ShiftModifier)
code_editor = main_window.editor.get_current_editor()
assert QApplication.focusWidget() is code_editor
diff --git a/spyder/app/utils.py b/spyder/app/utils.py
index 254df98b40a..4316c560568 100644
--- a/spyder/app/utils.py
+++ b/spyder/app/utils.py
@@ -93,15 +93,15 @@ def set_opengl_implementation(option):
See spyder-ide/spyder#7447 for the details.
"""
if option == 'software':
- QCoreApplication.setAttribute(Qt.AA_UseSoftwareOpenGL)
+ QCoreApplication.setAttribute(Qt.ApplicationAttribute.AA_UseSoftwareOpenGL)
if QQuickWindow is not None:
QQuickWindow.setSceneGraphBackend(QSGRendererInterface.Software)
elif option == 'desktop':
- QCoreApplication.setAttribute(Qt.AA_UseDesktopOpenGL)
+ QCoreApplication.setAttribute(Qt.ApplicationAttribute.AA_UseDesktopOpenGL)
if QQuickWindow is not None:
QQuickWindow.setSceneGraphBackend(QSGRendererInterface.OpenGL)
elif option == 'gles':
- QCoreApplication.setAttribute(Qt.AA_UseOpenGLES)
+ QCoreApplication.setAttribute(Qt.ApplicationAttribute.AA_UseOpenGLES)
if QQuickWindow is not None:
QQuickWindow.setSceneGraphBackend(QSGRendererInterface.OpenGL)
@@ -308,7 +308,7 @@ def create_window(WindowClass, app, splash, options, args):
# Don't show icons in menus for Mac
if sys.platform == 'darwin':
- QCoreApplication.setAttribute(Qt.AA_DontShowIconsInMenus, True)
+ QCoreApplication.setAttribute(Qt.ApplicationAttribute.AA_DontShowIconsInMenus, True)
# Open external files with our Mac app
if running_in_mac_app():
diff --git a/spyder/config/gui.py b/spyder/config/gui.py
index 3d1b2a32988..5b31ca638e0 100644
--- a/spyder/config/gui.py
+++ b/spyder/config/gui.py
@@ -106,7 +106,7 @@ def _config_shortcut(action, context, name, keystr, parent):
preferences page.
"""
qsc = QShortcut(QKeySequence(keystr), parent, action)
- qsc.setContext(Qt.WidgetWithChildrenShortcut)
+ qsc.setContext(Qt.ShortcutContext.WidgetWithChildrenShortcut)
sc = Shortcut(data=(qsc, context, name))
return sc
diff --git a/spyder/plugins/appearance/widgets.py b/spyder/plugins/appearance/widgets.py
index 8dd478d848e..cb1456d5d5c 100644
--- a/spyder/plugins/appearance/widgets.py
+++ b/spyder/plugins/appearance/widgets.py
@@ -102,7 +102,7 @@ def add_color_scheme_stack(self, scheme_name, custom=False):
self.widgets[scheme_name] = {}
# Widget setup
- line_edit.label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
+ line_edit.label.setAlignment(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter)
self.setWindowTitle(_('Color scheme editor'))
# Layout
@@ -137,7 +137,7 @@ def add_color_scheme_stack(self, scheme_name, custom=False):
option,
without_layout=True,
)
- label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
+ label.setAlignment(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter)
group_layout.addWidget(label, row+1, 0)
group_layout.addLayout(clayout, row+1, 1)
@@ -149,7 +149,7 @@ def add_color_scheme_stack(self, scheme_name, custom=False):
option,
without_layout=True,
)
- label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
+ label.setAlignment(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter)
group_layout.addWidget(label, row+1, 0)
group_layout.addLayout(clayout, row+1, 1)
group_layout.addWidget(cb_bold, row+1, 2)
diff --git a/spyder/plugins/application/confpage.py b/spyder/plugins/application/confpage.py
index a287e32766b..dadf4c07448 100644
--- a/spyder/plugins/application/confpage.py
+++ b/spyder/plugins/application/confpage.py
@@ -202,7 +202,7 @@ def set_open_file(state):
tip=_("Enter values for different screens "
"separated by semicolons ';'.\n"
"Float values are supported"),
- alignment=Qt.Horizontal,
+ alignment=Qt.Orientation.Horizontal,
regex=r"[0-9]+(?:\.[0-9]*)(;[0-9]+(?:\.[0-9]*))*",
restart=True)
diff --git a/spyder/plugins/application/container.py b/spyder/plugins/application/container.py
index 40e6e5b6902..8b3b4035725 100644
--- a/spyder/plugins/application/container.py
+++ b/spyder/plugins/application/container.py
@@ -128,7 +128,7 @@ def setup(self):
text=_("Spyder documentation"),
icon=self.create_icon("DialogHelpButton"),
triggered=lambda: start_file(__docs_url__),
- context=Qt.ApplicationShortcut,
+ context=Qt.ShortcutContext.ApplicationShortcut,
register_shortcut=True,
shortcut_context="_")
@@ -193,7 +193,7 @@ def setup(self):
icon=self.create_icon('restart'),
tip=_("Restart"),
triggered=self.restart_normal,
- context=Qt.ApplicationShortcut,
+ context=Qt.ShortcutContext.ApplicationShortcut,
shortcut_context="_",
register_shortcut=True)
@@ -202,7 +202,7 @@ def setup(self):
_("&Restart in debug mode"),
tip=_("Restart in debug mode"),
triggered=self.restart_debug,
- context=Qt.ApplicationShortcut,
+ context=Qt.ShortcutContext.ApplicationShortcut,
shortcut_context="_",
register_shortcut=True)
diff --git a/spyder/plugins/application/widgets/install.py b/spyder/plugins/application/widgets/install.py
index ff626aee217..926db2a8f86 100644
--- a/spyder/plugins/application/widgets/install.py
+++ b/spyder/plugins/application/widgets/install.py
@@ -66,9 +66,9 @@ def __init__(self, parent):
self.cancel_button.setIcon(ima.icon('DialogCloseButton'))
self.cancel_button.setFixedHeight(25)
self.cancel_button.setFixedWidth(25)
- progress_layout.addWidget(self._progress_bar, alignment=Qt.AlignLeft)
+ progress_layout.addWidget(self._progress_bar, alignment=Qt.AlignmentFlag.AlignLeft)
progress_layout.addWidget(self.cancel_button)
- progress_layout.setAlignment(Qt.AlignVCenter)
+ progress_layout.setAlignment(Qt.AlignmentFlag.AlignVCenter)
self._progress_widget.setLayout(progress_layout)
self._progress_label = QLabel(_('Downloading'))
diff --git a/spyder/plugins/application/widgets/status.py b/spyder/plugins/application/widgets/status.py
index ae570aa35a9..75532621176 100644
--- a/spyder/plugins/application/widgets/status.py
+++ b/spyder/plugins/application/widgets/status.py
@@ -68,7 +68,7 @@ def __init__(self, parent):
# Set font size and aligment attributes fro custom widget to
# match default label values
- self.custom_widget.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
+ self.custom_widget.setAlignment(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter)
self.custom_widget.setFont(self.text_font)
# Signals
diff --git a/spyder/plugins/base.py b/spyder/plugins/base.py
index bf8743fc469..aabf7b701dd 100644
--- a/spyder/plugins/base.py
+++ b/spyder/plugins/base.py
@@ -92,10 +92,10 @@ def _show_compatibility_message(self, message):
def _starting_long_process(self, message):
"""
Show message in main window's status bar and change cursor to
- Qt.WaitCursor
+ Qt.CursorShape.WaitCursor
"""
self._show_status_message(message)
- QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
+ QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
QApplication.processEvents()
def _ending_long_process(self, message=""):
@@ -334,7 +334,7 @@ def _create_toggle_view_action(self):
action = create_action(self, title,
toggled=lambda checked: self.toggle_view(checked),
shortcut=QKeySequence(self.shortcut),
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
else:
action = create_action(self, title, toggled=lambda checked:
self.toggle_view(checked))
diff --git a/spyder/plugins/breakpoints/widgets/main_widget.py b/spyder/plugins/breakpoints/widgets/main_widget.py
index 2596e5f5776..78b8ac4b7b0 100644
--- a/spyder/plugins/breakpoints/widgets/main_widget.py
+++ b/spyder/plugins/breakpoints/widgets/main_widget.py
@@ -127,7 +127,7 @@ def headerData(self, section, orientation, role=Qt.DisplayRole):
return to_qvariant()
i_column = int(section)
- if orientation == Qt.Horizontal:
+ if orientation == Qt.Orientation.Horizontal:
return to_qvariant(COLUMN_HEADERS[i_column])
else:
return to_qvariant()
@@ -151,9 +151,9 @@ def data(self, index, role=Qt.DisplayRole):
elif role == Qt.TextAlignmentRole:
if index.column() == COL_LINE:
# Align line number right
- return to_qvariant(int(Qt.AlignRight | Qt.AlignVCenter))
+ return to_qvariant(int(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter))
else:
- return to_qvariant(int(Qt.AlignLeft | Qt.AlignVCenter))
+ return to_qvariant(int(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter))
elif role == Qt.ToolTipRole:
if index.column() == COL_FILE:
# Return full file name (in last position)
diff --git a/spyder/plugins/completion/api.py b/spyder/plugins/completion/api.py
index 1fc0f32ef09..c7efbb54fb2 100644
--- a/spyder/plugins/completion/api.py
+++ b/spyder/plugins/completion/api.py
@@ -1240,7 +1240,7 @@ def set_conf(self,
def create_action(self, name, text, icon=None, icon_text='', tip=None,
toggled=None, triggered=None, shortcut_context=None,
- context=Qt.WidgetWithChildrenShortcut, initial=None,
+ context=Qt.ShortcutContext.WidgetWithChildrenShortcut, initial=None,
register_shortcut=False):
"""
name: str
diff --git a/spyder/plugins/completion/providers/kite/widgets/install.py b/spyder/plugins/completion/providers/kite/widgets/install.py
index 14c6c8d30e4..33440ad287f 100644
--- a/spyder/plugins/completion/providers/kite/widgets/install.py
+++ b/spyder/plugins/completion/providers/kite/widgets/install.py
@@ -204,7 +204,7 @@ def __init__(self, parent):
self.cancel_button = QPushButton()
self.cancel_button.setIcon(ima.icon('DialogCloseButton'))
self.cancel_button.hide()
- progress_layout.addWidget(self._progress_bar, alignment=Qt.AlignLeft)
+ progress_layout.addWidget(self._progress_bar, alignment=Qt.AlignmentFlag.AlignLeft)
progress_layout.addWidget(self.cancel_button)
self._progress_widget.setLayout(progress_layout)
diff --git a/spyder/plugins/completion/providers/languageserver/conftabs/advanced.py b/spyder/plugins/completion/providers/languageserver/conftabs/advanced.py
index 8b5c59b1d55..e1e208f3fc6 100644
--- a/spyder/plugins/completion/providers/languageserver/conftabs/advanced.py
+++ b/spyder/plugins/completion/providers/languageserver/conftabs/advanced.py
@@ -36,7 +36,7 @@ def __init__(self, parent):
_("Warning: Only modify these values if "
"you know what you're doing!"))
advanced_label.setWordWrap(True)
- advanced_label.setAlignment(Qt.AlignJustify)
+ advanced_label.setAlignment(Qt.AlignmentFlag.AlignJustify)
# Advanced settings checkbox
self.advanced_options_check = self.create_checkbox(
@@ -45,11 +45,11 @@ def __init__(self, parent):
# Advanced options
self.advanced_module = self.create_lineedit(
_("Module for the Python language server: "),
- 'advanced/module', alignment=Qt.Horizontal,
+ 'advanced/module', alignment=Qt.Orientation.Horizontal,
word_wrap=False)
self.advanced_host = self.create_lineedit(
_("IP Address and port to bind the server to: "),
- 'advanced/host', alignment=Qt.Horizontal,
+ 'advanced/host', alignment=Qt.Orientation.Horizontal,
word_wrap=False)
self.advanced_port = self.create_spinbox(
":", "", 'advanced/port', min_=1, max_=65535, step=1)
@@ -105,7 +105,7 @@ def __init__(self, parent):
self.setLayout(layout)
def disable_tcp(self, state):
- if state == Qt.Checked:
+ if state == Qt.CheckState.Checked:
self.advanced_host.textbox.setEnabled(False)
self.advanced_port.spinbox.setEnabled(False)
self.external_server.stateChanged.disconnect()
@@ -119,7 +119,7 @@ def disable_tcp(self, state):
self.external_server.stateChanged.connect(self.disable_stdio)
def disable_stdio(self, state):
- if state == Qt.Checked:
+ if state == Qt.CheckState.Checked:
self.advanced_host.textbox.setEnabled(True)
self.advanced_port.spinbox.setEnabled(True)
self.advanced_module.textbox.setEnabled(False)
diff --git a/spyder/plugins/completion/providers/languageserver/conftabs/docstring.py b/spyder/plugins/completion/providers/languageserver/conftabs/docstring.py
index e38d50ad0a8..5b71c6e724b 100644
--- a/spyder/plugins/completion/providers/languageserver/conftabs/docstring.py
+++ b/spyder/plugins/completion/providers/languageserver/conftabs/docstring.py
@@ -60,19 +60,19 @@ def __init__(self, parent):
'pydocstyle/convention')
self.docstring_style_select = self.create_lineedit(
_("Show the following errors:"),
- 'pydocstyle/select', alignment=Qt.Horizontal, word_wrap=False,
+ 'pydocstyle/select', alignment=Qt.Orientation.Horizontal, word_wrap=False,
placeholder=_("Example codes: D413, D414"))
self.docstring_style_ignore = self.create_lineedit(
_("Ignore the following errors:"),
- 'pydocstyle/ignore', alignment=Qt.Horizontal, word_wrap=False,
+ 'pydocstyle/ignore', alignment=Qt.Orientation.Horizontal, word_wrap=False,
placeholder=_("Example codes: D107, D402"))
self.docstring_style_match = self.create_lineedit(
_("Only check filenames matching these patterns:"),
- 'pydocstyle/match', alignment=Qt.Horizontal, word_wrap=False,
+ 'pydocstyle/match', alignment=Qt.Orientation.Horizontal, word_wrap=False,
placeholder=_("Skip test files: (?!test_).*\\.py"))
self.docstring_style_match_dir = self.create_lineedit(
_("Only check in directories matching these patterns:"),
- 'pydocstyle/match_dir', alignment=Qt.Horizontal, word_wrap=False,
+ 'pydocstyle/match_dir', alignment=Qt.Orientation.Horizontal, word_wrap=False,
placeholder=_("Skip dot directories: [^\\.].*"))
# Custom option handling
diff --git a/spyder/plugins/completion/providers/languageserver/conftabs/formatting.py b/spyder/plugins/completion/providers/languageserver/conftabs/formatting.py
index 874ee394958..aca6bc7ecd8 100644
--- a/spyder/plugins/completion/providers/languageserver/conftabs/formatting.py
+++ b/spyder/plugins/completion/providers/languageserver/conftabs/formatting.py
@@ -51,20 +51,20 @@ def __init__(self, parent):
# Code style options
self.code_style_filenames_match = self.create_lineedit(
_("Only check filenames matching these patterns:"),
- 'pycodestyle/filename', alignment=Qt.Horizontal, word_wrap=False,
+ 'pycodestyle/filename', alignment=Qt.Orientation.Horizontal, word_wrap=False,
placeholder=_("Check Python files: *.py"))
self.code_style_exclude = self.create_lineedit(
_("Exclude files or directories matching these patterns:"),
- 'pycodestyle/exclude', alignment=Qt.Horizontal, word_wrap=False,
+ 'pycodestyle/exclude', alignment=Qt.Orientation.Horizontal, word_wrap=False,
placeholder=_("Exclude all test files: (?!test_).*\\.py"))
code_style_select = self.create_lineedit(
_("Show the following errors or warnings:").format(
code_style_codes_url),
- 'pycodestyle/select', alignment=Qt.Horizontal, word_wrap=False,
+ 'pycodestyle/select', alignment=Qt.Orientation.Horizontal, word_wrap=False,
placeholder=_("Example codes: E113, W391"))
code_style_ignore = self.create_lineedit(
_("Ignore the following errors or warnings:"),
- 'pycodestyle/ignore', alignment=Qt.Horizontal, word_wrap=False,
+ 'pycodestyle/ignore', alignment=Qt.Orientation.Horizontal, word_wrap=False,
placeholder=_("Example codes: E201, E303"))
self.code_style_max_line_length = self.create_spinbox(
_("Maximum allowed line length:"), None,
diff --git a/spyder/plugins/completion/providers/languageserver/conftabs/otherlanguages.py b/spyder/plugins/completion/providers/languageserver/conftabs/otherlanguages.py
index aa44d1c7a9d..991ff31a800 100644
--- a/spyder/plugins/completion/providers/languageserver/conftabs/otherlanguages.py
+++ b/spyder/plugins/completion/providers/languageserver/conftabs/otherlanguages.py
@@ -41,7 +41,7 @@ def __init__(self, parent):
).format(lsp_url=LSP_URL))
servers_label.setOpenExternalLinks(True)
servers_label.setWordWrap(True)
- servers_label.setAlignment(Qt.AlignJustify)
+ servers_label.setAlignment(Qt.AlignmentFlag.AlignJustify)
# Servers table
table_group = QGroupBox(_('Available servers:'))
diff --git a/spyder/plugins/completion/providers/languageserver/widgets/serversconfig.py b/spyder/plugins/completion/providers/languageserver/widgets/serversconfig.py
index d61db233c35..72c4c4b2595 100644
--- a/spyder/plugins/completion/providers/languageserver/widgets/serversconfig.py
+++ b/spyder/plugins/completion/providers/languageserver/widgets/serversconfig.py
@@ -518,7 +518,7 @@ def sortByName(self):
def flags(self, index):
"""Qt Override."""
if not index.isValid():
- return Qt.ItemIsEnabled
+ return Qt.ItemFlag.ItemIsEnabled
return Qt.ItemFlags(QAbstractTableModel.flags(self, index))
def data(self, index, role=Qt.DisplayRole):
@@ -543,18 +543,18 @@ def data(self, index, role=Qt.DisplayRole):
text = ' External server'
return to_qvariant(text.format(server.cmd, server.args))
elif role == Qt.TextAlignmentRole:
- return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter))
+ return to_qvariant(int(Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignVCenter))
return to_qvariant()
def headerData(self, section, orientation, role=Qt.DisplayRole):
"""Qt Override."""
if role == Qt.TextAlignmentRole:
- if orientation == Qt.Horizontal:
- return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter))
- return to_qvariant(int(Qt.AlignRight | Qt.AlignVCenter))
+ if orientation == Qt.Orientation.Horizontal:
+ return to_qvariant(int(Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignVCenter))
+ return to_qvariant(int(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter))
if role != Qt.DisplayRole:
return to_qvariant()
- if orientation == Qt.Horizontal:
+ if orientation == Qt.Orientation.Horizontal:
if section == LANGUAGE:
return to_qvariant(_("Language"))
elif section == ADDR:
@@ -703,11 +703,11 @@ def previous_row(self):
def keyPressEvent(self, event):
"""Qt Override."""
key = event.key()
- if key in [Qt.Key_Enter, Qt.Key_Return]:
+ if key in [Qt.Key.Key_Enter, Qt.Key.Key_Return]:
self.show_editor()
- elif key in [Qt.Key_Backtab]:
+ elif key in [Qt.Key.Key_Backtab]:
self.parent().reset_btn.setFocus()
- elif key in [Qt.Key_Up, Qt.Key_Down, Qt.Key_Left, Qt.Key_Right]:
+ elif key in [Qt.Key.Key_Up, Qt.Key.Key_Down, Qt.Key.Key_Left, Qt.Key.Key_Right]:
super(LSPServerTable, self).keyPressEvent(event)
else:
super(LSPServerTable, self).keyPressEvent(event)
diff --git a/spyder/plugins/completion/providers/snippets/conftabs.py b/spyder/plugins/completion/providers/snippets/conftabs.py
index 1e42c573d90..efc10d30981 100644
--- a/spyder/plugins/completion/providers/snippets/conftabs.py
+++ b/spyder/plugins/completion/providers/snippets/conftabs.py
@@ -46,7 +46,7 @@ def __init__(self, parent):
"the settings").format(grammar_url))
snippets_info_label.setOpenExternalLinks(True)
snippets_info_label.setWordWrap(True)
- snippets_info_label.setAlignment(Qt.AlignJustify)
+ snippets_info_label.setAlignment(Qt.AlignmentFlag.AlignJustify)
self.snippets_language_cb = QComboBox(self)
self.snippets_language_cb.setToolTip(
diff --git a/spyder/plugins/completion/providers/snippets/widgets/snippetsconfig.py b/spyder/plugins/completion/providers/snippets/widgets/snippetsconfig.py
index 37babadf85e..d3633dbac95 100644
--- a/spyder/plugins/completion/providers/snippets/widgets/snippetsconfig.py
+++ b/spyder/plugins/completion/providers/snippets/widgets/snippetsconfig.py
@@ -438,7 +438,7 @@ def sortByName(self):
def flags(self, index):
if not index.isValid():
- return Qt.ItemIsEnabled
+ return Qt.ItemFlag.ItemIsEnabled
return Qt.ItemFlags(QAbstractTableModel.flags(self, index))
def data(self, index, role=Qt.DisplayRole):
@@ -455,19 +455,19 @@ def data(self, index, role=Qt.DisplayRole):
elif column == self.DESCRIPTION:
return to_qvariant(snippet.description)
elif role == Qt.TextAlignmentRole:
- return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter))
+ return to_qvariant(int(Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignVCenter))
elif role == Qt.ToolTipRole:
return to_qvariant(_("Double-click to view or edit"))
return to_qvariant()
def headerData(self, section, orientation, role=Qt.DisplayRole):
if role == Qt.TextAlignmentRole:
- if orientation == Qt.Horizontal:
- return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter))
- return to_qvariant(int(Qt.AlignRight | Qt.AlignVCenter))
+ if orientation == Qt.Orientation.Horizontal:
+ return to_qvariant(int(Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignVCenter))
+ return to_qvariant(int(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter))
if role != Qt.DisplayRole:
return to_qvariant()
- if orientation == Qt.Horizontal:
+ if orientation == Qt.Orientation.Horizontal:
if section == self.TRIGGER:
return to_qvariant(_('Trigger text'))
elif section == self.DESCRIPTION:
@@ -780,11 +780,11 @@ def previous_row(self):
def keyPressEvent(self, event):
"""Qt Override."""
key = event.key()
- if key in [Qt.Key_Enter, Qt.Key_Return]:
+ if key in [Qt.Key.Key_Enter, Qt.Key.Key_Return]:
self.show_editor()
- elif key in [Qt.Key_Backtab]:
+ elif key in [Qt.Key.Key_Backtab]:
self.parent().reset_btn.setFocus()
- elif key in [Qt.Key_Up, Qt.Key_Down, Qt.Key_Left, Qt.Key_Right]:
+ elif key in [Qt.Key.Key_Up, Qt.Key.Key_Down, Qt.Key.Key_Left, Qt.Key.Key_Right]:
super(SnippetTable, self).keyPressEvent(event)
else:
super(SnippetTable, self).keyPressEvent(event)
diff --git a/spyder/plugins/console/tests/test_plugin.py b/spyder/plugins/console/tests/test_plugin.py
index 8cf3812cce3..fa945c17fa8 100644
--- a/spyder/plugins/console/tests/test_plugin.py
+++ b/spyder/plugins/console/tests/test_plugin.py
@@ -87,8 +87,8 @@ def test_completions(console_plugin, qtbot):
# Get completions
qtbot.keyClicks(shell, 'impor')
- qtbot.keyClick(shell, Qt.Key_Tab)
- qtbot.keyClick(shell.completion_widget, Qt.Key_Enter)
+ qtbot.keyClick(shell, Qt.Key.Key_Tab)
+ qtbot.keyClick(shell.completion_widget, Qt.Key.Key_Enter)
# Assert completion was introduced in the console
assert u'import' in shell.toPlainText()
diff --git a/spyder/plugins/console/widgets/main_widget.py b/spyder/plugins/console/widgets/main_widget.py
index 33be9c4f126..f9e494e328d 100644
--- a/spyder/plugins/console/widgets/main_widget.py
+++ b/spyder/plugins/console/widgets/main_widget.py
@@ -178,7 +178,7 @@ def setup(self):
tip=_("Quit"),
icon=self.create_icon('exit'),
triggered=self.sig_quit_requested,
- context=Qt.ApplicationShortcut,
+ context=Qt.ShortcutContext.ApplicationShortcut,
shortcut_context="_",
register_shortcut=True,
menurole=QAction.QuitRole
diff --git a/spyder/plugins/console/widgets/shell.py b/spyder/plugins/console/widgets/shell.py
index 8473a4a72da..adbc4b713b6 100644
--- a/spyder/plugins/console/widgets/shell.py
+++ b/spyder/plugins/console/widgets/shell.py
@@ -315,7 +315,7 @@ def preprocess_keyevent(self, event):
# if not on current line)
ctrl = event.modifiers() & Qt.ControlModifier
meta = event.modifiers() & Qt.MetaModifier # meta=ctrl in OSX
- if event.key() == Qt.Key_C and \
+ if event.key() == Qt.Key.Key_C and \
((Qt.MetaModifier | Qt.ControlModifier) & event.modifiers()):
if meta and sys.platform == 'darwin':
self.interrupt()
@@ -325,7 +325,7 @@ def preprocess_keyevent(self, event):
return True
if self.new_input_line and ( len(event.text()) or event.key() in \
- (Qt.Key_Up, Qt.Key_Down, Qt.Key_Left, Qt.Key_Right) ):
+ (Qt.Key.Key_Up, Qt.Key.Key_Down, Qt.Key.Key_Left, Qt.Key.Key_Right) ):
self.on_new_line()
return False
@@ -344,33 +344,33 @@ def postprocess_keyevent(self, event):
cursor_position = self.get_position('cursor')
- if key in (Qt.Key_Return, Qt.Key_Enter):
+ if key in (Qt.Key.Key_Return, Qt.Key.Key_Enter):
if self.is_cursor_on_last_line():
self._key_enter()
# add and run selection
else:
self.insert_text(self.get_selected_text(), at_end=True)
- elif key == Qt.Key_Insert and not shift and not ctrl:
+ elif key == Qt.Key.Key_Insert and not shift and not ctrl:
self.setOverwriteMode(not self.overwriteMode())
- elif key == Qt.Key_Delete:
+ elif key == Qt.Key.Key_Delete:
if self.has_selected_text():
self.check_selection()
self.remove_selected_text()
elif self.is_cursor_on_last_line():
self.stdkey_clear()
- elif key == Qt.Key_Backspace:
+ elif key == Qt.Key.Key_Backspace:
self._key_backspace(cursor_position)
- elif key == Qt.Key_Tab:
+ elif key == Qt.Key.Key_Tab:
self._key_tab()
- elif key == Qt.Key_Space and ctrl:
+ elif key == Qt.Key.Key_Space and ctrl:
self._key_ctrl_space()
- elif key == Qt.Key_Left:
+ elif key == Qt.Key.Key_Left:
if self.current_prompt_pos == cursor_position:
# Avoid moving cursor on prompt
return
@@ -378,20 +378,20 @@ def postprocess_keyevent(self, event):
else self.move_cursor_to_next
method('word' if ctrl else 'character', direction='left')
- elif key == Qt.Key_Right:
+ elif key == Qt.Key.Key_Right:
if self.is_cursor_at_end():
return
method = self.extend_selection_to_next if shift \
else self.move_cursor_to_next
method('word' if ctrl else 'character', direction='right')
- elif (key == Qt.Key_Home) or ((key == Qt.Key_Up) and ctrl):
+ elif (key == Qt.Key.Key_Home) or ((key == Qt.Key.Key_Up) and ctrl):
self._key_home(shift, ctrl)
- elif (key == Qt.Key_End) or ((key == Qt.Key_Down) and ctrl):
+ elif (key == Qt.Key.Key_End) or ((key == Qt.Key.Key_Down) and ctrl):
self._key_end(shift, ctrl)
- elif key == Qt.Key_Up:
+ elif key == Qt.Key.Key_Up:
if not self.is_cursor_on_last_line():
self.set_cursor_position('eof')
y_cursor = self.get_coordinates(cursor_position)[1]
@@ -401,7 +401,7 @@ def postprocess_keyevent(self, event):
else:
self.browse_history(backward=True)
- elif key == Qt.Key_Down:
+ elif key == Qt.Key.Key_Down:
if not self.is_cursor_on_last_line():
self.set_cursor_position('eof')
y_cursor = self.get_coordinates(cursor_position)[1]
@@ -411,43 +411,43 @@ def postprocess_keyevent(self, event):
else:
self.browse_history(backward=False)
- elif key in (Qt.Key_PageUp, Qt.Key_PageDown):
+ elif key in (Qt.Key.Key_PageUp, Qt.Key.Key_PageDown):
#XXX: Find a way to do this programmatically instead of calling
# widget keyhandler (this won't work if the *event* is coming from
# the event queue - i.e. if the busy buffer is ever implemented)
ConsoleBaseWidget.keyPressEvent(self, event)
- elif key == Qt.Key_Escape and shift:
+ elif key == Qt.Key.Key_Escape and shift:
self.clear_line()
- elif key == Qt.Key_Escape:
+ elif key == Qt.Key.Key_Escape:
self._key_escape()
- elif key == Qt.Key_L and ctrl:
+ elif key == Qt.Key.Key_L and ctrl:
self.clear_terminal()
- elif key == Qt.Key_V and ctrl:
+ elif key == Qt.Key.Key_V and ctrl:
self.paste()
- elif key == Qt.Key_X and ctrl:
+ elif key == Qt.Key.Key_X and ctrl:
self.cut()
- elif key == Qt.Key_Z and ctrl:
+ elif key == Qt.Key.Key_Z and ctrl:
self.undo()
- elif key == Qt.Key_Y and ctrl:
+ elif key == Qt.Key.Key_Y and ctrl:
self.redo()
- elif key == Qt.Key_A and ctrl:
+ elif key == Qt.Key.Key_A and ctrl:
self.selectAll()
- elif key == Qt.Key_Question and not self.has_selected_text():
+ elif key == Qt.Key.Key_Question and not self.has_selected_text():
self._key_question(text)
- elif key == Qt.Key_ParenLeft and not self.has_selected_text():
+ elif key == Qt.Key.Key_ParenLeft and not self.has_selected_text():
self._key_parenleft(text)
- elif key == Qt.Key_Period and not self.has_selected_text():
+ elif key == Qt.Key.Key_Period and not self.has_selected_text():
self._key_period(text)
elif len(text) and not self.isReadOnly():
diff --git a/spyder/plugins/editor/api/decoration.py b/spyder/plugins/editor/api/decoration.py
index ef792a841b4..40501792c0f 100644
--- a/spyder/plugins/editor/api/decoration.py
+++ b/spyder/plugins/editor/api/decoration.py
@@ -194,7 +194,7 @@ def set_full_width(self, flag=True, clear=True):
self.cursor.clearSelection()
self.format.setProperty(QTextFormat.FullWidthSelection, flag)
- def set_as_underlined(self, color=Qt.blue):
+ def set_as_underlined(self, color=Qt.GlobalColor.blue):
"""
Underlines the text.
@@ -204,7 +204,7 @@ def set_as_underlined(self, color=Qt.blue):
QTextCharFormat.SingleUnderline)
self.format.setUnderlineColor(color)
- def set_as_spell_check(self, color=Qt.blue):
+ def set_as_spell_check(self, color=Qt.GlobalColor.blue):
"""
Underlines text as a spellcheck error.
diff --git a/spyder/plugins/editor/extensions/docstring.py b/spyder/plugins/editor/extensions/docstring.py
index e0205e63ba0..c8602282221 100644
--- a/spyder/plugins/editor/extensions/docstring.py
+++ b/spyder/plugins/editor/extensions/docstring.py
@@ -1027,7 +1027,7 @@ def __init__(self, code_editor):
def keyPressEvent(self, event):
"""Close the instance if key is not enter key."""
key = event.key()
- if key not in (Qt.Key_Enter, Qt.Key_Return):
+ if key not in (Qt.Key.Key_Enter, Qt.Key.Key_Return):
self.code_editor.keyPressEvent(event)
self.close()
else:
diff --git a/spyder/plugins/editor/extensions/snippets.py b/spyder/plugins/editor/extensions/snippets.py
index f0746ea7858..8a2c83da529 100644
--- a/spyder/plugins/editor/extensions/snippets.py
+++ b/spyder/plugins/editor/extensions/snippets.py
@@ -205,7 +205,7 @@ def _on_key_pressed(self, event):
line, column = self.editor.get_cursor_line_column()
node, snippet, __ = self._find_node_by_position(
line, column)
- if key == Qt.Key_Tab:
+ if key == Qt.Key.Key_Tab:
event.accept()
next_snippet = ((self.active_snippet + 1) %
len(self.snippets_map))
@@ -213,7 +213,7 @@ def _on_key_pressed(self, event):
if next_snippet == 0:
self.reset()
- elif key == Qt.Key_Escape:
+ elif key == Qt.Key.Key_Escape:
self.reset()
event.accept()
elif len(text) > 0:
diff --git a/spyder/plugins/editor/extensions/tests/test_closequotes.py b/spyder/plugins/editor/extensions/tests/test_closequotes.py
index fcf0fd3ec68..7419da71cf5 100644
--- a/spyder/plugins/editor/extensions/tests/test_closequotes.py
+++ b/spyder/plugins/editor/extensions/tests/test_closequotes.py
@@ -147,7 +147,7 @@ def test_close_quotes_in_brackets(qtbot, editor_close_quotes):
assert editor.toPlainText() == 'foo("")'
assert editor.textCursor().columnNumber() == 5
# Test not closing when single quote is before a bracket
- qtbot.keyPress(editor, Qt.Key_Delete) # now 'foo(")'
+ qtbot.keyPress(editor, Qt.Key.Key_Delete) # now 'foo(")'
qtbot.keyClicks(editor, '"')
assert editor.toPlainText() == 'foo("")'
assert editor.textCursor().columnNumber() == 6
diff --git a/spyder/plugins/editor/extensions/tests/test_docstring.py b/spyder/plugins/editor/extensions/tests/test_docstring.py
index 62cffb99a46..294871c94f3 100644
--- a/spyder/plugins/editor/extensions/tests/test_docstring.py
+++ b/spyder/plugins/editor/extensions/tests/test_docstring.py
@@ -360,12 +360,12 @@ def test_editor_docstring_below_def_by_shortcut(qtbot, editor_auto_docstring,
None.
"""''',
- Qt.Key_Enter),
+ Qt.Key.Key_Enter),
('''def foo():
''',
'''def foo():
"""a''',
- Qt.Key_A)
+ Qt.Key.Key_A)
])
def test_editor_docstring_delayed_popup(qtbot, editor_auto_docstring,
text, expected, key):
@@ -379,13 +379,13 @@ def test_editor_docstring_delayed_popup(qtbot, editor_auto_docstring,
cursor.setPosition(QTextCursor.EndOfLine, QTextCursor.MoveAnchor)
editor.setTextCursor(cursor)
- qtbot.keyPress(editor, Qt.Key_Space)
- qtbot.keyPress(editor, Qt.Key_Space)
- qtbot.keyPress(editor, Qt.Key_Space)
- qtbot.keyPress(editor, Qt.Key_Space)
- qtbot.keyPress(editor, Qt.Key_QuoteDbl)
- qtbot.keyPress(editor, Qt.Key_QuoteDbl)
- qtbot.keyPress(editor, Qt.Key_QuoteDbl)
+ qtbot.keyPress(editor, Qt.Key.Key_Space)
+ qtbot.keyPress(editor, Qt.Key.Key_Space)
+ qtbot.keyPress(editor, Qt.Key.Key_Space)
+ qtbot.keyPress(editor, Qt.Key.Key_Space)
+ qtbot.keyPress(editor, Qt.Key.Key_QuoteDbl)
+ qtbot.keyPress(editor, Qt.Key.Key_QuoteDbl)
+ qtbot.keyPress(editor, Qt.Key.Key_QuoteDbl)
qtbot.wait(1000)
qtbot.keyPress(editor.menu_docstring, key)
qtbot.wait(1000)
diff --git a/spyder/plugins/editor/panels/classfunctiondropdown.py b/spyder/plugins/editor/panels/classfunctiondropdown.py
index 7e054af548d..eae636fd830 100644
--- a/spyder/plugins/editor/panels/classfunctiondropdown.py
+++ b/spyder/plugins/editor/panels/classfunctiondropdown.py
@@ -154,7 +154,7 @@ class or function definition in the file.
combobox.addItem(_(''), 0)
model = combobox.model()
item = model.item(0)
- item.setFlags(Qt.NoItemFlags)
+ item.setFlags(Qt.ItemFlag.NoItemFlags)
cb_data = []
for item in data:
diff --git a/spyder/plugins/editor/panels/codefolding.py b/spyder/plugins/editor/panels/codefolding.py
index 4baaca22246..899e4010b72 100644
--- a/spyder/plugins/editor/panels/codefolding.py
+++ b/spyder/plugins/editor/panels/codefolding.py
@@ -453,7 +453,7 @@ def mouseMoveEvent(self, event):
if self._mouse_over_line is None:
# mouse enter fold scope
QApplication.setOverrideCursor(
- QCursor(Qt.PointingHandCursor))
+ QCursor(Qt.CursorShape.PointingHandCursor))
if (self._mouse_over_line != block.blockNumber() and
self._mouse_over_line is not None):
# fold scope changed, a previous block was highlighter so
@@ -617,10 +617,10 @@ def _on_key_pressed(self, event):
Override key press to select the current scope if the user wants
to deleted a folded scope (without selecting it).
"""
- delete_request = event.key() in {Qt.Key_Delete, Qt.Key_Backspace}
+ delete_request = event.key() in {Qt.Key.Key_Delete, Qt.Key.Key_Backspace}
cursor = self.editor.textCursor()
if cursor.hasSelection():
- if event.key() == Qt.Key_Return:
+ if event.key() == Qt.Key.Key_Return:
delete_request = True
if event.text() or delete_request:
diff --git a/spyder/plugins/editor/panels/edgeline.py b/spyder/plugins/editor/panels/edgeline.py
index a535db4388f..5ac05c5cf9b 100644
--- a/spyder/plugins/editor/panels/edgeline.py
+++ b/spyder/plugins/editor/panels/edgeline.py
@@ -24,7 +24,7 @@ class EdgeLine(Panel):
def __init__(self):
Panel.__init__(self)
self.columns = (79,)
- self.color = Qt.darkGray
+ self.color = Qt.GlobalColor.darkGray
def paintEvent(self, event):
"""Override Qt method"""
diff --git a/spyder/plugins/editor/panels/indentationguides.py b/spyder/plugins/editor/panels/indentationguides.py
index 270b0d33494..8f3416b61ea 100644
--- a/spyder/plugins/editor/panels/indentationguides.py
+++ b/spyder/plugins/editor/panels/indentationguides.py
@@ -26,7 +26,7 @@ def __init__(self):
i_width(int): identation width in characters.
"""
Panel.__init__(self)
- self.color = Qt.darkGray
+ self.color = Qt.GlobalColor.darkGray
self.i_width = 4
self.bar_offset = 0
diff --git a/spyder/plugins/editor/panels/linenumber.py b/spyder/plugins/editor/panels/linenumber.py
index a2f11e931c9..871ef3d107e 100644
--- a/spyder/plugins/editor/panels/linenumber.py
+++ b/spyder/plugins/editor/panels/linenumber.py
@@ -33,7 +33,7 @@ def __init__(self):
self.setMouseTracking(True)
self.scrollable = True
- self.linenumbers_color = QColor(Qt.darkGray)
+ self.linenumbers_color = QColor(Qt.GlobalColor.darkGray)
# Markers
self._markers_margin = True
@@ -220,7 +220,7 @@ def draw_linenumbers_slow(self, painter):
painter.drawText(0, top, self.width(),
font_height,
- int(Qt.AlignRight | Qt.AlignBottom),
+ int(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignBottom),
str(line_number))
def leaveEvent(self, event):
@@ -245,7 +245,7 @@ def mouseMoveEvent(self, event):
else:
self.editor.hide_tooltip()
- if event.buttons() == Qt.LeftButton:
+ if event.buttons() == Qt.MouseButton.LeftButton:
self._released = line_number
self.editor.select_lines(self._pressed, self._released)
diff --git a/spyder/plugins/editor/panels/scrollflag.py b/spyder/plugins/editor/panels/scrollflag.py
index 1ae496f039d..231f8269c22 100644
--- a/spyder/plugins/editor/panels/scrollflag.py
+++ b/spyder/plugins/editor/panels/scrollflag.py
@@ -46,9 +46,9 @@ def __init__(self):
self._range_indicator_is_visible = False
self._alt_key_is_down = False
- self._slider_range_color = QColor(Qt.gray)
+ self._slider_range_color = QColor(Qt.GlobalColor.gray)
self._slider_range_color.setAlphaF(.85)
- self._slider_range_brush = QColor(Qt.gray)
+ self._slider_range_brush = QColor(Qt.GlobalColor.gray)
self._slider_range_brush.setAlphaF(.5)
self._update_list_timer = QTimer(self)
@@ -295,20 +295,20 @@ def mouseMoveEvent(self, event):
def mousePressEvent(self, event):
"""Override Qt method"""
- if self.slider and event.button() == Qt.LeftButton:
+ if self.slider and event.button() == Qt.MouseButton.LeftButton:
vsb = self.editor.verticalScrollBar()
value = self.position_to_value(event.pos().y())
vsb.setValue(int(value-vsb.pageStep()/2))
def keyReleaseEvent(self, event):
"""Override Qt method."""
- if event.key() == Qt.Key_Alt:
+ if event.key() == Qt.Key.Key_Alt:
self._alt_key_is_down = False
self.update()
def keyPressEvent(self, event):
"""Override Qt method"""
- if event.key() == Qt.Key_Alt:
+ if event.key() == Qt.Key.Key_Alt:
self._alt_key_is_down = True
self.update()
diff --git a/spyder/plugins/editor/panels/tests/test_scrollflag.py b/spyder/plugins/editor/panels/tests/test_scrollflag.py
index 69f7c60e54e..5216da3089c 100644
--- a/spyder/plugins/editor/panels/tests/test_scrollflag.py
+++ b/spyder/plugins/editor/panels/tests/test_scrollflag.py
@@ -217,14 +217,14 @@ def test_range_indicator_alt_modifier_response(editor_bot, qtbot):
# Set the cursor position to the center of the editor.
w = editor.width()
h = editor.height()
- qtbot.mousePress(editor, Qt.LeftButton, pos=QPoint(w//2, h//2))
+ qtbot.mousePress(editor, Qt.MouseButton.LeftButton, pos=QPoint(w//2, h//2))
# Hold the alt key and assert that the slider range indicator is visible.
# Because it is not possible to simulate the action of holding the alt
# key down in pytest-qt, this is done through a flag in the ScrollFlagArea
# that is set to True when pressing the alt key and to false when releasing
# it. This flag is only used for testing purpose.
- qtbot.keyPress(editor, Qt.Key_Alt)
+ qtbot.keyPress(editor, Qt.Key.Key_Alt)
editor.resize(600, 150)
x = int(sfa.width()/2)
y = int(sfa.height()/2)
@@ -235,7 +235,7 @@ def test_range_indicator_alt_modifier_response(editor_bot, qtbot):
# editor's height and assert that the editor vertical scrollbar has moved
# to its middle range position.
with qtbot.waitSignal(editor.sig_alt_left_mouse_pressed, raising=True):
- qtbot.mousePress(editor.viewport(), Qt.LeftButton,
+ qtbot.mousePress(editor.viewport(), Qt.MouseButton.LeftButton,
Qt.AltModifier, QPoint(w//2, h//2))
assert vsb.value() == (vsb.minimum()+vsb.maximum())//2
@@ -243,7 +243,7 @@ def test_range_indicator_alt_modifier_response(editor_bot, qtbot):
# editor's height and assert that the editor vertical scrollbar has moved
# to its minimum position.
with qtbot.waitSignal(editor.sig_alt_left_mouse_pressed, raising=True):
- qtbot.mousePress(editor.viewport(), Qt.LeftButton,
+ qtbot.mousePress(editor.viewport(), Qt.MouseButton.LeftButton,
Qt.AltModifier, QPoint(w//2, 1))
assert vsb.value() == vsb.minimum()
@@ -251,7 +251,7 @@ def test_range_indicator_alt_modifier_response(editor_bot, qtbot):
# editor's height and assert that the editor vertical scrollbar has moved
# to its maximum position.
with qtbot.waitSignal(editor.sig_alt_left_mouse_pressed, raising=True):
- qtbot.mousePress(editor.viewport(), Qt.LeftButton,
+ qtbot.mousePress(editor.viewport(), Qt.MouseButton.LeftButton,
Qt.AltModifier, QPoint(w//2, h-1))
assert vsb.value() == vsb.maximum()
@@ -261,7 +261,7 @@ def test_range_indicator_alt_modifier_response(editor_bot, qtbot):
x = int(sfa.width()/2)
y = int(sfa.height()/2)
qtbot.mouseMove(sfa, pos=QPoint(x*100, y), delay=-1)
- qtbot.keyRelease(editor, Qt.Key_Alt)
+ qtbot.keyRelease(editor, Qt.Key.Key_Alt)
qtbot.waitUntil(lambda: not sfa._range_indicator_is_visible, timeout=3000)
diff --git a/spyder/plugins/editor/plugin.py b/spyder/plugins/editor/plugin.py
index 9414250135e..2c8d15b84b8 100644
--- a/spyder/plugins/editor/plugin.py
+++ b/spyder/plugins/editor/plugin.py
@@ -275,7 +275,7 @@ def __init__(self, parent, ignore_last_opened_files=False):
self.splitter.setStretchFactor(1, 1)
layout.addWidget(self.splitter)
self.setLayout(layout)
- self.setFocusPolicy(Qt.ClickFocus)
+ self.setFocusPolicy(Qt.FocusPolicy.ClickFocus)
# Editor's splitter state
state = self.get_option('splitter_state', None)
@@ -508,7 +508,7 @@ def get_plugin_actions(self):
_("&New file..."),
icon=ima.icon('filenew'), tip=_("New file"),
triggered=self.new,
- context=Qt.WidgetShortcut
+ context=Qt.ShortcutContext.WidgetShortcut
)
self.register_shortcut(self.new_action, context="Editor",
name="New file", add_shortcut_to_tip=True)
@@ -525,7 +525,7 @@ def get_plugin_actions(self):
self.open_action = create_action(self, _("&Open..."),
icon=ima.icon('fileopen'), tip=_("Open file"),
triggered=self.load,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(self.open_action, context="Editor",
name="Open file", add_shortcut_to_tip=True)
@@ -536,21 +536,21 @@ def get_plugin_actions(self):
self.save_action = create_action(self, _("&Save"),
icon=ima.icon('filesave'), tip=_("Save file"),
triggered=self.save,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(self.save_action, context="Editor",
name="Save file", add_shortcut_to_tip=True)
self.save_all_action = create_action(self, _("Sav&e all"),
icon=ima.icon('save_all'), tip=_("Save all files"),
triggered=self.save_all,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(self.save_all_action, context="Editor",
name="Save all", add_shortcut_to_tip=True)
save_as_action = create_action(self, _("Save &as..."), None,
ima.icon('filesaveas'), tip=_("Save current file as..."),
triggered=self.save_as,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(save_as_action, "Editor", "Save As")
save_copy_as_action = create_action(self, _("Save copy as..."), None,
@@ -570,7 +570,7 @@ def get_plugin_actions(self):
self.close_all_action = create_action(self, _("C&lose all"),
icon=ima.icon('filecloseall'), tip=_("Close all opened files"),
triggered=self.close_all_files,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(self.close_all_action, context="Editor",
name="Close all")
@@ -578,25 +578,25 @@ def get_plugin_actions(self):
_text = _("&Find text")
find_action = create_action(self, _text, icon=ima.icon('find'),
tip=_text, triggered=self.find,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(find_action, context="find_replace",
name="Find text", add_shortcut_to_tip=True)
find_next_action = create_action(self, _("Find &next"),
icon=ima.icon('findnext'),
triggered=self.find_next,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(find_next_action, context="find_replace",
name="Find next")
find_previous_action = create_action(self, _("Find &previous"),
icon=ima.icon('findprevious'),
triggered=self.find_previous,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(find_previous_action, context="find_replace",
name="Find previous")
_text = _("&Replace text")
replace_action = create_action(self, _text, icon=ima.icon('replace'),
tip=_text, triggered=self.replace,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(replace_action, context="find_replace",
name="Replace text")
@@ -605,7 +605,7 @@ def get_plugin_actions(self):
_("Set/Clear breakpoint"),
icon=ima.icon('breakpoint_big'),
triggered=self.set_or_clear_breakpoint,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(set_clear_breakpoint_action, context="Editor",
name="Breakpoint")
@@ -613,7 +613,7 @@ def get_plugin_actions(self):
_("Set/Edit conditional breakpoint"),
icon=ima.icon('breakpoint_cond_big'),
triggered=self.set_or_edit_conditional_breakpoint,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(set_cond_breakpoint_action, context="Editor",
name="Conditional breakpoint")
@@ -702,21 +702,21 @@ def get_plugin_actions(self):
tip=_("Run selection or "
"current line"),
triggered=self.run_selection,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(run_selected_action, context="Editor",
name="Run selection", add_shortcut_to_tip=True)
run_to_line_action = create_action(self, _("Run &to current line"),
tip=_("Run to current line"),
triggered=self.run_to_line,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(run_to_line_action, context="Editor",
name="Run to line", add_shortcut_to_tip=True)
run_from_line_action = create_action(self, _("Run &from current line"),
tip=_("Run from current line"),
triggered=self.run_from_line,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(run_from_line_action, context="Editor",
name="Run from line", add_shortcut_to_tip=True)
@@ -726,7 +726,7 @@ def get_plugin_actions(self):
tip=_("Run current cell \n"
"[Use #%% to create cells]"),
triggered=self.run_cell,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(run_cell_action, context="Editor",
name="Run cell", add_shortcut_to_tip=True)
@@ -737,7 +737,7 @@ def get_plugin_actions(self):
icon=ima.icon('run_cell_advance'),
tip=_("Run current cell and go to the next one "),
triggered=self.run_cell_and_advance,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(run_cell_advance_action, context="Editor",
name="Run cell and advance",
@@ -750,7 +750,7 @@ def get_plugin_actions(self):
tip=_("Debug current cell "
"(Alt+Shift+Enter)"),
triggered=self.debug_cell,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(self.debug_cell_action, context="Editor",
name="Debug cell",
@@ -760,7 +760,7 @@ def get_plugin_actions(self):
_("Re-run last cell"),
tip=_("Re run last cell "),
triggered=self.re_run_last_cell,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(re_run_last_cell_action,
context="Editor",
name='re-run last cell',
@@ -789,7 +789,7 @@ def get_plugin_actions(self):
_("Previous warning/error"), icon=ima.icon('prev_wng'),
tip=_("Go to previous code analysis warning/error"),
triggered=self.go_to_previous_warning,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(self.previous_warning_action,
context="Editor",
name="Previous warning",
@@ -798,7 +798,7 @@ def get_plugin_actions(self):
_("Next warning/error"), icon=ima.icon('next_wng'),
tip=_("Go to next code analysis warning/error"),
triggered=self.go_to_next_warning,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(self.next_warning_action,
context="Editor",
name="Next warning",
@@ -808,7 +808,7 @@ def get_plugin_actions(self):
_("Last edit location"), icon=ima.icon('last_edit_location'),
tip=_("Go to last edit location"),
triggered=self.go_to_last_edit_location,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(self.previous_edit_cursor_action,
context="Editor",
name="Last edit location",
@@ -817,7 +817,7 @@ def get_plugin_actions(self):
_("Previous cursor position"), icon=ima.icon('prev_cursor'),
tip=_("Go to previous cursor position"),
triggered=self.go_to_previous_cursor_position,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(self.previous_cursor_action,
context="Editor",
name="Previous cursor position",
@@ -826,7 +826,7 @@ def get_plugin_actions(self):
_("Next cursor position"), icon=ima.icon('next_cursor'),
tip=_("Go to next cursor position"),
triggered=self.go_to_next_cursor_position,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(self.next_cursor_action,
context="Editor",
name="Next cursor position",
@@ -836,47 +836,47 @@ def get_plugin_actions(self):
self.toggle_comment_action = create_action(self,
_("Comment")+"/"+_("Uncomment"), icon=ima.icon('comment'),
tip=_("Comment current line or selection"),
- triggered=self.toggle_comment, context=Qt.WidgetShortcut)
+ triggered=self.toggle_comment, context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(self.toggle_comment_action, context="Editor",
name="Toggle comment")
blockcomment_action = create_action(self, _("Add &block comment"),
tip=_("Add block comment around "
"current line or selection"),
- triggered=self.blockcomment, context=Qt.WidgetShortcut)
+ triggered=self.blockcomment, context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(blockcomment_action, context="Editor",
name="Blockcomment")
unblockcomment_action = create_action(self,
_("R&emove block comment"),
tip = _("Remove comment block around "
"current line or selection"),
- triggered=self.unblockcomment, context=Qt.WidgetShortcut)
+ triggered=self.unblockcomment, context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(unblockcomment_action, context="Editor",
name="Unblockcomment")
# ----------------------------------------------------------------------
# The following action shortcuts are hard-coded in CodeEditor
# keyPressEvent handler (the shortcut is here only to inform user):
- # (context=Qt.WidgetShortcut -> disable shortcut for other widgets)
+ # (context=Qt.ShortcutContext.WidgetShortcut -> disable shortcut for other widgets)
self.indent_action = create_action(self,
_("Indent"), "Tab", icon=ima.icon('indent'),
tip=_("Indent current line or selection"),
- triggered=self.indent, context=Qt.WidgetShortcut)
+ triggered=self.indent, context=Qt.ShortcutContext.WidgetShortcut)
self.unindent_action = create_action(self,
_("Unindent"), "Shift+Tab", icon=ima.icon('unindent'),
tip=_("Unindent current line or selection"),
- triggered=self.unindent, context=Qt.WidgetShortcut)
+ triggered=self.unindent, context=Qt.ShortcutContext.WidgetShortcut)
self.text_uppercase_action = create_action(self,
_("Toggle Uppercase"), icon=ima.icon('toggle_uppercase'),
tip=_("Change to uppercase current line or selection"),
- triggered=self.text_uppercase, context=Qt.WidgetShortcut)
+ triggered=self.text_uppercase, context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(self.text_uppercase_action, context="Editor",
name="transform to uppercase")
self.text_lowercase_action = create_action(self,
_("Toggle Lowercase"), icon=ima.icon('toggle_lowercase'),
tip=_("Change to lowercase current line or selection"),
- triggered=self.text_lowercase, context=Qt.WidgetShortcut)
+ triggered=self.text_lowercase, context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(self.text_lowercase_action, context="Editor",
name="transform to lowercase")
# ----------------------------------------------------------------------
@@ -918,7 +918,7 @@ def get_plugin_actions(self):
_('Format file or selection with {0}').format(
formatter.capitalize()),
shortcut=CONF.get_shortcut('editor', 'autoformatting'),
- context=Qt.WidgetShortcut,
+ context=Qt.ShortcutContext.WidgetShortcut,
triggered=self.format_document_or_selection)
self.formatting_action.setEnabled(False)
@@ -967,7 +967,7 @@ def get_plugin_actions(self):
gotoline_action = create_action(self, _("Go to line..."),
icon=ima.icon('gotoline'),
triggered=self.go_to_line,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.register_shortcut(gotoline_action, context="Editor",
name="Go to line")
diff --git a/spyder/plugins/editor/tests/test_plugin.py b/spyder/plugins/editor/tests/test_plugin.py
index 59123b524cc..54da2439740 100644
--- a/spyder/plugins/editor/tests/test_plugin.py
+++ b/spyder/plugins/editor/tests/test_plugin.py
@@ -439,7 +439,7 @@ def test_save_with_os_eol_chars(editor_plugin, mocker, qtbot, tmpdir):
# Write some blank lines on it.
for __ in range(3):
- qtbot.keyClick(codeeditor, Qt.Key_Return)
+ qtbot.keyClick(codeeditor, Qt.Key.Key_Return)
# Save file and check that it has the right eol.
editorstack.save()
diff --git a/spyder/plugins/editor/widgets/base.py b/spyder/plugins/editor/widgets/base.py
index efc660f7091..b92627d58c5 100644
--- a/spyder/plugins/editor/widgets/base.py
+++ b/spyder/plugins/editor/widgets/base.py
@@ -495,7 +495,7 @@ def keyPressEvent(self, event):
meta = event.modifiers() & Qt.MetaModifier
# Use our own copy method for {Ctrl,Cmd}+C to avoid Qt
# copying text in HTML. See spyder-ide/spyder#2285.
- if (ctrl or meta) and key == Qt.Key_C:
+ if (ctrl or meta) and key == Qt.Key.Key_C:
self.copy()
else:
super(TextEditBaseWidget, self).keyPressEvent(event)
@@ -1062,7 +1062,7 @@ def mousePressEvent(self, event):
self.calltip_widget.hide()
self.setFocus()
event = QMouseEvent(QEvent.MouseButtonPress, event.pos(),
- Qt.LeftButton, Qt.LeftButton, Qt.NoModifier)
+ Qt.MouseButton.LeftButton, Qt.MouseButton.LeftButton, Qt.KeyboardModifier.NoModifier)
QPlainTextEdit.mousePressEvent(self, event)
QPlainTextEdit.mouseReleaseEvent(self, event)
# Send selection text to clipboard to be able to use
diff --git a/spyder/plugins/editor/widgets/codeeditor.py b/spyder/plugins/editor/widgets/codeeditor.py
index 45bbc0b8b97..7341ed1269d 100644
--- a/spyder/plugins/editor/widgets/codeeditor.py
+++ b/spyder/plugins/editor/widgets/codeeditor.py
@@ -297,7 +297,7 @@ class CodeEditor(TextEditBaseWidget):
def __init__(self, parent=None):
TextEditBaseWidget.__init__(self, parent)
- self.setFocusPolicy(Qt.StrongFocus)
+ self.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
# Projects
self.current_project_path = None
@@ -532,7 +532,7 @@ def __init__(self, parent=None):
self.setMouseTracking(True)
self.__cursor_changed = False
self._mouse_left_button_pressed = False
- self.ctrl_click_color = QColor(Qt.blue)
+ self.ctrl_click_color = QColor(Qt.GlobalColor.blue)
self._bookmarks_blocks = {}
self.bookmarks = []
@@ -4661,7 +4661,7 @@ def keyReleaseEvent(self, event):
"""Override Qt method."""
self.sig_key_released.emit(event)
key = event.key()
- direction_keys = {Qt.Key_Up, Qt.Key_Left, Qt.Key_Right, Qt.Key_Down}
+ direction_keys = {Qt.Key.Key_Up, Qt.Key.Key_Left, Qt.Key.Key_Right, Qt.Key.Key_Down}
if key in direction_keys:
self.request_cursor_event()
@@ -4669,7 +4669,7 @@ def keyReleaseEvent(self, event):
# trigger the emission of the valueChanged signal in
# verticalScrollBar.
# See https://bugreports.qt.io/browse/QTBUG-25365
- if key in {Qt.Key_Up, Qt.Key_Down}:
+ if key in {Qt.Key.Key_Up, Qt.Key.Key_Down}:
self.update_decorations_timer.start()
# This necessary to run our Pygments highlighter again after the
@@ -4744,15 +4744,15 @@ def keyPressEvent(self, event):
self.clear_occurrences()
- if key in {Qt.Key_Up, Qt.Key_Left, Qt.Key_Right, Qt.Key_Down}:
+ if key in {Qt.Key.Key_Up, Qt.Key.Key_Left, Qt.Key.Key_Right, Qt.Key.Key_Down}:
self.hide_tooltip()
if event.isAccepted():
# The event was handled by one of the editor extension.
return
- if key in [Qt.Key_Control, Qt.Key_Shift, Qt.Key_Alt,
- Qt.Key_Meta, Qt.KeypadModifier]:
+ if key in [Qt.Key.Key_Control, Qt.Key.Key_Shift, Qt.Key.Key_Alt,
+ Qt.Key.Key_Meta, Qt.KeypadModifier]:
# The user pressed only a modifier key.
if ctrl:
pos = self.mapFromGlobal(QCursor.pos())
@@ -4775,7 +4775,7 @@ def keyPressEvent(self, event):
if text not in self.auto_completion_characters:
if text in operators or text in delimiters:
self.completion_widget.hide()
- if key in (Qt.Key_Enter, Qt.Key_Return):
+ if key in (Qt.Key.Key_Enter, Qt.Key.Key_Return):
if not shift and not ctrl:
if (
self.add_colons_enabled and
@@ -4818,9 +4818,9 @@ def keyPressEvent(self, event):
self.fix_indent(comment_or_string=cmt_or_str,
cur_indent=cur_indent)
self.textCursor().endEditBlock()
- elif key == Qt.Key_Insert and not shift and not ctrl:
+ elif key == Qt.Key.Key_Insert and not shift and not ctrl:
self.setOverwriteMode(not self.overwriteMode())
- elif key == Qt.Key_Backspace and not shift and not ctrl:
+ elif key == Qt.Key.Key_Backspace and not shift and not ctrl:
if has_selection or not self.intelligent_backspace:
self._handle_keypress_event(event)
else:
@@ -4851,9 +4851,9 @@ def keyPressEvent(self, event):
cursor.removeSelectedText()
else:
self._handle_keypress_event(event)
- elif key == Qt.Key_Home:
+ elif key == Qt.Key.Key_Home:
self.stdkey_home(shift, ctrl)
- elif key == Qt.Key_End:
+ elif key == Qt.Key.Key_End:
# See spyder-ide/spyder#495: on MacOS X, it is necessary to
# redefine this basic action which should have been implemented
# natively
@@ -4884,7 +4884,7 @@ def keyPressEvent(self, event):
self.insert_text(text)
self.request_signature()
elif (
- key == Qt.Key_Colon and
+ key == Qt.Key.Key_Colon and
not has_selection and
self.auto_unindent_enabled
):
@@ -4899,7 +4899,7 @@ def keyPressEvent(self, event):
self.unindent(force=True)
self._handle_keypress_event(event)
elif (
- key == Qt.Key_Space and
+ key == Qt.Key.Key_Space and
not shift and
not ctrl and
not has_selection and
@@ -4916,7 +4916,7 @@ def keyPressEvent(self, event):
if ind(leading_text) == ind(prevtxt):
self.unindent(force=True)
self._handle_keypress_event(event)
- elif key == Qt.Key_Tab and not ctrl:
+ elif key == Qt.Key.Key_Tab and not ctrl:
# Important note: can't be called with a QShortcut because
# of its singular role with respect to widget focus management
if not has_selection and not self.tab_mode:
@@ -4924,7 +4924,7 @@ def keyPressEvent(self, event):
else:
# indent the selected text
self.indent_or_replace()
- elif key == Qt.Key_Backtab and not ctrl:
+ elif key == Qt.Key.Key_Backtab and not ctrl:
# Backtab, i.e. Shift+, could be treated as a QShortcut but
# there is no point since can't (see above)
if not has_selection and not self.tab_mode:
@@ -4954,14 +4954,14 @@ def do_automatic_completions(self):
key = self._last_pressed_key
if key is not None:
- if key in [Qt.Key_Return, Qt.Key_Escape,
- Qt.Key_Tab, Qt.Key_Backtab, Qt.Key_Space]:
+ if key in [Qt.Key.Key_Return, Qt.Key.Key_Escape,
+ Qt.Key.Key_Tab, Qt.Key.Key_Backtab, Qt.Key.Key_Space]:
self._last_pressed_key = None
return
# Correctly handle completions when Backspace key is pressed.
# We should not show the widget if deleting a space before a word.
- if key == Qt.Key_Backspace:
+ if key == Qt.Key.Key_Backspace:
cursor.setPosition(pos - 1, QTextCursor.MoveAnchor)
cursor.select(QTextCursor.WordUnderCursor)
prev_text = to_text_string(cursor.selectedText())
@@ -4987,7 +4987,7 @@ def do_automatic_completions(self):
text = to_text_string(cursor.selectedText())
is_backspace = (
- self.is_completion_widget_visible() and key == Qt.Key_Backspace)
+ self.is_completion_widget_visible() and key == Qt.Key.Key_Backspace)
if (
(len(text) >= self.automatic_completions_after_chars) and
@@ -5111,7 +5111,7 @@ def _handle_goto_definition_event(self, pos):
text = self.get_word_at(pos)
if text and not sourcecode.is_keyword(to_text_string(text)):
if not self.__cursor_changed:
- QApplication.setOverrideCursor(QCursor(Qt.PointingHandCursor))
+ QApplication.setOverrideCursor(QCursor(Qt.CursorShape.PointingHandCursor))
self.__cursor_changed = True
cursor = self.cursorForPosition(pos)
cursor.select(QTextCursor.WordUnderCursor)
@@ -5148,7 +5148,7 @@ def _handle_goto_uri_event(self, pos):
if not self.__cursor_changed:
QApplication.setOverrideCursor(
- QCursor(Qt.PointingHandCursor))
+ QCursor(Qt.CursorShape.PointingHandCursor))
self.__cursor_changed = True
self.sig_uri_found.emit(pattern_text)
@@ -5439,9 +5439,9 @@ def mousePressEvent(self, event):
ctrl = event.modifiers() & Qt.ControlModifier
alt = event.modifiers() & Qt.AltModifier
pos = event.pos()
- self._mouse_left_button_pressed = event.button() == Qt.LeftButton
+ self._mouse_left_button_pressed = event.button() == Qt.MouseButton.LeftButton
- if event.button() == Qt.LeftButton and ctrl:
+ if event.button() == Qt.MouseButton.LeftButton and ctrl:
TextEditBaseWidget.mousePressEvent(self, event)
cursor = self.cursorForPosition(pos)
uri = self._last_hover_pattern_text
@@ -5449,14 +5449,14 @@ def mousePressEvent(self, event):
self.go_to_uri_from_cursor(uri)
else:
self.go_to_definition_from_cursor(cursor)
- elif event.button() == Qt.LeftButton and alt:
+ elif event.button() == Qt.MouseButton.LeftButton and alt:
self.sig_alt_left_mouse_pressed.emit(event)
else:
TextEditBaseWidget.mousePressEvent(self, event)
def mouseReleaseEvent(self, event):
"""Override Qt method."""
- if event.button() == Qt.LeftButton:
+ if event.button() == Qt.MouseButton.LeftButton:
self._mouse_left_button_pressed = False
self.request_cursor_event()
diff --git a/spyder/plugins/editor/widgets/completion.py b/spyder/plugins/editor/widgets/completion.py
index a3379df371b..e39c1c7d01b 100644
--- a/spyder/plugins/editor/widgets/completion.py
+++ b/spyder/plugins/editor/widgets/completion.py
@@ -315,14 +315,14 @@ def keyPressEvent(self, event):
alt = event.modifiers() & Qt.AltModifier
shift = event.modifiers() & Qt.ShiftModifier
ctrl = event.modifiers() & Qt.ControlModifier
- altgr = event.modifiers() and (key == Qt.Key_AltGr)
+ altgr = event.modifiers() and (key == Qt.Key.Key_AltGr)
# Needed to properly handle Neo2 and other keyboard layouts
# See spyder-ide/spyder#11293
neo2_level4 = (key == 0) # AltGr (ISO_Level5_Shift) in Neo2 on Linux
modifier = shift or ctrl or alt or altgr or neo2_level4
- if key in (Qt.Key_Return, Qt.Key_Enter, Qt.Key_Tab):
+ if key in (Qt.Key.Key_Return, Qt.Key.Key_Enter, Qt.Key.Key_Tab):
# Check that what was selected can be selected,
# otherwise timing issues
item = self.currentItem()
@@ -334,29 +334,29 @@ def keyPressEvent(self, event):
else:
self.hide()
self.textedit.keyPressEvent(event)
- elif key == Qt.Key_Escape:
+ elif key == Qt.Key.Key_Escape:
self.hide()
- elif key in (Qt.Key_Left, Qt.Key_Right) or text in ('.', ':'):
+ elif key in (Qt.Key.Key_Left, Qt.Key.Key_Right) or text in ('.', ':'):
self.hide()
self.textedit.keyPressEvent(event)
elif (
- key in (Qt.Key_Up, Qt.Key_Down, Qt.Key_PageUp, Qt.Key_PageDown)
+ key in (Qt.Key.Key_Up, Qt.Key.Key_Down, Qt.Key.Key_PageUp, Qt.Key.Key_PageDown)
and not modifier
):
self.textedit._completions_hint_idle = True
- if key == Qt.Key_Up and self.currentRow() == 0:
+ if key == Qt.Key.Key_Up and self.currentRow() == 0:
self.setCurrentRow(self.count() - 1)
- elif key == Qt.Key_Down and self.currentRow() == self.count()-1:
+ elif key == Qt.Key.Key_Down and self.currentRow() == self.count()-1:
self.setCurrentRow(0)
else:
QListWidget.keyPressEvent(self, event)
- elif key in (Qt.Key_Home, Qt.Key_End):
+ elif key in (Qt.Key.Key_Home, Qt.Key.Key_End):
# This allows users to easily move to the beginning/end of the
# current line when this widget is visible.
# Fixes spyder-ide/spyder#19989
self.hide()
self.textedit.keyPressEvent(event)
- elif key == Qt.Key_Backspace:
+ elif key == Qt.Key.Key_Backspace:
self.textedit.keyPressEvent(event)
self.update_current(new=False)
elif len(text):
@@ -482,7 +482,7 @@ def focusOutEvent(self, event):
# keyboard input is lost.
# Fixes spyder-ide/spyder#1318.
if sys.platform == "darwin":
- if event.reason() != Qt.ActiveWindowFocusReason:
+ if event.reason() != Qt.FocusReason.ActiveWindowFocusReason:
self.hide()
else:
# Avoid an error when running tests that show
diff --git a/spyder/plugins/editor/widgets/editor.py b/spyder/plugins/editor/widgets/editor.py
index 8633a4c82ed..f84d59b549f 100644
--- a/spyder/plugins/editor/widgets/editor.py
+++ b/spyder/plugins/editor/widgets/editor.py
@@ -147,23 +147,23 @@ def keyReleaseEvent(self, event):
for key in qsc.split('+'):
key = key.lower()
- if ((key == 'ctrl' and event.key() == Qt.Key_Control) or
- (key == 'alt' and event.key() == Qt.Key_Alt)):
+ if ((key == 'ctrl' and event.key() == Qt.Key.Key_Control) or
+ (key == 'alt' and event.key() == Qt.Key.Key_Alt)):
self.item_selected()
event.accept()
def keyPressEvent(self, event):
"""Reimplement Qt method to allow cyclic behavior."""
- if event.key() == Qt.Key_Down:
+ if event.key() == Qt.Key.Key_Down:
self.select_row(1)
- elif event.key() == Qt.Key_Up:
+ elif event.key() == Qt.Key.Key_Up:
self.select_row(-1)
def focusOutEvent(self, event):
"""Reimplement Qt method to close the widget when loosing focus."""
event.ignore()
if sys.platform == "darwin":
- if event.reason() != Qt.ActiveWindowFocusReason:
+ if event.reason() != Qt.FocusReason.ActiveWindowFocusReason:
self.close()
else:
self.close()
@@ -308,7 +308,7 @@ def __init__(self, parent, actions):
triggered=self.show_in_external_file_explorer,
shortcut=CONF.get_shortcut(context="Editor",
name="show in external file explorer"),
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.menu_actions = actions + [external_fileexp_action,
None, switcher_action,
@@ -1443,7 +1443,7 @@ def __get_split_actions(self):
triggered=self.sig_split_vertically,
shortcut=CONF.get_shortcut(context='Editor',
name='split vertically'),
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.horsplit_action = create_action(
self,
@@ -1453,7 +1453,7 @@ def __get_split_actions(self):
triggered=self.sig_split_horizontally,
shortcut=CONF.get_shortcut(context='Editor',
name='split horizontally'),
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
self.close_action = create_action(
self,
@@ -1462,7 +1462,7 @@ def __get_split_actions(self):
triggered=self.close_split,
shortcut=CONF.get_shortcut(context='Editor',
name='close split panel'),
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
# Regular actions
actions = [MENU_SEPARATOR, self.versplit_action,
@@ -1492,8 +1492,8 @@ def reset_orientation(self):
self.versplit_action.setEnabled(True)
def set_orientation(self, orientation):
- self.horsplit_action.setEnabled(orientation == Qt.Horizontal)
- self.versplit_action.setEnabled(orientation == Qt.Vertical)
+ self.horsplit_action.setEnabled(orientation == Qt.Orientation.Horizontal)
+ self.versplit_action.setEnabled(orientation == Qt.Orientation.Vertical)
def update_actions(self):
state = self.get_stack_count() > 0
@@ -3098,9 +3098,9 @@ def __init__(self, parent, plugin, menu_actions, first=False,
self.plugin.clone_editorstack(editorstack=self.editorstack)
self.editorstack.destroyed.connect(self.editorstack_closed)
self.editorstack.sig_split_vertically.connect(
- lambda: self.split(orientation=Qt.Vertical))
+ lambda: self.split(orientation=Qt.Orientation.Vertical))
self.editorstack.sig_split_horizontally.connect(
- lambda: self.split(orientation=Qt.Horizontal))
+ lambda: self.split(orientation=Qt.Orientation.Horizontal))
self.addWidget(self.editorstack)
if not running_under_pytest():
@@ -3159,7 +3159,7 @@ def editorsplitter_closed(self):
self.__give_focus_to_remaining_editor()
- def split(self, orientation=Qt.Vertical):
+ def split(self, orientation=Qt.Orientation.Vertical):
"""Create and attach a new EditorSplitter to the current EditorSplitter.
The new EditorSplitter widget will contain an EditorStack that
@@ -3230,7 +3230,7 @@ def get_layout_settings(self):
clines = [finfo.editor.get_cursor_line_number()
for finfo in editorstack.data]
cfname = editorstack.get_current_filename()
- splitsettings.append((orientation == Qt.Vertical, cfname, clines))
+ splitsettings.append((orientation == Qt.Orientation.Vertical, cfname, clines))
return dict(hexstate=qbytearray_to_str(self.saveState()),
sizes=self.sizes(), splitsettings=splitsettings)
@@ -3263,7 +3263,7 @@ def set_layout_settings(self, settings, dont_goto=None):
editor = None
for i, (is_vertical, cfname, clines) in enumerate(splitsettings):
if i > 0:
- splitter.split(Qt.Vertical if is_vertical else Qt.Horizontal)
+ splitter.split(Qt.Orientation.Vertical if is_vertical else Qt.Orientation.Horizontal)
splitter = splitter.widget(1)
editorstack = splitter.widget(0)
for j, finfo in enumerate(editorstack.data):
diff --git a/spyder/plugins/editor/widgets/gotoline.py b/spyder/plugins/editor/widgets/gotoline.py
index a9a2105a71f..86c9c814ed8 100644
--- a/spyder/plugins/editor/widgets/gotoline.py
+++ b/spyder/plugins/editor/widgets/gotoline.py
@@ -45,15 +45,15 @@ def __init__(self, editor):
last_label_v = QLabel("%d" % editor.get_line_count())
glayout = QGridLayout()
- glayout.addWidget(label, 0, 0, Qt.AlignVCenter | Qt.AlignRight)
- glayout.addWidget(self.lineedit, 0, 1, Qt.AlignVCenter)
- glayout.addWidget(cl_label, 1, 0, Qt.AlignVCenter | Qt.AlignRight)
- glayout.addWidget(cl_label_v, 1, 1, Qt.AlignVCenter)
- glayout.addWidget(last_label, 2, 0, Qt.AlignVCenter | Qt.AlignRight)
- glayout.addWidget(last_label_v, 2, 1, Qt.AlignVCenter)
+ glayout.addWidget(label, 0, 0, Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignRight)
+ glayout.addWidget(self.lineedit, 0, 1, Qt.AlignmentFlag.AlignVCenter)
+ glayout.addWidget(cl_label, 1, 0, Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignRight)
+ glayout.addWidget(cl_label_v, 1, 1, Qt.AlignmentFlag.AlignVCenter)
+ glayout.addWidget(last_label, 2, 0, Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignRight)
+ glayout.addWidget(last_label_v, 2, 1, Qt.AlignmentFlag.AlignVCenter)
bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
- Qt.Vertical, self)
+ Qt.Orientation.Vertical, self)
bbox.accepted.connect(self.accept)
bbox.rejected.connect(self.reject)
btnlayout = QVBoxLayout()
diff --git a/spyder/plugins/editor/widgets/printer.py b/spyder/plugins/editor/widgets/printer.py
index 0ed529a8e2b..757e5d1ff4d 100644
--- a/spyder/plugins/editor/widgets/printer.py
+++ b/spyder/plugins/editor/widgets/printer.py
@@ -36,7 +36,7 @@ def formatPage(self, painter, drawing, area, pagenr):
header = '%s - %s - Page %s' % (self.docName(), self.date, pagenr)
painter.save()
painter.setFont(self.header_font)
- painter.setPen(QColor(Qt.black))
+ painter.setPen(QColor(Qt.GlobalColor.black))
if drawing:
painter.drawText(area.right()-painter.fontMetrics().width(header),
area.top()+painter.fontMetrics().ascent(), header)
diff --git a/spyder/plugins/editor/widgets/recover.py b/spyder/plugins/editor/widgets/recover.py
index 05fdfb42871..e61081b727f 100644
--- a/spyder/plugins/editor/widgets/recover.py
+++ b/spyder/plugins/editor/widgets/recover.py
@@ -137,7 +137,7 @@ def add_label_to_table(self, row, col, txt):
"""Add a label to specified cell in table."""
label = QLabel(txt)
label.setMargin(5)
- label.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
+ label.setAlignment(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter)
self.table.setCellWidget(row, col, label)
def add_table(self):
diff --git a/spyder/plugins/editor/widgets/tests/test_classfunc_selector.py b/spyder/plugins/editor/widgets/tests/test_classfunc_selector.py
index c25da31f197..56bedc1635a 100644
--- a/spyder/plugins/editor/widgets/tests/test_classfunc_selector.py
+++ b/spyder/plugins/editor/widgets/tests/test_classfunc_selector.py
@@ -66,21 +66,21 @@ def test_class_func_selector(completions_codeeditor, qtbot):
# Check line is followed
for _ in range(7):
- qtbot.keyPress(code_editor, Qt.Key_Down)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Down)
assert panel.class_cb.currentText() == 'SomeObject'
assert panel.method_cb.currentText() == 'SomeObject.__init__'
for _ in range(18):
- qtbot.keyPress(code_editor, Qt.Key_Down)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Down)
assert panel.class_cb.currentText() == 'SomeOtherObject'
assert (panel.method_cb.currentText()
== 'SomeOtherObject.hello_3.nested_func')
# Check go to line works for class selector
- qtbot.mouseClick(panel.class_cb, Qt.LeftButton, pos=QPoint(5, 5))
+ qtbot.mouseClick(panel.class_cb, Qt.MouseButton.LeftButton, pos=QPoint(5, 5))
listview = panel.class_cb.findChild(QListView)
- qtbot.keyPress(listview, Qt.Key_Up)
- qtbot.keyPress(listview, Qt.Key_Return)
+ qtbot.keyPress(listview, Qt.Key.Key_Up)
+ qtbot.keyPress(listview, Qt.Key.Key_Return)
qtbot.wait(1000)
cursor = code_editor.textCursor()
assert cursor.blockNumber() == 4
@@ -88,11 +88,11 @@ def test_class_func_selector(completions_codeeditor, qtbot):
# Check go to line works for func selector
panel.method_cb.setFocus()
- qtbot.mouseClick(panel.method_cb, Qt.LeftButton, pos=QPoint(5, 5))
+ qtbot.mouseClick(panel.method_cb, Qt.MouseButton.LeftButton, pos=QPoint(5, 5))
listview = panel.method_cb.findChild(QListView)
- qtbot.keyPress(listview, Qt.Key_Down)
- qtbot.keyPress(listview, Qt.Key_Down)
- qtbot.keyPress(listview, Qt.Key_Return)
+ qtbot.keyPress(listview, Qt.Key.Key_Down)
+ qtbot.keyPress(listview, Qt.Key.Key_Down)
+ qtbot.keyPress(listview, Qt.Key.Key_Return)
qtbot.wait(1000)
cursor = code_editor.textCursor()
assert cursor.blockNumber() == 9
diff --git a/spyder/plugins/editor/widgets/tests/test_codeeditor.py b/spyder/plugins/editor/widgets/tests/test_codeeditor.py
index 6b82a198aa2..a34ba7e7cb7 100644
--- a/spyder/plugins/editor/widgets/tests/test_codeeditor.py
+++ b/spyder/plugins/editor/widgets/tests/test_codeeditor.py
@@ -51,71 +51,71 @@ def test_editor_lower_to_upper(codeeditor):
[
("for i in range(2): ",
"for i in range(2): \n \n \n ",
- [Qt.Key_Enter, Qt.Key_Enter, ' ', Qt.Key_Enter],
+ [Qt.Key.Key_Enter, Qt.Key.Key_Enter, ' ', Qt.Key.Key_Enter],
False),
('for i in range(2): ',
'for i in range(2):\n\n ',
- [Qt.Key_Enter, Qt.Key_Enter],
+ [Qt.Key.Key_Enter, Qt.Key.Key_Enter],
True),
('myvar = 2 ',
'myvar = 2\n',
- [Qt.Key_Enter],
+ [Qt.Key.Key_Enter],
True),
('somecode = 1\nmyvar = 2 \nmyvar = 3',
'somecode = 1\nmyvar = 2 \nmyvar = 3',
- [' ', Qt.Key_Up, Qt.Key_Up],
+ [' ', Qt.Key.Key_Up, Qt.Key.Key_Up],
True),
('somecode = 1\nmyvar = 2 ',
'somecode = 1\nmyvar = 2 ',
- [Qt.Key_Left],
+ [Qt.Key.Key_Left],
True),
('"""This is a string with important spaces\n ',
'"""This is a string with important spaces\n \n',
- [Qt.Key_Enter],
+ [Qt.Key.Key_Enter],
True),
('"""string ',
'"""string \n',
- [Qt.Key_Enter],
+ [Qt.Key.Key_Enter],
True),
('somecode = 1\nmyvar = 2',
'somecode = 1\nmyvar = 2',
- [' ', (Qt.LeftButton, 0)],
+ [' ', (Qt.MouseButton.LeftButton, 0)],
True),
('somecode = 1\nmyvar = 2',
'somecode = 1\nmyvar = 2 ',
- [' ', (Qt.LeftButton, 23)],
+ [' ', (Qt.MouseButton.LeftButton, 23)],
True),
('a=1\na=2 \na=3',
'a=1\na=2 \na=3',
- [(Qt.LeftButton, 6), Qt.Key_Up],
+ [(Qt.MouseButton.LeftButton, 6), Qt.Key.Key_Up],
True),
('def fun():\n """fun',
'def fun():\n """fun\n\n ',
- [Qt.Key_Enter, Qt.Key_Enter],
+ [Qt.Key.Key_Enter, Qt.Key.Key_Enter],
True),
('def fun():\n """fun',
'def fun():\n """fun\n \n ',
- [Qt.Key_Enter, Qt.Key_Enter],
+ [Qt.Key.Key_Enter, Qt.Key.Key_Enter],
False),
("('🚫')",
"('🚫')\n",
- [Qt.Key_Enter],
+ [Qt.Key.Key_Enter],
True),
("def fun():",
"def fun():\n\n ",
- [Qt.Key_Enter, Qt.Key_Enter],
+ [Qt.Key.Key_Enter, Qt.Key.Key_Enter],
True),
("def fun():",
"def fun():\n\n\n",
- [Qt.Key_Enter, Qt.Key_Enter, Qt.Key_Enter],
+ [Qt.Key.Key_Enter, Qt.Key.Key_Enter, Qt.Key.Key_Enter],
True),
("def fun():\n i = 0\n# no indent",
"def fun():\n i = 0\n# no indent\n",
- [Qt.Key_Enter],
+ [Qt.Key.Key_Enter],
True),
("if a:\n def b():\n i = 1",
"if a:\n def b():\n i = 1\n\n ",
- [Qt.Key_Enter, Qt.Key_Enter, Qt.Key_Backspace],
+ [Qt.Key.Key_Enter, Qt.Key.Key_Enter, Qt.Key.Key_Backspace],
True),
])
def test_editor_rstrip_keypress(codeeditor, qtbot, input_text, expected_text,
@@ -139,7 +139,7 @@ def test_editor_rstrip_keypress(codeeditor, qtbot, input_text, expected_text,
widget.mousePressEvent(QMouseEvent(
QEvent.MouseButtonPress, xypos,
button, button,
- Qt.NoModifier))
+ Qt.KeyboardModifier.NoModifier))
else:
qtbot.keyPress(widget, key)
assert widget.toPlainText() == expected_text
@@ -216,7 +216,7 @@ def test_undo_return(codeeditor, qtbot):
cursor = editor.textCursor()
cursor.setPosition(14)
editor.setTextCursor(cursor)
- qtbot.keyPress(editor, Qt.Key_Return)
+ qtbot.keyPress(editor, Qt.Key.Key_Return)
assert editor.toPlainText() == returned_text
qtbot.keyPress(editor, "z", modifier=Qt.ControlModifier)
assert editor.toPlainText() == text
@@ -327,17 +327,17 @@ def test_editor_backspace_char(codeeditor, qtbot):
cursor.setPosition(expected_column)
editor.setTextCursor(cursor)
for line in range(3):
- qtbot.keyPress(editor, Qt.Key_Backspace)
+ qtbot.keyPress(editor, Qt.Key.Key_Backspace)
expected_column -= 1
assert editor.textCursor().columnNumber() == expected_column
- qtbot.keyPress(editor, Qt.Key_Down)
+ qtbot.keyPress(editor, Qt.Key.Key_Down)
assert editor.textCursor().columnNumber() == expected_column
for line in range(3):
- qtbot.keyPress(editor, Qt.Key_Backspace)
+ qtbot.keyPress(editor, Qt.Key.Key_Backspace)
expected_column -= 1
assert editor.textCursor().columnNumber() == expected_column
- qtbot.keyPress(editor, Qt.Key_Up)
+ qtbot.keyPress(editor, Qt.Key.Key_Up)
assert editor.textCursor().columnNumber() == expected_column
@@ -353,19 +353,19 @@ def test_editor_backspace_selection(codeeditor, qtbot):
# This first subtest does not trigger the original bug
for press in range(3):
- qtbot.keyPress(editor, Qt.Key_Left, Qt.ShiftModifier)
+ qtbot.keyPress(editor, Qt.Key.Key_Left, Qt.ShiftModifier)
expected_column -= 3
- qtbot.keyPress(editor, Qt.Key_Backspace)
+ qtbot.keyPress(editor, Qt.Key.Key_Backspace)
assert editor.textCursor().columnNumber() == expected_column
- qtbot.keyPress(editor, Qt.Key_Down)
+ qtbot.keyPress(editor, Qt.Key.Key_Down)
assert editor.textCursor().columnNumber() == expected_column
# However, this second subtest does trigger the original bug
for press in range(3):
- qtbot.keyPress(editor, Qt.Key_Right, Qt.ShiftModifier)
- qtbot.keyPress(editor, Qt.Key_Backspace)
+ qtbot.keyPress(editor, Qt.Key.Key_Right, Qt.ShiftModifier)
+ qtbot.keyPress(editor, Qt.Key.Key_Backspace)
assert editor.textCursor().columnNumber() == expected_column
- qtbot.keyPress(editor, Qt.Key_Down)
+ qtbot.keyPress(editor, Qt.Key.Key_Down)
assert editor.textCursor().columnNumber() == expected_column
@@ -379,15 +379,15 @@ def test_editor_delete_char(codeeditor, qtbot):
cursor.setPosition(expected_column)
editor.setTextCursor(cursor)
for line in range(3):
- qtbot.keyPress(editor, Qt.Key_Delete)
+ qtbot.keyPress(editor, Qt.Key.Key_Delete)
assert editor.textCursor().columnNumber() == expected_column
- qtbot.keyPress(editor, Qt.Key_Down)
+ qtbot.keyPress(editor, Qt.Key.Key_Down)
assert editor.textCursor().columnNumber() == expected_column
for line in range(3):
- qtbot.keyPress(editor, Qt.Key_Delete)
+ qtbot.keyPress(editor, Qt.Key.Key_Delete)
assert editor.textCursor().columnNumber() == expected_column
- qtbot.keyPress(editor, Qt.Key_Up)
+ qtbot.keyPress(editor, Qt.Key.Key_Up)
assert editor.textCursor().columnNumber() == expected_column
@@ -405,19 +405,19 @@ def test_editor_delete_selection(codeeditor, qtbot):
# This first subtest does not trigger the original bug
for press in range(3):
- qtbot.keyPress(editor, Qt.Key_Left, Qt.ShiftModifier)
+ qtbot.keyPress(editor, Qt.Key.Key_Left, Qt.ShiftModifier)
expected_column -= 3
- qtbot.keyPress(editor, Qt.Key_Delete)
+ qtbot.keyPress(editor, Qt.Key.Key_Delete)
assert editor.textCursor().columnNumber() == expected_column
- qtbot.keyPress(editor, Qt.Key_Down)
+ qtbot.keyPress(editor, Qt.Key.Key_Down)
assert editor.textCursor().columnNumber() == expected_column
# However, this second subtest does trigger the original bug
for press in range(3):
- qtbot.keyPress(editor, Qt.Key_Right, Qt.ShiftModifier)
- qtbot.keyPress(editor, Qt.Key_Delete)
+ qtbot.keyPress(editor, Qt.Key.Key_Right, Qt.ShiftModifier)
+ qtbot.keyPress(editor, Qt.Key.Key_Delete)
assert editor.textCursor().columnNumber() == expected_column
- qtbot.keyPress(editor, Qt.Key_Up)
+ qtbot.keyPress(editor, Qt.Key.Key_Up)
assert editor.textCursor().columnNumber() == expected_column
@@ -446,15 +446,15 @@ def test_qtbug35861(qtbot):
assert widget.textCursor().columnNumber() == expected_column
for line in range(4):
- qtbot.keyClick(widget, Qt.Key_Backspace)
+ qtbot.keyClick(widget, Qt.Key.Key_Backspace)
assert widget.textCursor().columnNumber() == (expected_column - 1)
- qtbot.keyClick(widget, Qt.Key_Down)
+ qtbot.keyClick(widget, Qt.Key.Key_Down)
assert widget.textCursor().columnNumber() == expected_column
for line in range(4):
- qtbot.keyClick(widget, Qt.Key_Backspace)
+ qtbot.keyClick(widget, Qt.Key.Key_Backspace)
assert widget.textCursor().columnNumber() == (expected_column - 1)
- qtbot.keyClick(widget, Qt.Key_Up)
+ qtbot.keyClick(widget, Qt.Key.Key_Up)
assert widget.textCursor().columnNumber() == expected_column
@@ -597,7 +597,7 @@ def test_cell_highlight(codeeditor, qtbot):
assert editor.current_cell[0].selectionEnd() == 9
# Delete cell
- qtbot.keyPress(editor, Qt.Key_Backspace)
+ qtbot.keyPress(editor, Qt.Key.Key_Backspace)
assert editor.current_cell[0].selectionStart() == 0
assert editor.current_cell[0].selectionEnd() == 8
@@ -610,7 +610,7 @@ def test_cell_highlight(codeeditor, qtbot):
cursor = editor.textCursor()
cursor.setPosition(5)
editor.setTextCursor(cursor)
- qtbot.keyPress(editor, Qt.Key_Delete)
+ qtbot.keyPress(editor, Qt.Key.Key_Delete)
assert editor.current_cell[0].selectionStart() == 0
assert editor.current_cell[0].selectionEnd() == 8
diff --git a/spyder/plugins/editor/widgets/tests/test_completions_hide.py b/spyder/plugins/editor/widgets/tests/test_completions_hide.py
index 0c1a2cc6c1e..843cd2d0a1e 100644
--- a/spyder/plugins/editor/widgets/tests/test_completions_hide.py
+++ b/spyder/plugins/editor/widgets/tests/test_completions_hide.py
@@ -41,14 +41,14 @@ def test_automatic_completions_hide_complete(completions_codeeditor, qtbot):
qtbot.keyClicks(code_editor, 'thing', delay=delay)
qtbot.wait(500)
assert completion.isHidden()
- qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300) # newline
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter, delay=300) # newline
# Hide even within a function
qtbot.keyClicks(code_editor, 'print(something', delay=delay)
qtbot.wait(500)
assert completion.isHidden()
qtbot.keyClicks(code_editor, ')', delay=delay)
- qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300) # newline
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter, delay=300) # newline
# Hide even inside comprehension
qtbot.keyClicks(code_editor, 'a = {something', delay=delay)
@@ -57,30 +57,30 @@ def test_automatic_completions_hide_complete(completions_codeeditor, qtbot):
# Hide if removing spaces before a word
code_editor.moveCursor(cursor.End)
- qtbot.keyPress(code_editor, Qt.Key_Enter) # newline
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter) # newline
qtbot.keyClicks(code_editor, 'some', delay=delay)
- qtbot.keyPress(code_editor, Qt.Key_Enter) # newline
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter) # newline
qtbot.keyClicks(code_editor, ' None', delay=delay)
if completion.isVisible():
- qtbot.keyPress(completion, Qt.Key_Enter)
+ qtbot.keyPress(completion, Qt.Key.Key_Enter)
code_editor.moveCursor(cursor.StartOfWord)
- qtbot.keyPress(code_editor, Qt.Key_Backspace)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Backspace)
qtbot.wait(2000)
assert completion.isHidden()
- qtbot.keyPress(code_editor, Qt.Key_Backspace)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Backspace)
qtbot.wait(2000)
assert completion.isHidden()
# Hide if removing spaces before a word even not at the start of line.
code_editor.moveCursor(cursor.End)
- qtbot.keyPress(code_editor, Qt.Key_Enter) # newline
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter) # newline
qtbot.keyClicks(code_editor, 'some + some ', delay=delay)
- qtbot.keyPress(code_editor, Qt.Key_Left)
- qtbot.keyPress(code_editor, Qt.Key_Left)
- qtbot.keyPress(code_editor, Qt.Key_Left)
- qtbot.keyPress(code_editor, Qt.Key_Left)
- qtbot.keyPress(code_editor, Qt.Key_Left)
- qtbot.keyPress(code_editor, Qt.Key_Backspace)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Left)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Left)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Left)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Left)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Left)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Backspace)
qtbot.wait(2000)
assert completion.isHidden()
@@ -104,7 +104,7 @@ def test_automatic_completions_widget_visible(completions_codeeditor, qtbot):
code_editor.set_text('import math')
cursor = code_editor.textCursor()
code_editor.moveCursor(cursor.End)
- qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300) # newline
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter, delay=300) # newline
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000):
@@ -112,11 +112,11 @@ def test_automatic_completions_widget_visible(completions_codeeditor, qtbot):
assert completion.isVisible()
- qtbot.keyPress(code_editor, Qt.Key_Backspace, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Backspace, delay=300)
qtbot.wait(500)
assert completion.isVisible()
- qtbot.keyPress(code_editor, Qt.Key_Backspace, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Backspace, delay=300)
qtbot.wait(500)
assert completion.isVisible()
diff --git a/spyder/plugins/editor/widgets/tests/test_decorations.py b/spyder/plugins/editor/widgets/tests/test_decorations.py
index bbe43615aaa..3022702067f 100644
--- a/spyder/plugins/editor/widgets/tests/test_decorations.py
+++ b/spyder/plugins/editor/widgets/tests/test_decorations.py
@@ -169,7 +169,7 @@ def test_update_decorations_when_scrolling(qtbot):
# Simulate continuously pressing the down arrow key.
for __ in range(200):
- qtbot.keyPress(editor, Qt.Key_Down)
+ qtbot.keyPress(editor, Qt.Key.Key_Down)
# Only one call to _update should be done, after releasing the key.
qtbot.wait(editor.UPDATE_DECORATIONS_TIMEOUT + 100)
@@ -177,7 +177,7 @@ def test_update_decorations_when_scrolling(qtbot):
# Simulate continuously pressing the up arrow key.
for __ in range(200):
- qtbot.keyPress(editor, Qt.Key_Up)
+ qtbot.keyPress(editor, Qt.Key.Key_Up)
# Only one call to _update should be done, after releasing the key.
qtbot.wait(editor.UPDATE_DECORATIONS_TIMEOUT + 100)
diff --git a/spyder/plugins/editor/widgets/tests/test_editor.py b/spyder/plugins/editor/widgets/tests/test_editor.py
index 86d0ee80d84..ccb2222724c 100644
--- a/spyder/plugins/editor/widgets/tests/test_editor.py
+++ b/spyder/plugins/editor/widgets/tests/test_editor.py
@@ -367,7 +367,7 @@ def test_replace_current_selected_line(editor_find_replace_bot, qtbot):
finder.show(hide_replace=False)
qtbot.keyClicks(finder.search_text, 'spam')
qtbot.keyClicks(finder.replace_text, 'ham')
- qtbot.keyPress(finder.replace_text, Qt.Key_Return)
+ qtbot.keyPress(finder.replace_text, Qt.Key.Key_Return)
assert editor.toPlainText()[0:-1] == expected_new_text
@@ -383,25 +383,25 @@ def test_replace_enter_press(editor_find_replace_bot, qtbot):
finder.search_text.lineEdit().setFocus()
# search forward
- qtbot.keyClick(finder.search_text.lineEdit(), Qt.Key_Return)
+ qtbot.keyClick(finder.search_text.lineEdit(), Qt.Key.Key_Return)
assert editor.get_cursor_line_column() == (1,4)
- qtbot.keyClick(finder.search_text.lineEdit(), Qt.Key_Return)
+ qtbot.keyClick(finder.search_text.lineEdit(), Qt.Key.Key_Return)
assert editor.get_cursor_line_column() == (2,4)
- qtbot.keyClick(finder.search_text.lineEdit(), Qt.Key_Return)
+ qtbot.keyClick(finder.search_text.lineEdit(), Qt.Key.Key_Return)
assert editor.get_cursor_line_column() == (3,4)
# search backwards
- qtbot.keyClick(finder.search_text.lineEdit(), Qt.Key_Return,
+ qtbot.keyClick(finder.search_text.lineEdit(), Qt.Key.Key_Return,
modifier=Qt.ShiftModifier)
assert editor.get_cursor_line_column() == (2,4)
- qtbot.keyClick(finder.search_text.lineEdit(), Qt.Key_Return,
+ qtbot.keyClick(finder.search_text.lineEdit(), Qt.Key.Key_Return,
modifier=Qt.ShiftModifier)
assert editor.get_cursor_line_column() == (1,4)
- qtbot.keyClick(finder.search_text.lineEdit(), Qt.Key_Return,
+ qtbot.keyClick(finder.search_text.lineEdit(), Qt.Key.Key_Return,
modifier=Qt.ShiftModifier)
assert editor.get_cursor_line_column() == (3,4)
@@ -418,7 +418,7 @@ def test_replace_plain_regex(editor_find_replace_bot, qtbot):
qtbot.keyClicks(finder.search_text, 'spam')
qtbot.keyClicks(finder.replace_text, r'.\[()]*test')
- qtbot.keyPress(finder.replace_text, Qt.Key_Return)
+ qtbot.keyPress(finder.replace_text, Qt.Key.Key_Return)
assert editor.toPlainText()[0:-1] == expected_new_text
@@ -435,24 +435,24 @@ def test_replace_invalid_regex(editor_find_replace_bot, qtbot):
qtbot.keyClicks(finder.replace_text, 'anything')
if not finder.re_button.isChecked():
- qtbot.mouseClick(finder.re_button, Qt.LeftButton)
+ qtbot.mouseClick(finder.re_button, Qt.MouseButton.LeftButton)
- qtbot.mouseClick(finder.replace_button, Qt.LeftButton)
+ qtbot.mouseClick(finder.replace_button, Qt.MouseButton.LeftButton)
assert editor.toPlainText() == old_text
- qtbot.mouseClick(finder.replace_sel_button, Qt.LeftButton)
+ qtbot.mouseClick(finder.replace_sel_button, Qt.MouseButton.LeftButton)
assert editor.toPlainText() == old_text
- qtbot.mouseClick(finder.replace_all_button, Qt.LeftButton)
+ qtbot.mouseClick(finder.replace_all_button, Qt.MouseButton.LeftButton)
assert editor.toPlainText() == old_text
# Test with valid search_text and invalid replace_text
qtbot.keyClicks(finder.search_text, 'anything')
qtbot.keyClicks(finder.replace_text, '\\')
- qtbot.mouseClick(finder.replace_button, Qt.LeftButton)
+ qtbot.mouseClick(finder.replace_button, Qt.MouseButton.LeftButton)
assert editor.toPlainText() == old_text
- qtbot.mouseClick(finder.replace_sel_button, Qt.LeftButton)
+ qtbot.mouseClick(finder.replace_sel_button, Qt.MouseButton.LeftButton)
assert editor.toPlainText() == old_text
- qtbot.mouseClick(finder.replace_all_button, Qt.LeftButton)
+ qtbot.mouseClick(finder.replace_all_button, Qt.MouseButton.LeftButton)
assert editor.toPlainText() == old_text
@@ -472,14 +472,14 @@ def test_replace_honouring_case(editor_find_replace_bot, qtbot):
# Make sure regex button is set
if not finder.re_button.isChecked():
- qtbot.mouseClick(finder.re_button, Qt.LeftButton)
+ qtbot.mouseClick(finder.re_button, Qt.MouseButton.LeftButton)
# Make sure case button is not set
if finder.case_button.isChecked():
- qtbot.mouseClick(finder.case_button, Qt.LeftButton)
+ qtbot.mouseClick(finder.case_button, Qt.MouseButton.LeftButton)
# Replace all
- qtbot.mouseClick(finder.replace_all_button, Qt.LeftButton)
+ qtbot.mouseClick(finder.replace_all_button, Qt.MouseButton.LeftButton)
assert editor.toPlainText() == expected_new_text
@@ -619,7 +619,7 @@ def test_tab_keypress_properly_caught_find_replace(editor_find_replace_bot,
editor.set_text(text)
finder.focusNextChild = MagicMock(name="focusNextChild")
- qtbot.keyPress(finder.search_text, Qt.Key_Tab)
+ qtbot.keyPress(finder.search_text, Qt.Key.Key_Tab)
finder.focusNextChild.assert_called_once_with()
@@ -645,7 +645,7 @@ def test_tab_moves_focus_from_search_to_replace(editor_find_replace_bot,
qtbot.wait(100)
assert finder.search_text.hasFocus()
assert not finder.replace_text.hasFocus()
- qtbot.keyPress(finder.search_text, Qt.Key_Tab)
+ qtbot.keyPress(finder.search_text, Qt.Key.Key_Tab)
qtbot.wait(100)
assert not finder.search_text.hasFocus()
assert finder.replace_text.hasFocus()
@@ -662,7 +662,7 @@ def test_tab_copies_find_to_replace(editor_find_replace_bot, qtbot):
finder.search_text.setFocus()
finder.search_text.set_current_text('This is some test text!')
qtbot.wait(500)
- qtbot.keyClick(finder.search_text, Qt.Key_Tab)
+ qtbot.keyClick(finder.search_text, Qt.Key.Key_Tab)
assert finder.replace_text.currentText() == 'This is some test text!'
diff --git a/spyder/plugins/editor/widgets/tests/test_editor_and_outline.py b/spyder/plugins/editor/widgets/tests/test_editor_and_outline.py
index 48a6280fad7..7973b05c0a4 100644
--- a/spyder/plugins/editor/widgets/tests/test_editor_and_outline.py
+++ b/spyder/plugins/editor/widgets/tests/test_editor_and_outline.py
@@ -340,10 +340,10 @@ def test_editor_outlineexplorer(qtbot, completions_codeeditor_outline):
with qtbot.waitSignal(
code_editor.completions_response_signal, timeout=30000):
- qtbot.keyPress(code_editor, Qt.Key_Return)
- qtbot.keyPress(code_editor, Qt.Key_Return)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Return)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Return)
- qtbot.keyPress(code_editor, Qt.Key_Up)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Up)
code_editor.paste()
qtbot.wait(3000)
@@ -372,10 +372,10 @@ def test_editor_outlineexplorer(qtbot, completions_codeeditor_outline):
with qtbot.waitSignal(
code_editor.completions_response_signal, timeout=30000):
- qtbot.keyPress(code_editor, Qt.Key_Return)
- qtbot.keyPress(code_editor, Qt.Key_Return)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Return)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Return)
- qtbot.keyPress(code_editor, Qt.Key_Up)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Up)
code_editor.paste()
qtbot.wait(3000)
@@ -391,9 +391,9 @@ def test_editor_outlineexplorer(qtbot, completions_codeeditor_outline):
with qtbot.waitSignal(
code_editor.completions_response_signal, timeout=30000):
- qtbot.keyPress(code_editor, Qt.Key_Return)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Return)
qtbot.keyClicks(code_editor, 'self.y = None')
- qtbot.keyPress(code_editor, Qt.Key_Return)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Return)
with qtbot.waitSignal(treewidget.sig_tree_updated, timeout=30000):
code_editor.request_symbols()
@@ -438,7 +438,7 @@ def foo():
# Remove content
code_editor.selectAll()
- qtbot.keyPress(code_editor, Qt.Key_Delete)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Delete)
with qtbot.waitSignal(
code_editor.completions_response_signal, timeout=30000):
diff --git a/spyder/plugins/editor/widgets/tests/test_editorsplitter.py b/spyder/plugins/editor/widgets/tests/test_editorsplitter.py
index 854a9bf92fa..91c4c2d2914 100644
--- a/spyder/plugins/editor/widgets/tests/test_editorsplitter.py
+++ b/spyder/plugins/editor/widgets/tests/test_editorsplitter.py
@@ -124,7 +124,7 @@ def clone(editorstack):
def test_init(editor_splitter_bot):
""""Test __init__."""
es = editor_splitter_bot
- assert es.orientation() == Qt.Horizontal
+ assert es.orientation() == Qt.Orientation.Horizontal
assert es.testAttribute(Qt.WA_DeleteOnClose)
assert not es.childrenCollapsible()
assert not es.toolbar_list
@@ -231,7 +231,7 @@ def test_split(editor_splitter_layout_bot):
# Split main panel with default split.
es.split() # Call directly.
- assert es.orientation() == Qt.Vertical
+ assert es.orientation() == Qt.Orientation.Vertical
assert not es.editorstack.horsplit_action.isEnabled()
assert es.editorstack.versplit_action.isEnabled()
assert es.count() == 2
@@ -244,7 +244,7 @@ def test_split(editor_splitter_layout_bot):
# Create a horizontal split on original widget.
es.editorstack.sig_split_horizontally.emit() # Call from signal.
- assert es.orientation() == Qt.Horizontal
+ assert es.orientation() == Qt.Orientation.Horizontal
assert es.editorstack.horsplit_action.isEnabled()
assert not es.editorstack.versplit_action.isEnabled()
assert es.count() == 3
@@ -256,8 +256,8 @@ def test_split(editor_splitter_layout_bot):
# Test splitting one of the children.
es1 = es.widget(1)
es1.editorstack.sig_split_vertically.emit()
- assert es.orientation() == Qt.Horizontal # Main split didn't change.
- assert es1.orientation() == Qt.Vertical # Child splitter.
+ assert es.orientation() == Qt.Orientation.Horizontal # Main split didn't change.
+ assert es1.orientation() == Qt.Orientation.Vertical # Child splitter.
assert not es1.editorstack.horsplit_action.isEnabled()
assert es1.editorstack.versplit_action.isEnabled()
assert es1.count() == 2
@@ -275,18 +275,18 @@ def test_iter_editorstacks(editor_splitter_bot):
assert es_iter() == [(es.editorstack, es.orientation())]
# Split once.
- es.split(Qt.Vertical)
+ es.split(Qt.Orientation.Vertical)
esw1 = es.widget(1)
assert es_iter() == [(es.editorstack, es.orientation()),
(esw1.editorstack, esw1.orientation())]
# Second splitter on base isn't iterated.
- es.split(Qt.Horizontal)
+ es.split(Qt.Orientation.Horizontal)
assert es_iter() == [(es.editorstack, es.orientation()),
(esw1.editorstack, esw1.orientation())]
# Split a child.
- esw1.split(Qt.Vertical)
+ esw1.split(Qt.Orientation.Vertical)
esw1w1 = es.widget(1).widget(1)
assert es_iter() == [(es.editorstack, es.orientation()),
(esw1.editorstack, esw1.orientation()),
@@ -311,7 +311,7 @@ def test_get_layout_settings(editor_splitter_bot, qtbot, mocker):
mocker.patch.object(EditorSplitter, "iter_editorstacks")
EditorSplitter.iter_editorstacks.return_value = (
- [(stack1, Qt.Vertical), (stack2, Qt.Horizontal)])
+ [(stack1, Qt.Orientation.Vertical), (stack2, Qt.Orientation.Horizontal)])
setting = es.get_layout_settings()
assert setting['hexstate']
diff --git a/spyder/plugins/editor/widgets/tests/test_folding.py b/spyder/plugins/editor/widgets/tests/test_folding.py
index c2b62355e65..51a2449ddb4 100644
--- a/spyder/plugins/editor/widgets/tests/test_folding.py
+++ b/spyder/plugins/editor/widgets/tests/test_folding.py
@@ -102,7 +102,7 @@ def test_unfold_when_searching(search_codeeditor, qtbot):
# unfolded when searching
finder.show()
qtbot.keyClicks(finder.search_text, 'print')
- qtbot.keyPress(finder.search_text, Qt.Key_Return)
+ qtbot.keyPress(finder.search_text, Qt.Key.Key_Return)
assert line_search.isVisible()
editor.toggle_code_folding(False)
diff --git a/spyder/plugins/editor/widgets/tests/test_formatting.py b/spyder/plugins/editor/widgets/tests/test_formatting.py
index 756976446fe..4d65089227c 100644
--- a/spyder/plugins/editor/widgets/tests/test_formatting.py
+++ b/spyder/plugins/editor/widgets/tests/test_formatting.py
@@ -303,7 +303,7 @@ def test_formatting_on_save(completions_editor, formatter, qtbot):
# Make a simple change to the file
code_editor.moveCursor(QTextCursor.EndOfLine)
- qtbot.keyPress(code_editor, Qt.Key_Space)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Space)
qtbot.wait(500)
# Save the file
diff --git a/spyder/plugins/editor/widgets/tests/test_goto.py b/spyder/plugins/editor/widgets/tests/test_goto.py
index aae5e9d0f14..0f651a74d72 100644
--- a/spyder/plugins/editor/widgets/tests/test_goto.py
+++ b/spyder/plugins/editor/widgets/tests/test_goto.py
@@ -105,7 +105,7 @@ def test_goto_uri(qtbot, codeeditor, mocker, params):
qtbot.mouseMove(code_editor, point, delay=500)
with qtbot.waitSignal(code_editor.sig_uri_found, timeout=3000) as blocker:
- qtbot.keyPress(code_editor, Qt.Key_Control, delay=500)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Control, delay=500)
args = blocker.args
print([param, expected_output_1])
print([args])
@@ -150,7 +150,7 @@ def test_goto_uri_project_root_path(qtbot, codeeditor, mocker, tmpdir):
# Check valid with project open
with qtbot.waitSignal(code_editor.sig_file_uri_preprocessed,
timeout=3000) as blocker:
- qtbot.keyPress(code_editor, Qt.Key_Control, delay=500)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Control, delay=500)
args = blocker.args
assert args[0] == expected_output_path
@@ -161,7 +161,7 @@ def test_goto_uri_project_root_path(qtbot, codeeditor, mocker, tmpdir):
code_editor.set_current_project_path()
with qtbot.waitSignal(code_editor.sig_file_uri_preprocessed,
timeout=3000) as blocker:
- qtbot.keyPress(code_editor, Qt.Key_Control, delay=500)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Control, delay=500)
args = blocker.args
assert args[0] == expected_output_path
@@ -178,7 +178,7 @@ def test_goto_uri_message_box(qtbot, codeeditor, mocker):
def interact():
msgbox = code_editor.findChild(QMessageBox)
assert msgbox
- qtbot.keyClick(msgbox, Qt.Key_Return)
+ qtbot.keyClick(msgbox, Qt.Key.Key_Return)
timer = QTimer()
timer.setSingleShot(True)
@@ -203,5 +203,5 @@ def test_pattern_highlight_regression(qtbot, codeeditor):
qtbot.wait(500)
code_editor.moveCursor(QTextCursor.End)
qtbot.wait(500)
- qtbot.keyClick(code_editor, Qt.Key_1)
+ qtbot.keyClick(code_editor, Qt.Key.Key_1)
qtbot.wait(1000)
diff --git a/spyder/plugins/editor/widgets/tests/test_hints_and_calltips.py b/spyder/plugins/editor/widgets/tests/test_hints_and_calltips.py
index beb3a372d6c..f6fed1be593 100644
--- a/spyder/plugins/editor/widgets/tests/test_hints_and_calltips.py
+++ b/spyder/plugins/editor/widgets/tests/test_hints_and_calltips.py
@@ -58,7 +58,7 @@ def test_hide_calltip(completions_codeeditor, qtbot):
assert calltip.isVisible()
qtbot.keyClicks(code_editor, ')', delay=330)
qtbot.waitUntil(lambda: not calltip.isVisible(), timeout=3000)
- qtbot.keyClick(code_editor, Qt.Key_Enter, delay=330)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Enter, delay=330)
assert not calltip.isVisible()
@@ -97,7 +97,7 @@ def test_get_calltips(qtbot, completions_codeeditor, params):
# Bracket autocompletion enabled
with qtbot.waitSignal(code_editor.sig_signature_invoked,
timeout=30000) as blocker:
- qtbot.keyPress(code_editor, Qt.Key_ParenLeft, delay=1000)
+ qtbot.keyPress(code_editor, Qt.Key.Key_ParenLeft, delay=1000)
# This is needed to leave time for the calltip to appear
# and make the tests succeed
@@ -113,7 +113,7 @@ def test_get_calltips(qtbot, completions_codeeditor, params):
bracket_extension.enable = False
with qtbot.waitSignal(code_editor.sig_signature_invoked,
timeout=30000) as blocker:
- qtbot.keyPress(code_editor, Qt.Key_ParenLeft, delay=1000)
+ qtbot.keyPress(code_editor, Qt.Key.Key_ParenLeft, delay=1000)
# This is needed to leave time for the calltip to appear
# and make the tests succeed
@@ -153,7 +153,7 @@ def test_get_hints(qtbot, completions_codeeditor, params, capsys):
# Get cursor coordinates
code_editor.moveCursor(QTextCursor.End)
- qtbot.keyPress(code_editor, Qt.Key_Left)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Left)
# Wait a bit in case the window manager repositions the window.
qtbot.wait(1000)
@@ -166,7 +166,7 @@ def test_get_hints(qtbot, completions_codeeditor, params, capsys):
with qtbot.waitSignal(code_editor.sig_display_object_info,
timeout=30000) as blocker:
qtbot.mouseMove(code_editor, point)
- qtbot.mouseClick(code_editor, Qt.LeftButton, pos=point)
+ qtbot.mouseClick(code_editor, Qt.MouseButton.LeftButton, pos=point)
qtbot.waitUntil(lambda: code_editor.tooltip_widget.isVisible(),
timeout=10000)
@@ -204,7 +204,7 @@ def test_get_hints_not_triggered(qtbot, completions_codeeditor, text):
code_editor.moveCursor(QTextCursor.End)
for _ in range(3):
- qtbot.keyPress(code_editor, Qt.Key_Left)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Left)
# Wait a bit in case the window manager repositions the window.
qtbot.wait(1000)
@@ -217,6 +217,6 @@ def test_get_hints_not_triggered(qtbot, completions_codeeditor, text):
with qtbot.waitSignal(code_editor.completions_response_signal,
timeout=30000):
qtbot.mouseMove(code_editor, point)
- qtbot.mouseClick(code_editor, Qt.LeftButton, pos=point)
+ qtbot.mouseClick(code_editor, Qt.MouseButton.LeftButton, pos=point)
qtbot.wait(1000)
assert not code_editor.tooltip_widget.isVisible()
diff --git a/spyder/plugins/editor/widgets/tests/test_introspection.py b/spyder/plugins/editor/widgets/tests/test_introspection.py
index 221046bf9e2..8a456edcd7d 100644
--- a/spyder/plugins/editor/widgets/tests/test_introspection.py
+++ b/spyder/plugins/editor/widgets/tests/test_introspection.py
@@ -75,28 +75,28 @@ def test_fallback_completions(completions_codeeditor, qtbot):
code_editor.document_did_change()
# Enter for new line
- qtbot.keyPress(code_editor, Qt.Key_Enter, delay=1000)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter, delay=1000)
qtbot.keyClicks(code_editor, 'wh')
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
# Assert all retrieved words start with 'wh'
assert all({x['insertText'].startswith('wh') for x in sig.args[0]})
# Delete 'wh'
for _ in range(2):
- qtbot.keyPress(code_editor, Qt.Key_Backspace)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Backspace)
# Insert another word
qtbot.keyClicks(code_editor, 'another')
- qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter, delay=300)
qtbot.keyClicks(code_editor, 'a')
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
word_set = {x['insertText'] for x in sig.args[0]}
assert 'another' in word_set
@@ -105,26 +105,26 @@ def test_fallback_completions(completions_codeeditor, qtbot):
assert 'assert' in word_set
for _ in range(3):
- qtbot.keyPress(code_editor, Qt.Key_Backspace)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Backspace)
- qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter, delay=300)
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
qtbot.keyClicks(code_editor, 'a')
- qtbot.keyPress(code_editor, Qt.Key_Tab, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab, delay=300)
word_set = {x['insertText'] for x in sig.args[0]}
assert 'another' not in word_set
# Check that fallback doesn't give an error with utf-16 characters.
# This is a regression test for issue spyder-ide/spyder#11862.
- qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter, delay=300)
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
code_editor.append("'😒 foobar'")
- qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter, delay=300)
qtbot.keyClicks(code_editor, 'foob')
- qtbot.keyPress(code_editor, Qt.Key_Tab, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab, delay=300)
word_set = {x['insertText'] for x in sig.args[0]}
assert 'foobar' in word_set
@@ -156,9 +156,9 @@ def test_space_completion(completions_codeeditor, qtbot):
# press tab and get completions
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
- qtbot.keyPress(completion, Qt.Key_Tab)
+ qtbot.keyPress(completion, Qt.Key.Key_Tab)
assert "import" in [x['label'] for x in sig.args[0]]
@@ -199,7 +199,7 @@ def test_hide_widget_completion(completions_codeeditor, qtbot):
# Press tab and get completions
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000):
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
# Check the completion widget is visible
assert completion.isHidden() is False
@@ -236,7 +236,7 @@ def test_automatic_completions(completions_codeeditor, qtbot):
qtbot.keyClicks(code_editor, 'f', delay=delay)
assert "from" in [x['label'] for x in sig.args[0]]
- # qtbot.keyPress(code_editor, Qt.Key_Tab)
+ # qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
qtbot.keyClicks(code_editor, 'rom')
@@ -284,9 +284,9 @@ def test_automatic_completions(completions_codeeditor, qtbot):
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
- qtbot.keyPress(completion, Qt.Key_Tab)
+ qtbot.keyPress(completion, Qt.Key.Key_Tab)
assert code_editor.toPlainText() == 'from numpy import'
@@ -330,7 +330,7 @@ def test_automatic_completions_tab_bug(completions_codeeditor, qtbot):
try:
with qtbot.waitSignal(completion.sig_show_completions,
timeout=5000):
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
assert False
except pytestqt.exceptions.TimeoutError:
pass
@@ -338,7 +338,7 @@ def test_automatic_completions_tab_bug(completions_codeeditor, qtbot):
try:
with qtbot.waitSignal(completion.sig_show_completions,
timeout=5000):
- qtbot.keyPress(code_editor, Qt.Key_Backtab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Backtab)
assert False
except pytestqt.exceptions.TimeoutError:
pass
@@ -355,12 +355,12 @@ def test_automatic_completions_space_bug(completions_codeeditor, qtbot):
code_editor.set_text('x = 1')
code_editor.set_cursor_position('sol')
- qtbot.keyPress(code_editor, Qt.Key_Right)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Right)
try:
with qtbot.waitSignal(completion.sig_show_completions,
timeout=5000):
- qtbot.keyPress(code_editor, Qt.Key_Space)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Space)
assert False
except pytestqt.exceptions.TimeoutError:
pass
@@ -390,8 +390,8 @@ def test_automatic_completions_parens_bug(completions_codeeditor, qtbot):
code_editor.moveCursor(cursor.End)
# Move cursor next to list((my$))
- qtbot.keyPress(code_editor, Qt.Key_Left)
- qtbot.keyPress(code_editor, Qt.Key_Left)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Left)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Left)
qtbot.wait(500)
# Complete my_ -> my_list
@@ -400,7 +400,7 @@ def test_automatic_completions_parens_bug(completions_codeeditor, qtbot):
qtbot.keyClicks(code_editor, '_', delay=delay)
assert "my_list" in [x['label'] for x in sig.args[0]]
- qtbot.keyPress(completion, Qt.Key_Enter)
+ qtbot.keyPress(completion, Qt.Key.Key_Enter)
# Square braces:
# Set cursor to start
@@ -410,7 +410,7 @@ def test_automatic_completions_parens_bug(completions_codeeditor, qtbot):
code_editor.moveCursor(cursor.End)
# Move cursor next to my_dic[on$]
- qtbot.keyPress(code_editor, Qt.Key_Left)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Left)
qtbot.wait(500)
# Complete one -> onesee
@@ -419,7 +419,7 @@ def test_automatic_completions_parens_bug(completions_codeeditor, qtbot):
qtbot.keyClicks(code_editor, 'e', delay=delay)
assert "onesee" in [x['label'] for x in sig.args[0]]
- qtbot.keyPress(completion, Qt.Key_Enter)
+ qtbot.keyPress(completion, Qt.Key.Key_Enter)
# Curly braces:
# Set cursor to start
@@ -429,7 +429,7 @@ def test_automatic_completions_parens_bug(completions_codeeditor, qtbot):
code_editor.moveCursor(cursor.End)
# Move cursor next to {on*}
- qtbot.keyPress(code_editor, Qt.Key_Left)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Left)
qtbot.wait(500)
# Complete one -> onesee
@@ -438,7 +438,7 @@ def test_automatic_completions_parens_bug(completions_codeeditor, qtbot):
qtbot.keyClicks(code_editor, 'e', delay=delay)
assert "onesee" in [x['label'] for x in sig.args[0]]
- qtbot.keyPress(completion, Qt.Key_Enter)
+ qtbot.keyPress(completion, Qt.Key.Key_Enter)
@pytest.mark.slow
@@ -464,7 +464,7 @@ def test_completions(completions_codeeditor, qtbot):
# press tab and get completions
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
assert "__future__" in [x['label'] for x in sig.args[0]]
code_editor.set_text('') # Delete line
code_editor.go_to_line(1)
@@ -478,7 +478,7 @@ def test_completions(completions_codeeditor, qtbot):
# press tab and get completions
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
completions = [x['label'] for x in sig.args[0]]
assert "_foo" in completions
assert "_foom" in completions
@@ -494,15 +494,15 @@ def test_completions(completions_codeeditor, qtbot):
# press tab and get completions
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
assert "math" in [x['label'] for x in sig.args[0]]
# enter should accept first completion
- qtbot.keyPress(completion, Qt.Key_Enter, delay=300)
+ qtbot.keyPress(completion, Qt.Key.Key_Enter, delay=300)
assert code_editor.toPlainText() == 'import math'
# enter for new line
- qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter, delay=300)
# Complete math.h() -> math.hypot()
qtbot.keyClicks(code_editor, 'math.h')
@@ -512,9 +512,9 @@ def test_completions(completions_codeeditor, qtbot):
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
- qtbot.keyPress(completion, Qt.Key_Tab)
+ qtbot.keyPress(completion, Qt.Key.Key_Tab)
if PY2:
assert "hypot(x, y)" in [x['label'] for x in sig.args[0]]
@@ -527,12 +527,12 @@ def test_completions(completions_codeeditor, qtbot):
assert code_editor.toPlainText() == 'import math\nmath.hypot'
- qtbot.keyPress(code_editor, Qt.Key_Escape)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Escape)
try:
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
except pytestqt.exceptions.TimeoutError:
# This should generate a timeout error because the completion
# prefix is the same that the completions returned by Jedi.
@@ -540,11 +540,11 @@ def test_completions(completions_codeeditor, qtbot):
pass
# enter for new line
- qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter, delay=300)
# Complete math.h() -> math.degrees()
qtbot.keyClicks(code_editor, 'math.h(')
- qtbot.keyPress(code_editor, Qt.Key_Left, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Left, delay=300)
qtbot.keyClicks(code_editor, 'y')
with qtbot.waitSignal(
code_editor.completions_response_signal, timeout=30000):
@@ -552,7 +552,7 @@ def test_completions(completions_codeeditor, qtbot):
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
if PY2:
assert "hypot(x, y)" in [x['label'] for x in sig.args[0]]
else:
@@ -561,9 +561,9 @@ def test_completions(completions_codeeditor, qtbot):
'hypot(coordinates)']
# right for () + enter for new line
- qtbot.keyPress(code_editor, Qt.Key_Right, delay=300)
- qtbot.keyPress(code_editor, Qt.Key_Right, delay=300)
- qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Right, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Right, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter, delay=300)
assert code_editor.toPlainText() == 'import math\nmath.hypot\n'\
'math.hypot()\n'
@@ -575,17 +575,17 @@ def test_completions(completions_codeeditor, qtbot):
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
assert "asin(x)" in [x['label'] for x in sig.args[0]]
# Test if the list is updated
assert "acos(x)" == completion.completion_list[0]['label']
qtbot.keyClicks(completion, 's')
data = completion.item(0).data(Qt.UserRole)
assert "asin" == data['insertText']
- qtbot.keyPress(completion, Qt.Key_Enter, delay=300)
+ qtbot.keyPress(completion, Qt.Key.Key_Enter, delay=300)
# enter for new line
- qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter, delay=300)
assert code_editor.toPlainText() == 'import math\nmath.hypot\n'\
'math.hypot()\nmath.asin\n'
@@ -597,16 +597,16 @@ def test_completions(completions_codeeditor, qtbot):
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
assert completion.count() == 6
assert "floor(x)" in [x['label'] for x in sig.args[0]]
qtbot.keyClicks(completion, 'l')
assert completion.count() == 1
- qtbot.keyPress(completion, Qt.Key_Backspace)
+ qtbot.keyPress(completion, Qt.Key.Key_Backspace)
assert completion.count() == 6
# enter for new line
- qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter, delay=300)
assert code_editor.toPlainText() == 'import math\nmath.hypot\n'\
'math.hypot()\nmath.asin\n'\
'math.f\n'
@@ -619,13 +619,13 @@ def test_completions(completions_codeeditor, qtbot):
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
qtbot.keyPress(code_editor, 's')
assert "asin(x)" in [x['label'] for x in sig.args[0]]
- qtbot.keyPress(completion, Qt.Key_Enter, delay=300)
+ qtbot.keyPress(completion, Qt.Key.Key_Enter, delay=300)
# enter for new line
- qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter, delay=300)
assert code_editor.toPlainText() == 'import math\nmath.hypot\n'\
'math.hypot()\nmath.asin\n'\
'math.f\nmath.asin\n'
@@ -633,7 +633,7 @@ def test_completions(completions_codeeditor, qtbot):
# Complete math.a|angle s ... to math.asin|angle
qtbot.keyClicks(code_editor, 'math.aangle')
for i in range(len('angle')):
- qtbot.keyClick(code_editor, Qt.Key_Left)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Left)
with qtbot.waitSignal(
code_editor.completions_response_signal, timeout=30000):
@@ -641,14 +641,14 @@ def test_completions(completions_codeeditor, qtbot):
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
qtbot.keyPress(code_editor, 's')
assert "asin(x)" in [x['label'] for x in sig.args[0]]
- qtbot.keyPress(completion, Qt.Key_Enter, delay=300)
+ qtbot.keyPress(completion, Qt.Key.Key_Enter, delay=300)
for i in range(len('angle')):
- qtbot.keyClick(code_editor, Qt.Key_Right)
+ qtbot.keyClick(code_editor, Qt.Key.Key_Right)
- qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter, delay=300)
assert code_editor.toPlainText() == 'import math\nmath.hypot\n'\
'math.hypot()\nmath.asin\n'\
'math.f\nmath.asin\n'\
@@ -663,9 +663,9 @@ def test_completions(completions_codeeditor, qtbot):
try:
with qtbot.waitSignal(completion.sig_show_completions,
timeout=5000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
- qtbot.keyPress(code_editor, Qt.Key_Backspace)
- qtbot.keyPress(code_editor, Qt.Key_Escape)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Backspace)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Escape)
raise RuntimeError("The signal should not have been received!")
except pytestqt.exceptions.TimeoutError:
pass
@@ -673,8 +673,8 @@ def test_completions(completions_codeeditor, qtbot):
try:
with qtbot.waitSignal(completion.sig_show_completions,
timeout=5000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
- qtbot.keyPress(code_editor, Qt.Key_Return)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Return)
raise RuntimeError("The signal should not have been received!")
except pytestqt.exceptions.TimeoutError:
pass
@@ -716,15 +716,15 @@ def test_func(xlonger, y1, some_z):
code_editor.completions_response_signal, timeout=30000):
code_editor.document_did_change()
- qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300)
- qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter, delay=300)
qtbot.keyClicks(code_editor, 'test_')
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
if len(sig.args[0]) > 1:
- qtbot.keyPress(completion, Qt.Key_Tab)
+ qtbot.keyPress(completion, Qt.Key.Key_Tab)
assert 'test_func(xlonger, y1, some_z)' in {
x['label'] for x in sig.args[0]}
@@ -742,31 +742,31 @@ def test_func(xlonger, y1, some_z):
assert 'xlonger' == arg1
assert snippets.active_snippet == 1
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
cursor = code_editor.textCursor()
arg2 = cursor.selectedText()
assert 'y1' == arg2
assert snippets.active_snippet == 2
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
cursor = code_editor.textCursor()
arg2 = cursor.selectedText()
assert 'some_z' == arg2
assert snippets.active_snippet == 3
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
assert not snippets.is_snippet_active
- qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter, delay=300)
qtbot.keyClicks(code_editor, 'test_')
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
if len(sig.args[0]) > 1:
- qtbot.keyPress(completion, Qt.Key_Tab)
+ qtbot.keyPress(completion, Qt.Key.Key_Tab)
# Replace selection
qtbot.keyClicks(code_editor, 'arg1')
@@ -774,7 +774,7 @@ def test_func(xlonger, y1, some_z):
# Snippets are disabled when there are no more left
for _ in range(0, 3):
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
assert not snippets.is_snippet_active
cursor = code_editor.textCursor()
@@ -783,25 +783,25 @@ def test_func(xlonger, y1, some_z):
text1 = cursor.selectedText()
assert text1 == 'test_func(arg1, y1, some_z)'
- qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter, delay=300)
qtbot.keyClicks(code_editor, 'test_')
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
if len(sig.args[0]) > 1:
- qtbot.keyPress(completion, Qt.Key_Tab)
+ qtbot.keyPress(completion, Qt.Key.Key_Tab)
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
assert snippets.active_snippet == 2
# Extend text from right
- qtbot.keyPress(code_editor, Qt.Key_Right, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Right, delay=300)
qtbot.keyClicks(code_editor, '_var')
- qtbot.keyPress(code_editor, Qt.Key_Up, delay=300)
- qtbot.keyPress(code_editor, Qt.Key_Down, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Up, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Down, delay=300)
cursor = code_editor.textCursor()
cursor.movePosition(QTextCursor.StartOfBlock)
@@ -812,25 +812,25 @@ def test_func(xlonger, y1, some_z):
cursor.movePosition(QTextCursor.EndOfBlock)
code_editor.setTextCursor(cursor)
- qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter, delay=300)
qtbot.keyClicks(code_editor, 'test_')
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
if len(sig.args[0]) > 1:
- qtbot.keyPress(completion, Qt.Key_Tab)
+ qtbot.keyPress(completion, Qt.Key.Key_Tab)
for _ in range(0, 2):
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
assert snippets.active_snippet == 3
# Extend text from left
- qtbot.keyPress(code_editor, Qt.Key_Left, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Left, delay=300)
qtbot.keyClicks(code_editor, 's')
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
assert not snippets.is_snippet_active
@@ -840,24 +840,24 @@ def test_func(xlonger, y1, some_z):
text1 = cursor.selectedText()
assert text1 == 'test_func(xlonger, y1, ssome_z)'
- qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter, delay=300)
qtbot.keyClicks(code_editor, 'test_')
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
if len(sig.args[0]) > 1:
- qtbot.keyPress(completion, Qt.Key_Tab)
+ qtbot.keyPress(completion, Qt.Key.Key_Tab)
assert snippets.active_snippet == 1
# Delete snippet region
- qtbot.keyPress(code_editor, Qt.Key_Left, delay=300)
- qtbot.keyPress(code_editor, Qt.Key_Backspace, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Left, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Backspace, delay=300)
assert len(snippets.snippets_map) == 3
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
cursor = code_editor.textCursor()
arg1 = cursor.selectedText()
assert 'some_z' == arg1
@@ -869,7 +869,7 @@ def test_func(xlonger, y1, some_z):
assert len(snippets.snippets_map) == 4
for _ in range(0, 2):
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
cursor = code_editor.textCursor()
arg1 = cursor.selectedText()
@@ -881,27 +881,27 @@ def test_func(xlonger, y1, some_z):
assert len(snippets.snippets_map) == 3
for _ in range(0, 3):
- qtbot.keyPress(code_editor, Qt.Key_Tab)
- qtbot.keyPress(code_editor, Qt.Key_Right)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Right)
- qtbot.keyPress(code_editor, Qt.Key_Enter)
- qtbot.keyPress(code_editor, Qt.Key_Backspace)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Backspace)
qtbot.keyClicks(code_editor, 'test_')
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
if len(sig.args[0]) > 1:
- qtbot.keyPress(completion, Qt.Key_Tab)
+ qtbot.keyPress(completion, Qt.Key.Key_Tab)
# Delete text
- qtbot.keyPress(code_editor, Qt.Key_Left, delay=300)
- qtbot.keyPress(code_editor, Qt.Key_Right, delay=300)
- qtbot.keyPress(code_editor, Qt.Key_Backspace)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Left, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Right, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Backspace)
for _ in range(0, 3):
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
cursor = code_editor.textCursor()
cursor.movePosition(QTextCursor.StartOfBlock)
@@ -940,12 +940,12 @@ def test_kite_code_snippets(kite_codeeditor, qtbot):
# Set cursor to start
code_editor.go_to_line(1)
qtbot.keyClicks(code_editor, 'import numpy as np')
- qtbot.keyPress(code_editor, Qt.Key_Return)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Return)
qtbot.keyClicks(code_editor, 'np.sin')
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
assert 'sin('+u'\u2026'+')' in {
x['label'] for x in sig.args[0]}
@@ -956,7 +956,7 @@ def test_kite_code_snippets(kite_codeeditor, qtbot):
# Insert completion
qtbot.wait(500)
- qtbot.keyPress(completion, Qt.Key_Tab)
+ qtbot.keyPress(completion, Qt.Key.Key_Tab)
assert snippets.is_snippet_active
# Get code selected text
@@ -966,7 +966,7 @@ def test_kite_code_snippets(kite_codeeditor, qtbot):
assert snippets.active_snippet == 1
code_editor.set_cursor_position('eol')
- qtbot.keyPress(code_editor, Qt.Key_Left)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Left)
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig2:
@@ -977,11 +977,11 @@ def test_kite_code_snippets(kite_codeeditor, qtbot):
expected_insert = '${1:[x]})$0'
insert = sig2.args[0][0]
assert expected_insert == insert['textEdit']['newText']
- qtbot.keyPress(completion, Qt.Key_Tab)
+ qtbot.keyPress(completion, Qt.Key.Key_Tab)
# Snippets are disabled when there are no more left
code_editor.set_cursor_position('eol')
- qtbot.keyPress(code_editor, Qt.Key_Enter)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter)
assert not snippets.is_snippet_active
cursor = code_editor.textCursor()
@@ -1017,25 +1017,25 @@ def test_completion_order(completions_codeeditor, qtbot):
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
- qtbot.keyPress(completion, Qt.Key_Tab)
+ qtbot.keyPress(completion, Qt.Key.Key_Tab)
first_completion = sig.args[0][0]
assert first_completion['insertText'] == 'import'
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
- qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter, delay=300)
qtbot.keyClicks(code_editor, 'Impo')
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
- qtbot.keyPress(completion, Qt.Key_Tab)
+ qtbot.keyPress(completion, Qt.Key.Key_Tab)
first_completion = sig.args[0][0]
assert first_completion['insertText'] == 'ImportError'
@@ -1057,7 +1057,7 @@ def test_text_snippet_completions(completions_codeeditor, qtbot):
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
qtbot.keyClicks(code_editor, 'f')
- qtbot.keyPress(code_editor, Qt.Key_Tab, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab, delay=300)
results = [x for x in sig.args[0] if x['provider'] == 'Snippets']
@@ -1088,10 +1088,10 @@ def spam():
completion_plugin.after_configuration_update([])
qtbot.wait(500)
qtbot.keyClicks(code_editor, 'import foo')
- qtbot.keyPress(code_editor, Qt.Key_Enter)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter)
qtbot.keyClicks(code_editor, 'foo.s')
code_editor.document_did_change()
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
qtbot.wait(500)
assert code_editor.toPlainText() == 'import foo\nfoo.s'
@@ -1109,9 +1109,9 @@ def spam():
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
- qtbot.keyPress(completion, Qt.Key_Tab)
+ qtbot.keyPress(completion, Qt.Key.Key_Tab)
assert "spam()" in [x['label'] for x in sig.args[0]]
assert code_editor.toPlainText() == 'import foo\nfoo.spam'
@@ -1158,7 +1158,7 @@ def test_completions_environment(completions_codeeditor, qtbot, tmpdir):
qtbot.wait(2000)
qtbot.keyClicks(code_editor, 'import flas')
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
qtbot.wait(2000)
assert code_editor.toPlainText() == 'import flas'
@@ -1171,9 +1171,9 @@ def test_completions_environment(completions_codeeditor, qtbot, tmpdir):
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000) as sig:
qtbot.keyClicks(code_editor, 'import flas')
- qtbot.keyPress(code_editor, Qt.Key_Tab)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab)
- qtbot.keyPress(completion, Qt.Key_Tab)
+ qtbot.keyPress(completion, Qt.Key.Key_Tab)
assert "flask" in [x['label'] for x in sig.args[0]]
assert code_editor.toPlainText() == 'import flask'
@@ -1197,7 +1197,7 @@ def test_dot_completions(completions_codeeditor, qtbot):
# Import module and check completions are shown for it after writing a dot
# after it
qtbot.keyClicks(code_editor, "import math")
- qtbot.keyPress(code_editor, Qt.Key_Enter)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Enter)
qtbot.wait(500)
assert not completion.isVisible()
@@ -1246,7 +1246,7 @@ def test_completions_for_files_that_start_with_numbers(
with qtbot.waitSignal(completion.sig_show_completions,
timeout=10000):
- qtbot.keyPress(code_editor, Qt.Key_Tab, delay=300)
+ qtbot.keyPress(code_editor, Qt.Key.Key_Tab, delay=300)
qtbot.wait(500)
assert code_editor.get_text_with_eol() == f"'{file_name}'"
diff --git a/spyder/plugins/editor/widgets/tests/test_panels.py b/spyder/plugins/editor/widgets/tests/test_panels.py
index 42189d3cfcb..e7d39505f98 100644
--- a/spyder/plugins/editor/widgets/tests/test_panels.py
+++ b/spyder/plugins/editor/widgets/tests/test_panels.py
@@ -56,7 +56,7 @@ def _draw_red(self, top, painter):
painter.setPen(QColor('white'))
font_height = self.editor.fontMetrics().height()
painter.drawText(0, top, self.sizeHint().width(),
- font_height, int(Qt.AlignRight | Qt.AlignBottom),
+ font_height, int(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignBottom),
'👀')
def paintEvent(self, event):
diff --git a/spyder/plugins/editor/widgets/tests/test_save.py b/spyder/plugins/editor/widgets/tests/test_save.py
index 1d20f21b310..6c534584420 100644
--- a/spyder/plugins/editor/widgets/tests/test_save.py
+++ b/spyder/plugins/editor/widgets/tests/test_save.py
@@ -509,7 +509,7 @@ def test_save_when_completions_are_visible(completions_editor, qtbot):
# Press keyboard shortcut corresponding to save
qtbot.keyPress(
- completion, Qt.Key_S, modifier=Qt.ControlModifier, delay=300)
+ completion, Qt.Key.Key_S, modifier=Qt.ControlModifier, delay=300)
# Assert file was saved
with open(file_path, 'r') as f:
diff --git a/spyder/plugins/editor/widgets/tests/test_shortcuts.py b/spyder/plugins/editor/widgets/tests/test_shortcuts.py
index cb63eee2d61..502ffc42ce9 100644
--- a/spyder/plugins/editor/widgets/tests/test_shortcuts.py
+++ b/spyder/plugins/editor/widgets/tests/test_shortcuts.py
@@ -88,11 +88,11 @@ def test_start_and_end_of_document_shortcuts(editor_bot):
assert editor.get_cursor_line_column() == (0, 0)
# Go to the end of the document.
- qtbot.keyClick(editor, Qt.Key_End, modifier=Qt.ControlModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_End, modifier=Qt.ControlModifier)
assert editor.get_cursor_line_column() == (4, 0)
# Go to the start of the document.
- qtbot.keyClick(editor, Qt.Key_Home, modifier=Qt.ControlModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_Home, modifier=Qt.ControlModifier)
assert editor.get_cursor_line_column() == (0, 0)
@@ -110,20 +110,20 @@ def test_del_undo_redo_shortcuts(editor_bot):
editor = editorstack.get_current_editor()
# Delete the first character of the first line.
- qtbot.keyClick(editor, Qt.Key_Delete)
+ qtbot.keyClick(editor, Qt.Key.Key_Delete)
assert editor.toPlainText() == 'ine1\nLine2\nLine3\nLine4\n'
# Undo the last action with Ctrl+Z.
- qtbot.keyClick(editor, Qt.Key_Z, modifier=Qt.ControlModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_Z, modifier=Qt.ControlModifier)
assert editor.toPlainText() == 'Line1\nLine2\nLine3\nLine4\n'
# Redo the last action with Ctrl+Shift+Z .
- qtbot.keyClick(editor, Qt.Key_Z,
+ qtbot.keyClick(editor, Qt.Key.Key_Z,
modifier=Qt.ControlModifier | Qt.ShiftModifier)
assert editor.toPlainText() == 'ine1\nLine2\nLine3\nLine4\n'
# Undo the last action again with Ctrl+Z.
- qtbot.keyClick(editor, Qt.Key_Z, modifier=Qt.ControlModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_Z, modifier=Qt.ControlModifier)
assert editor.toPlainText() == 'Line1\nLine2\nLine3\nLine4\n'
@@ -140,23 +140,23 @@ def test_copy_cut_paste_shortcuts(editor_bot):
QApplication.clipboard().clear()
# Select and Copy the first line in the editor.
- qtbot.keyClick(editor, Qt.Key_End, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_End, modifier=Qt.ShiftModifier)
assert editor.get_selected_text() == 'Line1'
- qtbot.keyClick(editor, Qt.Key_C, modifier=Qt.ControlModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_C, modifier=Qt.ControlModifier)
assert QApplication.clipboard().text() == 'Line1'
# Paste the selected text.
- qtbot.keyClick(editor, Qt.Key_Home)
- qtbot.keyClick(editor, Qt.Key_V, modifier=Qt.ControlModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_Home)
+ qtbot.keyClick(editor, Qt.Key.Key_V, modifier=Qt.ControlModifier)
assert editor.toPlainText() == 'Line1Line1\nLine2\nLine3\nLine4\n'
# Select and Cut the first line in the editor.
- qtbot.keyClick(editor, Qt.Key_Home)
- qtbot.keyClick(editor, Qt.Key_End, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_Home)
+ qtbot.keyClick(editor, Qt.Key.Key_End, modifier=Qt.ShiftModifier)
assert editor.get_selected_text() == 'Line1Line1'
- qtbot.keyClick(editor, Qt.Key_X, modifier=Qt.ControlModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_X, modifier=Qt.ControlModifier)
assert QApplication.clipboard().text() == 'Line1Line1'
assert editor.toPlainText() == '\nLine2\nLine3\nLine4\n'
@@ -173,7 +173,7 @@ def test_select_all_shortcut(editor_bot):
editor = editorstack.get_current_editor()
# Select all the text in the editor.
- qtbot.keyClick(editor, Qt.Key_A, modifier=Qt.ControlModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_A, modifier=Qt.ControlModifier)
assert editor.get_selected_text() == 'Line1\nLine2\nLine3\nLine4\n'
@@ -191,7 +191,7 @@ def test_delete_line_shortcut(editor_bot):
# Delete the second line in the editor.
editor.go_to_line(2)
- qtbot.keyClick(editor, Qt.Key_D, modifier=Qt.ControlModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_D, modifier=Qt.ControlModifier)
assert editor.toPlainText() == 'Line1\nLine3\nLine4\n'
@@ -206,12 +206,12 @@ def test_go_to_line_shortcut(editor_bot, mocker):
"""
editorstack, qtbot = editor_bot
editor = editorstack.get_current_editor()
- qtbot.keyClick(editor, Qt.Key_Home, modifier=Qt.ControlModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_Home, modifier=Qt.ControlModifier)
# Go to line 3.
mocker.patch.object(GoToLineDialog, 'exec_', return_value=True)
mocker.patch.object(GoToLineDialog, 'get_line_number', return_value=3)
- qtbot.keyClick(editor, Qt.Key_L, modifier=Qt.ControlModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_L, modifier=Qt.ControlModifier)
assert editor.get_cursor_line_column() == (2, 0)
@@ -228,8 +228,8 @@ def test_transform_to_lowercase_shortcut(editor_bot):
editor = editorstack.get_current_editor()
# Transform all the text to lowercase.
- qtbot.keyClick(editor, Qt.Key_A, modifier=Qt.ControlModifier)
- qtbot.keyClick(editor, Qt.Key_U, modifier=Qt.ControlModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_A, modifier=Qt.ControlModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_U, modifier=Qt.ControlModifier)
assert editor.toPlainText() == 'line1\nline2\nline3\nline4\n'
@@ -246,8 +246,8 @@ def test_transform_to_uppercase_shortcut(editor_bot):
editor = editorstack.get_current_editor()
# Transform all the text to uppercase.
- qtbot.keyClick(editor, Qt.Key_A, modifier=Qt.ControlModifier)
- qtbot.keyClick(editor, Qt.Key_U,
+ qtbot.keyClick(editor, Qt.Key.Key_A, modifier=Qt.ControlModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_U,
modifier=Qt.ControlModifier | Qt.ShiftModifier)
assert editor.toPlainText() == 'LINE1\nLINE2\nLINE3\nLINE4\n'
@@ -266,19 +266,19 @@ def test_next_and_previous_word_shortcuts(editor_bot):
# Go to the next word 3 times.
assert editor.get_cursor_line_column() == (0, 0)
- qtbot.keyClick(editor, Qt.Key_Right, modifier=Qt.ControlModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_Right, modifier=Qt.ControlModifier)
assert editor.get_cursor_line_column() == (0, 5)
- qtbot.keyClick(editor, Qt.Key_Right, modifier=Qt.ControlModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_Right, modifier=Qt.ControlModifier)
assert editor.get_cursor_line_column() == (1, 0)
- qtbot.keyClick(editor, Qt.Key_Right, modifier=Qt.ControlModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_Right, modifier=Qt.ControlModifier)
assert editor.get_cursor_line_column() == (1, 5)
# Go to the previous word 3 times.
- qtbot.keyClick(editor, Qt.Key_Left, modifier=Qt.ControlModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_Left, modifier=Qt.ControlModifier)
assert editor.get_cursor_line_column() == (1, 0)
- qtbot.keyClick(editor, Qt.Key_Left, modifier=Qt.ControlModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_Left, modifier=Qt.ControlModifier)
assert editor.get_cursor_line_column() == (0, 5)
- qtbot.keyClick(editor, Qt.Key_Left, modifier=Qt.ControlModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_Left, modifier=Qt.ControlModifier)
assert editor.get_cursor_line_column() == (0, 0)
@@ -296,24 +296,24 @@ def test_builtin_shift_del_and_ins(editor_bot):
QApplication.clipboard().clear()
# Select the first line of the editor.
- qtbot.keyClick(editor, Qt.Key_End, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_End, modifier=Qt.ShiftModifier)
assert editor.get_selected_text() == 'Line1'
# Copy the selection with Ctrl+Ins.
- qtbot.keyClick(editor, Qt.Key_Insert, modifier=Qt.ControlModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_Insert, modifier=Qt.ControlModifier)
assert QApplication.clipboard().text() == 'Line1'
# Paste the copied text at the end of the line with Shift+Ins.
- qtbot.keyClick(editor, Qt.Key_End)
- qtbot.keyClick(editor, Qt.Key_Insert, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_End)
+ qtbot.keyClick(editor, Qt.Key.Key_Insert, modifier=Qt.ShiftModifier)
assert editor.toPlainText() == 'Line1Line1\nLine2\nLine3\nLine4\n'
# Select the second line in the editor again.
- qtbot.keyClick(editor, Qt.Key_Home, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_Home, modifier=Qt.ShiftModifier)
assert editor.get_selected_text() == 'Line1Line1'
# Cut the selection with Shift+Del.
- qtbot.keyClick(editor, Qt.Key_Delete, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_Delete, modifier=Qt.ShiftModifier)
assert QApplication.clipboard().text() == 'Line1Line1'
assert editor.toPlainText() == '\nLine2\nLine3\nLine4\n'
@@ -330,24 +330,24 @@ def test_builtin_undo_redo(editor_bot):
# Write something on a new line.
qtbot.keyClicks(editor, 'Something')
- qtbot.keyClick(editor, Qt.Key_Return)
+ qtbot.keyClick(editor, Qt.Key.Key_Return)
assert editor.toPlainText() == 'Something\nLine1\nLine2\nLine3\nLine4\n'
# Undo the last action with Alt+Backspace.
- qtbot.keyClick(editor, Qt.Key_Backspace, modifier=Qt.AltModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_Backspace, modifier=Qt.AltModifier)
assert editor.toPlainText() == 'SomethingLine1\nLine2\nLine3\nLine4\n'
# Undo the second to last action with Alt+Backspace.
- qtbot.keyClick(editor, Qt.Key_Backspace, modifier=Qt.AltModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_Backspace, modifier=Qt.AltModifier)
assert editor.toPlainText() == 'Line1\nLine2\nLine3\nLine4\n'
# Redo the second to last action with Alt+Shift+Backspace.
- qtbot.keyClick(editor, Qt.Key_Backspace,
+ qtbot.keyClick(editor, Qt.Key.Key_Backspace,
modifier=Qt.AltModifier | Qt.ShiftModifier)
assert editor.toPlainText() == 'SomethingLine1\nLine2\nLine3\nLine4\n'
# Redo the last action with Ctrl+Y.
- qtbot.keyClick(editor, Qt.Key_Y, modifier=Qt.ControlModifier)
+ qtbot.keyClick(editor, Qt.Key.Key_Y, modifier=Qt.ControlModifier)
assert editor.toPlainText() == 'Something\nLine1\nLine2\nLine3\nLine4\n'
diff --git a/spyder/plugins/editor/widgets/tests/test_warnings.py b/spyder/plugins/editor/widgets/tests/test_warnings.py
index 2aa62888710..bd1af0d98d4 100644
--- a/spyder/plugins/editor/widgets/tests/test_warnings.py
+++ b/spyder/plugins/editor/widgets/tests/test_warnings.py
@@ -287,7 +287,7 @@ def test_update_warnings_after_closequotes(qtbot, completions_codeeditor_linting
with qtbot.waitSignal(editor.completions_response_signal, timeout=30000):
# Add a single quote to fix the error
editor.move_cursor(-2)
- qtbot.keyPress(editor, Qt.Key_Apostrophe)
+ qtbot.keyPress(editor, Qt.Key.Key_Apostrophe)
assert editor.toPlainText() == "print('test')\n"
# Assert that the error is gone.
@@ -333,7 +333,7 @@ def test_update_warnings_after_closebrackets(qtbot, completions_codeeditor_linti
with qtbot.waitSignal(editor.completions_response_signal, timeout=30000):
# Add a bracket to fix the error
editor.move_cursor(-1)
- qtbot.keyPress(editor, Qt.Key_ParenRight)
+ qtbot.keyPress(editor, Qt.Key.Key_ParenRight)
assert editor.toPlainText() == "print('test')\n"
# Assert that the error is gone.
diff --git a/spyder/plugins/explorer/widgets/explorer.py b/spyder/plugins/explorer/widgets/explorer.py
index 1757ba88588..12b3916af4a 100644
--- a/spyder/plugins/explorer/widgets/explorer.py
+++ b/spyder/plugins/explorer/widgets/explorer.py
@@ -776,13 +776,13 @@ def contextMenuEvent(self, event):
def keyPressEvent(self, event):
"""Reimplement Qt method"""
- if event.key() in (Qt.Key_Enter, Qt.Key_Return):
+ if event.key() in (Qt.Key.Key_Enter, Qt.Key.Key_Return):
self.clicked()
- elif event.key() == Qt.Key_F2:
+ elif event.key() == Qt.Key.Key_F2:
self.rename()
- elif event.key() == Qt.Key_Delete:
+ elif event.key() == Qt.Key.Key_Delete:
self.delete()
- elif event.key() == Qt.Key_Backspace:
+ elif event.key() == Qt.Key.Key_Backspace:
self.go_to_parent_directory()
else:
QTreeView.keyPressEvent(self, event)
@@ -831,10 +831,10 @@ def mouseMoveEvent(self, event):
if event.pos().x() > item_identation:
# When hovering over directories or files
- self.setCursor(Qt.PointingHandCursor)
+ self.setCursor(Qt.CursorShape.PointingHandCursor)
else:
# On every other element
- self.setCursor(Qt.ArrowCursor)
+ self.setCursor(Qt.CursorShape.ArrowCursor)
self.setToolTip(self.get_filename(index))
diff --git a/spyder/plugins/explorer/widgets/fileassociations.py b/spyder/plugins/explorer/widgets/fileassociations.py
index 2ea7eef8670..1f7eb8c9fe0 100644
--- a/spyder/plugins/explorer/widgets/fileassociations.py
+++ b/spyder/plugins/explorer/widgets/fileassociations.py
@@ -146,7 +146,7 @@ def __init__(self, parent=None):
def setup(self, applications=None):
"""Load installed applications."""
- QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
+ QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
self.list.clear()
if applications is None:
apps = get_installed_applications()
diff --git a/spyder/plugins/explorer/widgets/main_widget.py b/spyder/plugins/explorer/widgets/main_widget.py
index 2985e729880..d7285eb4522 100644
--- a/spyder/plugins/explorer/widgets/main_widget.py
+++ b/spyder/plugins/explorer/widgets/main_widget.py
@@ -325,15 +325,15 @@ def __init__(self, directory=None, file_associations={}):
self.label_dir = QLabel("Open dir:")
self.label_file = QLabel("Open file:")
self.label1 = QLabel()
- self.label_dir.setAlignment(Qt.AlignRight)
+ self.label_dir.setAlignment(Qt.AlignmentFlag.AlignRight)
self.label2 = QLabel()
self.label_option = QLabel("Option changed:")
self.label3 = QLabel()
# Setup
self.explorer.set_current_folder(self.directory)
- self.label_file.setAlignment(Qt.AlignRight)
- self.label_option.setAlignment(Qt.AlignRight)
+ self.label_file.setAlignment(Qt.AlignmentFlag.AlignRight)
+ self.label_option.setAlignment(Qt.AlignmentFlag.AlignRight)
# Layout
hlayout1 = QHBoxLayout()
diff --git a/spyder/plugins/explorer/widgets/tests/test_explorer.py b/spyder/plugins/explorer/widgets/tests/test_explorer.py
index 52d01cb9707..10d162deb42 100644
--- a/spyder/plugins/explorer/widgets/tests/test_explorer.py
+++ b/spyder/plugins/explorer/widgets/tests/test_explorer.py
@@ -176,7 +176,7 @@ def test_single_click_to_open(qtbot, file_explorer):
treewidget = file_explorer.explorer.treewidget
model = treewidget.model()
cwd = os.getcwd()
- qtbot.keyClick(treewidget, Qt.Key_Up) # To focus and select the 1st item
+ qtbot.keyClick(treewidget, Qt.Key.Key_Up) # To focus and select the 1st item
initial_index = treewidget.currentIndex() # To keep a reference
def run_test_helper(single_click, initial_index):
@@ -186,7 +186,7 @@ def run_test_helper(single_click, initial_index):
file_explorer.label1.setText('')
for __ in range(4): # 4 items inside `/spyder/plugins/explorer/`
- qtbot.keyClick(treewidget, Qt.Key_Down)
+ qtbot.keyClick(treewidget, Qt.Key.Key_Down)
index = treewidget.currentIndex()
path = model.data(index)
if path:
@@ -196,7 +196,7 @@ def run_test_helper(single_click, initial_index):
rect = treewidget.visualRect(index)
pos = rect.center()
qtbot.mouseClick(
- treewidget.viewport(), Qt.LeftButton, pos=pos)
+ treewidget.viewport(), Qt.MouseButton.LeftButton, pos=pos)
if single_click:
assert full_path == file_explorer.label1.text()
@@ -284,16 +284,16 @@ def test_clicked(qtbot, file_explorer_associations, tmp_path):
qtbot.wait(500)
# Select first item
- qtbot.keyClick(widget, Qt.Key_Up)
+ qtbot.keyClick(widget, Qt.Key.Key_Up)
# Test click
def interact():
msgbox = widget.findChild(QMessageBox)
assert msgbox
- qtbot.keyClick(msgbox, Qt.Key_Return)
+ qtbot.keyClick(msgbox, Qt.Key.Key_Return)
_ = create_timer(interact)
- qtbot.keyClick(widget, Qt.Key_Return)
+ qtbot.keyClick(widget, Qt.Key.Key_Return)
# Test no message box
def interact_2():
@@ -302,7 +302,7 @@ def interact_2():
widget.set_file_associations({})
_ = create_timer(interact_2)
- qtbot.keyClick(widget, Qt.Key_Return)
+ qtbot.keyClick(widget, Qt.Key.Key_Return)
@pytest.mark.order(1)
@@ -317,7 +317,7 @@ def test_check_launch_error_codes(qtbot, file_explorer_associations):
def interact():
msgbox = widget.findChild(QMessageBox)
assert msgbox
- qtbot.keyClick(msgbox, Qt.Key_Return)
+ qtbot.keyClick(msgbox, Qt.Key.Key_Return)
return_codes = {'some-command': 1}
_ = create_timer(interact)
@@ -328,7 +328,7 @@ def interact():
def interact_2():
msgbox = widget.findChild(QMessageBox)
assert msgbox
- qtbot.keyClick(msgbox, Qt.Key_Return)
+ qtbot.keyClick(msgbox, Qt.Key.Key_Return)
return_codes = {'some-command': 1, 'some-other-command': 1}
_ = create_timer(interact_2)
@@ -345,12 +345,12 @@ def test_open_association(qtbot, file_explorer_associations, tmp_path):
fpath.write_text(u'hello!')
# Select first item
- qtbot.keyClick(widget, Qt.Key_Down)
+ qtbot.keyClick(widget, Qt.Key.Key_Down)
def interact():
msgbox = widget.findChild(QMessageBox)
assert msgbox
- qtbot.keyClick(msgbox, Qt.Key_Return)
+ qtbot.keyClick(msgbox, Qt.Key.Key_Return)
_ = create_timer(interact)
widget.open_association('some-app')
diff --git a/spyder/plugins/explorer/widgets/tests/test_fileassociations.py b/spyder/plugins/explorer/widgets/tests/test_fileassociations.py
index 56a32389d80..aa5561acd54 100644
--- a/spyder/plugins/explorer/widgets/tests/test_fileassociations.py
+++ b/spyder/plugins/explorer/widgets/tests/test_fileassociations.py
@@ -159,20 +159,20 @@ def interact_with_dialog_1():
qtbot.keyClicks(widget._dlg_input.lineedit, extension)
assert widget._dlg_input.lineedit.text() == extension
assert not widget._dlg_input.button_ok.isEnabled()
- qtbot.keyClick(widget._dlg_input.button_cancel, Qt.Key_Return)
+ qtbot.keyClick(widget._dlg_input.button_cancel, Qt.Key.Key_Return)
_ = create_timer(interact_with_dialog_1)
- qtbot.mouseClick(widget.button_add, Qt.LeftButton)
+ qtbot.mouseClick(widget.button_add, Qt.MouseButton.LeftButton)
# Test add valid association
extension = '*.zpam,MANIFEST.in'
def interact_with_dialog_2():
qtbot.keyClicks(widget._dlg_input.lineedit, extension)
- qtbot.keyClick(widget._dlg_input.button_ok, Qt.Key_Return)
+ qtbot.keyClick(widget._dlg_input.button_ok, Qt.Key.Key_Return)
_ = create_timer(interact_with_dialog_2)
- qtbot.mouseClick(widget.button_add, Qt.LeftButton)
+ qtbot.mouseClick(widget.button_add, Qt.MouseButton.LeftButton)
assert widget.list_extensions.count() == 3
assert widget.list_extensions.item(2).text() == extension
@@ -196,20 +196,20 @@ def interact_with_dialog_2():
def interact_with_dialog_3():
widget._dlg_input.lineedit.clear()
qtbot.keyClicks(widget._dlg_input.lineedit, extension)
- qtbot.keyClick(widget._dlg_input.button_ok, Qt.Key_Return)
+ qtbot.keyClick(widget._dlg_input.button_ok, Qt.Key.Key_Return)
_ = create_timer(interact_with_dialog_3)
- qtbot.mouseClick(widget.button_edit, Qt.LeftButton)
+ qtbot.mouseClick(widget.button_edit, Qt.MouseButton.LeftButton)
assert widget.list_extensions.count() == 4
assert widget.list_extensions.item(2).text() == extension
# Test remove associations
- qtbot.mouseClick(widget.button_remove, Qt.LeftButton)
+ qtbot.mouseClick(widget.button_remove, Qt.MouseButton.LeftButton)
assert widget.list_extensions.count() == 3
# Test set default
widget.list_applications.setCurrentRow(1)
- qtbot.mouseClick(widget.button_default, Qt.LeftButton)
+ qtbot.mouseClick(widget.button_default, Qt.MouseButton.LeftButton)
assert 'App name 2' in widget.list_applications.item(0).text()
# Test add application
@@ -218,13 +218,13 @@ def interact_with_dialog_4():
count = widget._dlg_applications.list.count()
if count > 0:
widget._dlg_applications.list.setCurrentRow(count - 1)
- qtbot.keyClick(widget._dlg_applications.button_ok, Qt.Key_Return)
+ qtbot.keyClick(widget._dlg_applications.button_ok, Qt.Key.Key_Return)
else:
qtbot.keyClick(widget._dlg_applications.button_cancel,
- Qt.Key_Return)
+ Qt.Key.Key_Return)
_ = create_timer(interact_with_dialog_4)
- qtbot.mouseClick(widget.button_add_application, Qt.LeftButton)
+ qtbot.mouseClick(widget.button_add_application, Qt.MouseButton.LeftButton)
count = widget.list_applications.count()
assert count in [2, 3]
@@ -236,7 +236,7 @@ def interact_with_dialog_4():
# Test remove application
widget.list_applications.setCurrentRow(0)
- qtbot.mouseClick(widget.button_remove_application, Qt.LeftButton)
+ qtbot.mouseClick(widget.button_remove_application, Qt.MouseButton.LeftButton)
count = widget.list_applications.count()
assert count in [1, 2]
assert 'App name 1' in widget.list_applications.item(0).text()
diff --git a/spyder/plugins/findinfiles/plugin.py b/spyder/plugins/findinfiles/plugin.py
index a362a4d223e..6bde6455b70 100644
--- a/spyder/plugins/findinfiles/plugin.py
+++ b/spyder/plugins/findinfiles/plugin.py
@@ -64,7 +64,7 @@ def on_initialize(self):
tip=_("Search text in multiple files"),
triggered=self.find,
register_shortcut=True,
- context=Qt.WindowShortcut
+ context=Qt.ShortcutContext.WindowShortcut
)
self.refresh_search_directory()
diff --git a/spyder/plugins/findinfiles/widgets/combobox.py b/spyder/plugins/findinfiles/widgets/combobox.py
index 2a74de27cb3..5e10e016d34 100644
--- a/spyder/plugins/findinfiles/widgets/combobox.py
+++ b/spyder/plugins/findinfiles/widgets/combobox.py
@@ -201,7 +201,7 @@ def set_project_path(self, path):
def eventFilter(self, widget, event):
"""Used to handle key events on the QListView of the combobox."""
- if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Delete:
+ if event.type() == QEvent.KeyPress and event.key() == Qt.Key.Key_Delete:
index = self.view().currentIndex().row()
if index >= EXTERNAL_PATHS:
# Remove item and update the view.
diff --git a/spyder/plugins/findinfiles/widgets/tests/test_widgets.py b/spyder/plugins/findinfiles/widgets/tests/test_widgets.py
index a8d552c608e..3cf0fcef0a2 100644
--- a/spyder/plugins/findinfiles/widgets/tests/test_widgets.py
+++ b/spyder/plugins/findinfiles/widgets/tests/test_widgets.py
@@ -467,7 +467,7 @@ def test_delete_path(searchin_combobox, qtbot, mocker):
for i in range(EXTERNAL_PATHS):
searchin_combobox.view().setCurrentIndex(
searchin_combobox.model().index(i, 0))
- qtbot.keyPress(searchin_combobox.view(), Qt.Key_Delete)
+ qtbot.keyPress(searchin_combobox.view(), Qt.Key.Key_Delete)
assert searchin_combobox.count() == len(expected_results)+EXTERNAL_PATHS
assert searchin_combobox.get_external_paths() == expected_results
@@ -476,7 +476,7 @@ def test_delete_path(searchin_combobox, qtbot, mocker):
# Delete the first external path in the list.
searchin_combobox.view().setCurrentIndex(
searchin_combobox.model().index(EXTERNAL_PATHS, 0))
- qtbot.keyPress(searchin_combobox.view(), Qt.Key_Delete)
+ qtbot.keyPress(searchin_combobox.view(), Qt.Key.Key_Delete)
expected_results.pop(0)
assert searchin_combobox.count() == len(expected_results)+EXTERNAL_PATHS
@@ -487,7 +487,7 @@ def test_delete_path(searchin_combobox, qtbot, mocker):
# Delete the second external path in the remaining list.
searchin_combobox.view().setCurrentIndex(
searchin_combobox.model().index(EXTERNAL_PATHS+1, 0))
- qtbot.keyPress(searchin_combobox.view(), Qt.Key_Delete)
+ qtbot.keyPress(searchin_combobox.view(), Qt.Key.Key_Delete)
expected_results.pop(1)
assert searchin_combobox.count() == len(expected_results)+EXTERNAL_PATHS
@@ -498,7 +498,7 @@ def test_delete_path(searchin_combobox, qtbot, mocker):
# Delete the last external path in the list.
searchin_combobox.view().setCurrentIndex(
searchin_combobox.model().index(searchin_combobox.count()-1, 0))
- qtbot.keyPress(searchin_combobox.view(), Qt.Key_Delete)
+ qtbot.keyPress(searchin_combobox.view(), Qt.Key.Key_Delete)
expected_results.pop()
assert searchin_combobox.count() == len(expected_results)+EXTERNAL_PATHS
@@ -510,7 +510,7 @@ def test_delete_path(searchin_combobox, qtbot, mocker):
# Delete the last remaining external path in the list.
searchin_combobox.view().setCurrentIndex(
searchin_combobox.model().index(EXTERNAL_PATHS, 0))
- qtbot.keyPress(searchin_combobox.view(), Qt.Key_Delete)
+ qtbot.keyPress(searchin_combobox.view(), Qt.Key.Key_Delete)
assert searchin_combobox.count() == EXTERNAL_PATHS
assert searchin_combobox.get_external_paths() == []
diff --git a/spyder/plugins/ipythonconsole/confpage.py b/spyder/plugins/ipythonconsole/confpage.py
index 16ade0d481b..02728828052 100644
--- a/spyder/plugins/ipythonconsole/confpage.py
+++ b/spyder/plugins/ipythonconsole/confpage.py
@@ -202,7 +202,7 @@ def setup_page(self):
"import os; import sys"))
run_lines_label.setWordWrap(True)
run_lines_edit = self.create_lineedit(_("Lines:"), 'startup/run_lines',
- '', alignment=Qt.Horizontal)
+ '', alignment=Qt.Orientation.Horizontal)
run_lines_layout = QVBoxLayout()
run_lines_layout.addWidget(run_lines_label)
@@ -238,7 +238,7 @@ def setup_page(self):
"import matplotlib.pyplot as plt"))
pdb_run_lines_label.setWordWrap(True)
pdb_run_lines_edit = self.create_lineedit(
- _("Lines:"), 'startup/pdb_run_lines', '', alignment=Qt.Horizontal)
+ _("Lines:"), 'startup/pdb_run_lines', '', alignment=Qt.Orientation.Horizontal)
pdb_run_lines_layout = QVBoxLayout()
pdb_run_lines_layout.addWidget(pdb_run_lines_label)
@@ -388,14 +388,14 @@ def setup_page(self):
_('Default is
'
'In [<span class="in-prompt-number">'
'%i</span>]:'),
- alignment=Qt.Horizontal)
+ alignment=Qt.Orientation.Horizontal)
out_prompt_edit = self.create_lineedit(
_("Output prompt:"),
'out_prompt', '',
_('Default is
'
'Out[<span class="out-prompt-number">'
'%i</span>]:'),
- alignment=Qt.Horizontal)
+ alignment=Qt.Orientation.Horizontal)
prompts_layout = QVBoxLayout()
prompts_layout.addWidget(prompts_label)
diff --git a/spyder/plugins/ipythonconsole/tests/test_ipythonconsole.py b/spyder/plugins/ipythonconsole/tests/test_ipythonconsole.py
index 2ec718cc012..135dd8edc4b 100644
--- a/spyder/plugins/ipythonconsole/tests/test_ipythonconsole.py
+++ b/spyder/plugins/ipythonconsole/tests/test_ipythonconsole.py
@@ -534,16 +534,16 @@ def test_save_history_dbg(ipyconsole, qtbot):
# Enter an expression
with qtbot.waitSignal(shell.executed):
qtbot.keyClicks(control, 'aa = 10')
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
# Add a pdb command to make sure it is not saved
with qtbot.waitSignal(shell.executed):
qtbot.keyClicks(control, '!u')
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
# Add an empty line to make sure it is not saved
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
# Clear console (for some reason using shell.clear_console
# doesn't work here)
@@ -555,7 +555,7 @@ def test_save_history_dbg(ipyconsole, qtbot):
# Press Up arrow button and assert we get the last
# introduced command
- qtbot.keyClick(control, Qt.Key_Up)
+ qtbot.keyClick(control, Qt.Key.Key_Up)
assert 'aa = 10' in control.toPlainText()
# Open new widget
@@ -575,21 +575,21 @@ def test_save_history_dbg(ipyconsole, qtbot):
# Press Up arrow button and assert we get the last
# introduced command
- qtbot.keyClick(control, Qt.Key_Up)
+ qtbot.keyClick(control, Qt.Key.Key_Up)
assert 'aa = 10' in control.toPlainText()
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
# Add a multiline statment and ckeck we can browse it correctly
shell._pdb_history.append('if True:\n print(1)')
shell._pdb_history.append('print(2)')
shell._pdb_history.append('if True:\n print(10)')
shell._pdb_history_index = len(shell._pdb_history)
# The continuation prompt is here
- qtbot.keyClick(control, Qt.Key_Up)
+ qtbot.keyClick(control, Qt.Key.Key_Up)
assert '...: print(10)' in control.toPlainText()
shell._control.set_cursor_position(shell._control.get_position('eof') - 25)
- qtbot.keyClick(control, Qt.Key_Up)
+ qtbot.keyClick(control, Qt.Key.Key_Up)
assert '...: print(1)' in control.toPlainText()
@@ -739,7 +739,7 @@ def test_execute_events_dbg(ipyconsole, qtbot):
# Test reset magic
qtbot.keyClicks(control, 'plt.plot(range(10))')
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
# Assert that there's a plot in the console
assert shell._control.toHtml().count('img src') == 1
@@ -751,7 +751,7 @@ def test_execute_events_dbg(ipyconsole, qtbot):
# Test reset magic
qtbot.keyClicks(control, 'plt.plot(range(10))')
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
# Assert that there's no new plots in the console
assert shell._control.toHtml().count('img src') == 1
@@ -759,7 +759,7 @@ def test_execute_events_dbg(ipyconsole, qtbot):
# Test if the plot is shown with plt.show()
qtbot.keyClicks(control, 'plt.show()')
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
# Assert that there's a new plots in the console
assert shell._control.toHtml().count('img src') == 2
@@ -853,7 +853,7 @@ def test_clear_and_reset_magics_dbg(ipyconsole, qtbot):
# Test reset magic
qtbot.keyClicks(control, 'bb = 10')
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
assert shell.get_value('bb') == 10
shell.reset_namespace()
@@ -861,7 +861,7 @@ def test_clear_and_reset_magics_dbg(ipyconsole, qtbot):
qtbot.keyClicks(control, 'bb')
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
assert "*** NameError: name 'bb' is not defined" in control.toPlainText()
@@ -1172,7 +1172,7 @@ def check_value(name, value):
qtbot.wait(500)
qtbot.keyClicks(control, 'cb')
- qtbot.keyClick(control, Qt.Key_Tab)
+ qtbot.keyClick(control, Qt.Key.Key_Tab)
# Jedi completion takes time to start up the first time
qtbot.waitUntil(lambda: control.toPlainText().split()[-1] == 'cbs',
timeout=6000)
@@ -1182,11 +1182,11 @@ def check_value(name, value):
shell.execute('cbba = 1')
qtbot.waitUntil(lambda: check_value('cbba', 1))
qtbot.keyClicks(control, 'cb')
- qtbot.keyClick(control, Qt.Key_Tab)
+ qtbot.keyClick(control, Qt.Key.Key_Tab)
qtbot.waitUntil(shell._completion_widget.isVisible)
# cbs is another solution, so not completed yet
assert control.toPlainText().split()[-1] == 'cb'
- qtbot.keyClick(shell._completion_widget, Qt.Key_Enter)
+ qtbot.keyClick(shell._completion_widget, Qt.Key.Key_Enter)
qtbot.waitUntil(lambda: control.toPlainText().split()[-1] == 'cbba')
# Enter debugging mode
@@ -1196,75 +1196,75 @@ def check_value(name, value):
# Test complete in debug mode
# check abs is completed twice (as the cursor moves)
qtbot.keyClicks(control, 'ab')
- qtbot.keyClick(control, Qt.Key_Tab)
+ qtbot.keyClick(control, Qt.Key.Key_Tab)
qtbot.waitUntil(lambda: control.toPlainText().split()[-1] == 'abs')
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
# A second time to check a function call doesn't cause a problem
qtbot.keyClicks(control, 'print(ab')
- qtbot.keyClick(control, Qt.Key_Tab)
+ qtbot.keyClick(control, Qt.Key.Key_Tab)
qtbot.waitUntil(
lambda: control.toPlainText().split()[-1] == 'print(abs')
qtbot.keyClicks(control, ')')
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
# Enter an expression
qtbot.keyClicks(control, 'baab = 10')
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
qtbot.wait(100)
qtbot.waitUntil(lambda: check_value('baab', 10))
# Check baab is completed
qtbot.keyClicks(control, 'baa')
- qtbot.keyClick(control, Qt.Key_Tab)
+ qtbot.keyClick(control, Qt.Key.Key_Tab)
qtbot.waitUntil(lambda: control.toPlainText().split()[-1] == 'baab')
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
# Check the completion widget is shown for abba, abs
qtbot.keyClicks(control, 'abba = 10')
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
qtbot.wait(100)
qtbot.waitUntil(lambda: check_value('abba', 10))
qtbot.keyClicks(control, 'ab')
- qtbot.keyClick(control, Qt.Key_Tab)
+ qtbot.keyClick(control, Qt.Key.Key_Tab)
qtbot.waitUntil(shell._completion_widget.isVisible)
assert control.toPlainText().split()[-1] == 'ab'
- qtbot.keyClick(shell._completion_widget, Qt.Key_Enter)
+ qtbot.keyClick(shell._completion_widget, Qt.Key.Key_Enter)
qtbot.waitUntil(lambda: control.toPlainText().split()[-1] == 'abba')
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
# Create a class
qtbot.keyClicks(control, 'class A(): baba = 1')
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
qtbot.wait(100)
qtbot.waitUntil(lambda: shell.is_defined('A'))
qtbot.keyClicks(control, 'a = A()')
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
qtbot.wait(100)
qtbot.waitUntil(lambda: shell.is_defined('a'))
# Check we can complete attributes
qtbot.keyClicks(control, 'a.ba')
- qtbot.keyClick(control, Qt.Key_Tab)
+ qtbot.keyClick(control, Qt.Key.Key_Tab)
qtbot.waitUntil(lambda: control.toPlainText().split()[-1] == 'a.baba')
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
# Check we can complete pdb command names
qtbot.keyClicks(control, '!longl')
- qtbot.keyClick(control, Qt.Key_Tab)
+ qtbot.keyClick(control, Qt.Key.Key_Tab)
qtbot.waitUntil(lambda: control.toPlainText().split()[-1] == '!longlist')
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
# Check we can use custom complete for pdb
test_file = tmpdir.join('test.py')
@@ -1272,10 +1272,10 @@ def check_value(name, value):
# Set a breakpoint in the new file
qtbot.keyClicks(control, '!b ' + str(test_file) + ':1')
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
# Check we can complete the breakpoint number
qtbot.keyClicks(control, '!ignore ')
- qtbot.keyClick(control, Qt.Key_Tab)
+ qtbot.keyClick(control, Qt.Key.Key_Tab)
qtbot.waitUntil(lambda: control.toPlainText().split()[-1] == '1')
@@ -1295,12 +1295,12 @@ def test_pdb_multiline(ipyconsole, qtbot):
# Test reset magic
qtbot.keyClicks(control, 'if True:')
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
qtbot.wait(500)
qtbot.keyClicks(control, 'bb = 10')
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
qtbot.wait(500)
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
qtbot.wait(500)
assert shell.get_value('bb') == 10
@@ -1325,12 +1325,12 @@ def test_pdb_ignore_lib(ipyconsole, qtbot, show_lib):
qtbot.keyClicks(control, '!s')
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
qtbot.wait(500)
qtbot.keyClicks(control, '!q')
with qtbot.waitSignal(shell.executed):
- qtbot.keyClick(control, Qt.Key_Enter)
+ qtbot.keyClick(control, Qt.Key.Key_Enter)
if show_lib:
assert 'iostream.py' in control.toPlainText()
@@ -1624,7 +1624,7 @@ def test_recursive_pdb(ipyconsole, qtbot):
assert control.toPlainText().split()[-2:] == ["(IPdb", "[2]):"]
# Check completion works
qtbot.keyClicks(control, 'aba')
- qtbot.keyClick(control, Qt.Key_Tab)
+ qtbot.keyClick(control, Qt.Key.Key_Tab)
qtbot.waitUntil(lambda: control.toPlainText().split()[-1] == 'abab',
timeout=SHELL_TIMEOUT)
# quit one layer
@@ -1633,7 +1633,7 @@ def test_recursive_pdb(ipyconsole, qtbot):
assert control.toPlainText().split()[-2:] == ["IPdb", "[4]:"]
# Check completion works
qtbot.keyClicks(control, 'aba')
- qtbot.keyClick(control, Qt.Key_Tab)
+ qtbot.keyClick(control, Qt.Key.Key_Tab)
qtbot.waitUntil(lambda: control.toPlainText().split()[-1] == 'abab',
timeout=SHELL_TIMEOUT)
with qtbot.waitSignal(shell.executed):
@@ -1659,14 +1659,14 @@ def test_stop_pdb(ipyconsole, qtbot):
shell.execute("import time; time.sleep(10)")
qtbot.wait(500)
with qtbot.waitSignal(shell.executed, timeout=1000):
- qtbot.mouseClick(stop_button, Qt.LeftButton)
+ qtbot.mouseClick(stop_button, Qt.MouseButton.LeftButton)
assert "KeyboardInterrupt" in control.toPlainText()
# We are still in the debugger
assert "IPdb [2]:" in control.toPlainText()
assert "In [2]:" not in control.toPlainText()
# Leave the debugger
with qtbot.waitSignal(shell.executed):
- qtbot.mouseClick(stop_button, Qt.LeftButton)
+ qtbot.mouseClick(stop_button, Qt.MouseButton.LeftButton)
assert "In [2]:" in control.toPlainText()
diff --git a/spyder/plugins/ipythonconsole/widgets/control.py b/spyder/plugins/ipythonconsole/widgets/control.py
index 7c7d1270513..33d1044ed90 100644
--- a/spyder/plugins/ipythonconsole/widgets/control.py
+++ b/spyder/plugins/ipythonconsole/widgets/control.py
@@ -89,7 +89,7 @@ def showEvent(self, event):
def keyPressEvent(self, event):
"""Reimplement Qt Method - Basic keypress event handler"""
event, text, key, ctrl, shift = restore_keyevent(event)
- if (key == Qt.Key_ParenLeft and not self.has_selected_text()
+ if (key == Qt.Key.Key_ParenLeft and not self.has_selected_text()
and self.help_enabled and not self.parent()._reading):
self._key_paren_left(text)
else:
@@ -110,7 +110,7 @@ def mouseMoveEvent(self, event):
"""Detect anchors and change cursor shape accordingly."""
self.anchor = self.anchorAt(event.pos())
if self.anchor:
- QApplication.setOverrideCursor(Qt.PointingHandCursor)
+ QApplication.setOverrideCursor(Qt.CursorShape.PointingHandCursor)
else:
QApplication.restoreOverrideCursor()
super(ControlWidget, self).mouseMoveEvent(event)
@@ -119,7 +119,7 @@ def mouseReleaseEvent(self, event):
"""Ooen anchors when clicked."""
if self.anchor:
QDesktopServices.openUrl(QUrl(self.anchor))
- QApplication.setOverrideCursor(Qt.ArrowCursor)
+ QApplication.setOverrideCursor(Qt.CursorShape.ArrowCursor)
self.anchor = None
else:
super(ControlWidget, self).mouseReleaseEvent(event)
@@ -148,7 +148,7 @@ def keyPressEvent(self, event):
"""Reimplement Qt Method - Basic keypress event handler"""
event, text, key, ctrl, shift = restore_keyevent(event)
- if key == Qt.Key_Slash and self.isVisible():
+ if key == Qt.Key.Key_Slash and self.isVisible():
self.sig_show_find_widget_requested.emit()
else:
# Let the parent widget handle the key press event
diff --git a/spyder/plugins/ipythonconsole/widgets/kernelconnect.py b/spyder/plugins/ipythonconsole/widgets/kernelconnect.py
index 1531c12e80b..4e31af7d76c 100644
--- a/spyder/plugins/ipythonconsole/widgets/kernelconnect.py
+++ b/spyder/plugins/ipythonconsole/widgets/kernelconnect.py
@@ -43,7 +43,7 @@ def __init__(self, parent=None):
"ipythonconsole.html#using-external-kernels\">"
"our documentation.
"))
main_label.setWordWrap(True)
- main_label.setAlignment(Qt.AlignJustify)
+ main_label.setAlignment(Qt.AlignmentFlag.AlignJustify)
main_label.setOpenExternalLinks(True)
# Connection file
@@ -138,7 +138,7 @@ def __init__(self, parent=None):
# Ok and Cancel buttons
self.accept_btns = QDialogButtonBox(
QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
- Qt.Horizontal, self)
+ Qt.Orientation.Horizontal, self)
self.accept_btns.accepted.connect(self.save_connection_settings)
self.accept_btns.accepted.connect(self.accept)
diff --git a/spyder/plugins/ipythonconsole/widgets/restartdialog.py b/spyder/plugins/ipythonconsole/widgets/restartdialog.py
index 2fbc140e63f..a0ae543dd18 100644
--- a/spyder/plugins/ipythonconsole/widgets/restartdialog.py
+++ b/spyder/plugins/ipythonconsole/widgets/restartdialog.py
@@ -71,7 +71,7 @@ def __init__(self, parent):
layout.addWidget(self._restart_current)
layout.addWidget(self._restart_all)
layout.addSpacing(10)
- layout.addWidget(self._action_button, 0, Qt.AlignRight)
+ layout.addWidget(self._action_button, 0, Qt.AlignmentFlag.AlignRight)
layout.setContentsMargins(20, 20, 20, 20)
self.setLayout(layout)
diff --git a/spyder/plugins/ipythonconsole/widgets/tests/test_kernelconnect.py b/spyder/plugins/ipythonconsole/widgets/tests/test_kernelconnect.py
index dea1641bb93..58168efe734 100644
--- a/spyder/plugins/ipythonconsole/widgets/tests/test_kernelconnect.py
+++ b/spyder/plugins/ipythonconsole/widgets/tests/test_kernelconnect.py
@@ -119,7 +119,7 @@ def test_connection_dialog_remembers_input_with_ssh_passphrase(
# Press ok and save connection settings
qtbot.mouseClick(dlg.accept_btns.button(QDialogButtonBox.Ok),
- Qt.LeftButton)
+ Qt.MouseButton.LeftButton)
# create new dialog and check fields
new_dlg = connection_dialog_factory.get_default_dialog()
@@ -146,7 +146,7 @@ def test_connection_dialog_doesnt_remember_input_with_ssh_passphrase(
# Press ok and save connection settings
qtbot.mouseClick(dlg.accept_btns.button(QDialogButtonBox.Ok),
- Qt.LeftButton)
+ Qt.MouseButton.LeftButton)
# create new dialog and check fields
new_dlg = connection_dialog_factory.get_default_dialog()
@@ -172,7 +172,7 @@ def test_connection_dialog_remembers_input_with_password(
# Press ok and save connection settings
qtbot.mouseClick(dlg.accept_btns.button(QDialogButtonBox.Ok),
- Qt.LeftButton)
+ Qt.MouseButton.LeftButton)
# create new dialog and check fields
new_dlg = connection_dialog_factory.get_default_dialog()
@@ -198,7 +198,7 @@ def test_connection_dialog_doesnt_remember_input_with_password(
# Press ok and save connection settings
qtbot.mouseClick(dlg.accept_btns.button(QDialogButtonBox.Ok),
- Qt.LeftButton)
+ Qt.MouseButton.LeftButton)
# create new dialog and check fields
new_dlg = connection_dialog_factory.get_default_dialog()
diff --git a/spyder/plugins/layout/api.py b/spyder/plugins/layout/api.py
index 80cfff117b7..ff36e334e05 100644
--- a/spyder/plugins/layout/api.py
+++ b/spyder/plugins/layout/api.py
@@ -400,7 +400,7 @@ def set_main_window_layout(self, main_window, dockable_plugins):
layout_data = []
# Find dock splits in the horizontal direction
- direction = Qt.Horizontal
+ direction = Qt.Orientation.Horizontal
for row in range(0, self._rows + 1):
dock = None
for col in range(0, self._cols + 1):
@@ -418,10 +418,10 @@ def set_main_window_layout(self, main_window, dockable_plugins):
dock = docks[key]
main_window.addDockWidget(
- Qt.LeftDockWidgetArea, dock, direction)
+ Qt.DockWidgetArea.LeftDockWidgetArea, dock, direction)
# Find dock splits in the vertical direction
- direction = Qt.Vertical
+ direction = Qt.Orientation.Vertical
for col in range(0, self._cols + 1):
dock = None
for row in range(0, self._rows + 1):
@@ -497,8 +497,8 @@ def set_main_window_layout(self, main_window, dockable_plugins):
row_stretches.append(stretch)
main_window.showMaximized()
- main_window.resizeDocks(column_docks, column_stretches, Qt.Horizontal)
- main_window.resizeDocks(row_docks, row_stretches, Qt.Vertical)
+ main_window.resizeDocks(column_docks, column_stretches, Qt.Orientation.Horizontal)
+ main_window.resizeDocks(row_docks, row_stretches, Qt.Orientation.Vertical)
# Restore displayed external plugins
for plugin_id in external_plugins_to_show:
diff --git a/spyder/plugins/layout/container.py b/spyder/plugins/layout/container.py
index 8f95ec66896..b2f4c0839c7 100644
--- a/spyder/plugins/layout/container.py
+++ b/spyder/plugins/layout/container.py
@@ -82,7 +82,7 @@ def setup(self):
text=_('Close current pane'),
icon=self.create_icon('close_pane'),
triggered=self._plugin.close_current_dockwidget,
- context=Qt.ApplicationShortcut,
+ context=Qt.ShortcutContext.ApplicationShortcut,
register_shortcut=True,
shortcut_context='_'
)
@@ -93,7 +93,7 @@ def setup(self):
text=_('Maximize current pane'),
icon=self.create_icon('maximize'),
toggled=lambda state: self._plugin.maximize_dockwidget(),
- context=Qt.ApplicationShortcut,
+ context=Qt.ShortcutContext.ApplicationShortcut,
register_shortcut=True,
shortcut_context='_')
@@ -102,7 +102,7 @@ def setup(self):
LayoutContainerActions.Fullscreen,
text=_('Fullscreen mode'),
triggered=self._plugin.toggle_fullscreen,
- context=Qt.ApplicationShortcut,
+ context=Qt.ShortcutContext.ApplicationShortcut,
register_shortcut=True,
shortcut_context='_')
if sys.platform == 'darwin':
@@ -116,7 +116,7 @@ def setup(self):
text='',
triggered=lambda checked:
self._plugin.toggle_lock(),
- context=Qt.ApplicationShortcut,
+ context=Qt.ShortcutContext.ApplicationShortcut,
register_shortcut=True,
shortcut_context='_'
)
@@ -125,14 +125,14 @@ def setup(self):
LayoutContainerActions.SaveLayoutAction,
_("Save current layout"),
triggered=self.show_save_layout,
- context=Qt.ApplicationShortcut,
+ context=Qt.ShortcutContext.ApplicationShortcut,
register_shortcut=False,
)
self._show_preferences_action = self.create_action(
LayoutContainerActions.ShowLayoutPreferencesAction,
text=_("Layout preferences"),
triggered=self.show_layout_settings,
- context=Qt.ApplicationShortcut,
+ context=Qt.ShortcutContext.ApplicationShortcut,
register_shortcut=False,
)
self._reset_action = self.create_action(
@@ -147,14 +147,14 @@ def setup(self):
LayoutContainerActions.NextLayout,
_("Use next layout"),
triggered=self.toggle_next_layout,
- context=Qt.ApplicationShortcut,
+ context=Qt.ShortcutContext.ApplicationShortcut,
register_shortcut=True,
shortcut_context='_')
self._toggle_previous_layout_action = self.create_action(
LayoutContainerActions.PreviousLayout,
_("Use previous layout"),
triggered=self.toggle_previous_layout,
- context=Qt.ApplicationShortcut,
+ context=Qt.ShortcutContext.ApplicationShortcut,
register_shortcut=True,
shortcut_context='_')
diff --git a/spyder/plugins/layout/plugin.py b/spyder/plugins/layout/plugin.py
index c3c8940fc5c..471c043be30 100644
--- a/spyder/plugins/layout/plugin.py
+++ b/spyder/plugins/layout/plugin.py
@@ -725,7 +725,7 @@ def maximize_dockwidget(self, restore=False):
# Automatically show the outline if the editor was maximized:
outline_explorer = self.get_plugin(Plugins.OutlineExplorer)
self.main.addDockWidget(
- Qt.RightDockWidgetArea,
+ Qt.DockWidgetArea.RightDockWidgetArea,
outline_explorer.dockwidget)
outline_explorer.dockwidget.show()
else:
diff --git a/spyder/plugins/layout/widgets/dialog.py b/spyder/plugins/layout/widgets/dialog.py
index 59b66eb835a..9ba16f071c9 100644
--- a/spyder/plugins/layout/widgets/dialog.py
+++ b/spyder/plugins/layout/widgets/dialog.py
@@ -58,16 +58,16 @@ def flags(self, index):
ui_name, name, state = self.row(row)
if name in self.read_only:
- return Qt.NoItemFlags
+ return Qt.ItemFlag.NoItemFlags
if not index.isValid():
- return Qt.ItemIsEnabled
+ return Qt.ItemFlag.ItemIsEnabled
column = index.column()
if column in [0]:
- return Qt.ItemFlags(int(Qt.ItemIsEnabled | Qt.ItemIsSelectable |
- Qt.ItemIsUserCheckable |
- Qt.ItemIsEditable))
+ return Qt.ItemFlags(int(Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable |
+ Qt.ItemFlag.ItemIsUserCheckable |
+ Qt.ItemFlag.ItemIsEditable))
else:
- return Qt.ItemFlags(Qt.ItemIsEnabled)
+ return Qt.ItemFlags(Qt.ItemFlag.ItemIsEnabled)
def data(self, index, role=Qt.DisplayRole):
"""Override Qt method"""
@@ -87,9 +87,9 @@ def data(self, index, role=Qt.DisplayRole):
elif role == Qt.CheckStateRole:
if column == 0:
if state:
- return Qt.Checked
+ return Qt.CheckState.Checked
else:
- return Qt.Unchecked
+ return Qt.CheckState.Unchecked
if column == 1:
return to_qvariant(state)
return to_qvariant()
@@ -147,7 +147,7 @@ def __init__(self, parent, order):
self.combo_box.clearEditText()
self.button_box = QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel,
- Qt.Horizontal, self)
+ Qt.Orientation.Horizontal, self)
self.button_ok = self.button_box.button(QDialogButtonBox.Ok)
self.button_cancel = self.button_box.button(QDialogButtonBox.Cancel)
@@ -197,7 +197,7 @@ def __init__(self, parent, names, ui_names, order, active, read_only):
self.button_delete = QPushButton(_('Delete Layout'))
self.button_box = QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel,
- Qt.Horizontal, self)
+ Qt.Orientation.Horizontal, self)
self.group_box = QGroupBox(_("Layout Display and Order"))
self.table = QTableView(self)
self.ok_button = self.button_box.button(QDialogButtonBox.Ok)
diff --git a/spyder/plugins/onlinehelp/widgets.py b/spyder/plugins/onlinehelp/widgets.py
index d97a9bb6241..ca00f3b0fb1 100644
--- a/spyder/plugins/onlinehelp/widgets.py
+++ b/spyder/plugins/onlinehelp/widgets.py
@@ -333,7 +333,7 @@ def initialize(self, checked=True, force=False):
server_needed = checked and self.server is None
if force or server_needed or not self.is_server_running():
self.sig_toggle_view_changed.disconnect(self.initialize)
- QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
+ QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
self.start_server()
def is_server_running(self):
diff --git a/spyder/plugins/outlineexplorer/tests/test_widgets.py b/spyder/plugins/outlineexplorer/tests/test_widgets.py
index 54ab7d741d3..7dab6145831 100644
--- a/spyder/plugins/outlineexplorer/tests/test_widgets.py
+++ b/spyder/plugins/outlineexplorer/tests/test_widgets.py
@@ -136,7 +136,7 @@ def test_go_to_cursor_position(create_outlineexplorer, qtbot):
assert outlineexplorer.treewidget.currentItem() is None
qtbot.mouseClick(
outlineexplorer.get_toolbutton(OutlineExplorerToolbuttons.GoToCursor),
- Qt.LeftButton)
+ Qt.MouseButton.LeftButton)
assert outlineexplorer.treewidget.currentItem().text(0) == 'inner'
@@ -159,7 +159,7 @@ def test_follow_cursor(create_outlineexplorer, qtbot):
# Go to cursor to open the cursor
qtbot.mouseClick(
outlineexplorer.get_toolbutton(OutlineExplorerToolbuttons.GoToCursor),
- Qt.LeftButton)
+ Qt.MouseButton.LeftButton)
# Check if follows
editor._editor.go_to_line(1)
@@ -188,7 +188,7 @@ def test_go_to_cursor_position_with_new_file(create_outlineexplorer, qtbot):
filename = CASES['text']['file']
qtbot.mouseClick(
outlineexplorer.get_toolbutton(OutlineExplorerToolbuttons.GoToCursor),
- Qt.LeftButton)
+ Qt.MouseButton.LeftButton)
assert outlineexplorer.treewidget.currentItem().text(0) == filename
@@ -213,7 +213,7 @@ def test_go_to_last_item(create_outlineexplorer, qtbot):
# toolbar :
qtbot.mouseClick(
outlineexplorer.get_toolbutton(OutlineExplorerToolbuttons.GoToCursor),
- Qt.LeftButton)
+ Qt.MouseButton.LeftButton)
assert outlineexplorer.treewidget.currentItem().text(0) == 'method1'
diff --git a/spyder/plugins/plots/widgets/figurebrowser.py b/spyder/plugins/plots/widgets/figurebrowser.py
index 5fb06012f5e..cd3cd0a1585 100644
--- a/spyder/plugins/plots/widgets/figurebrowser.py
+++ b/spyder/plugins/plots/widgets/figurebrowser.py
@@ -329,7 +329,7 @@ def __init__(self, parent=None, background_color=None):
QScrollArea.__init__(self, parent)
SpyderWidgetMixin.__init__(self, class_parent=parent)
- self.setAlignment(Qt.AlignCenter)
+ self.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.viewport().setObjectName("figviewport")
self.viewport().setStyleSheet(
"#figviewport {background-color:" + str(background_color) + "}")
@@ -413,8 +413,8 @@ def eventFilter(self, widget, event):
# ---- Panning
# Set ClosedHandCursor:
elif event.type() == QEvent.MouseButtonPress:
- if event.button() == Qt.LeftButton:
- QApplication.setOverrideCursor(Qt.ClosedHandCursor)
+ if event.button() == Qt.MouseButton.LeftButton:
+ QApplication.setOverrideCursor(Qt.CursorShape.ClosedHandCursor)
self._ispanning = True
self.xclick = event.globalX()
self.yclick = event.globalY()
@@ -639,10 +639,10 @@ def eventFilter(self, widget, event):
"""
if event.type() == QEvent.KeyPress:
key = event.key()
- if key == Qt.Key_Up:
+ if key == Qt.Key.Key_Up:
self.go_previous_thumbnail()
return True
- elif key == Qt.Key_Down:
+ elif key == Qt.Key.Key_Down:
self.go_next_thumbnail()
return True
if event.type() == QEvent.Resize:
@@ -988,7 +988,7 @@ def setup_gui(self):
"""Setup the main layout of the widget."""
layout = QGridLayout(self)
layout.setContentsMargins(0, 0, 0, 0)
- layout.addWidget(self.canvas, 0, 0, Qt.AlignCenter)
+ layout.addWidget(self.canvas, 0, 0, Qt.AlignmentFlag.AlignCenter)
layout.setSizeConstraint(layout.SetFixedSize)
def highlight_canvas(self, highlight):
@@ -1028,7 +1028,7 @@ def eventFilter(self, widget, event):
clicked.
"""
if event.type() == QEvent.MouseButtonPress:
- if event.button() == Qt.LeftButton:
+ if event.button() == Qt.MouseButton.LeftButton:
self.sig_canvas_clicked.emit(self)
return super().eventFilter(widget, event)
diff --git a/spyder/plugins/plots/widgets/main_widget.py b/spyder/plugins/plots/widgets/main_widget.py
index 951019694f6..5b6126f5b85 100644
--- a/spyder/plugins/plots/widgets/main_widget.py
+++ b/spyder/plugins/plots/widgets/main_widget.py
@@ -73,7 +73,7 @@ def __init__(self, name=None, plugin=None, parent=None):
self._right_clicked_thumbnail = None
# Widget setup
- self.zoom_disp.setAlignment(Qt.AlignCenter)
+ self.zoom_disp.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.zoom_disp.setButtonSymbols(QSpinBox.NoButtons)
self.zoom_disp.setReadOnly(True)
self.zoom_disp.setSuffix(' %')
diff --git a/spyder/plugins/plots/widgets/tests/test_plots_widgets.py b/spyder/plugins/plots/widgets/tests/test_plots_widgets.py
index 1bda251e402..f5f410712b9 100644
--- a/spyder/plugins/plots/widgets/tests/test_plots_widgets.py
+++ b/spyder/plugins/plots/widgets/tests/test_plots_widgets.py
@@ -346,7 +346,7 @@ def test_mouse_clicking_thumbnails(figbrowser, tmpdir, qtbot, fmt):
figs = add_figures_to_browser(figbrowser, 3, tmpdir, fmt)
for i in [1, 0, 2]:
qtbot.mouseClick(
- figbrowser.thumbnails_sb._thumbnails[i].canvas, Qt.LeftButton)
+ figbrowser.thumbnails_sb._thumbnails[i].canvas, Qt.MouseButton.LeftButton)
assert figbrowser.thumbnails_sb.get_current_index() == i
assert figbrowser.thumbnails_sb.current_thumbnail.canvas.fig == figs[i]
assert figbrowser.figviewer.figcanvas.fig == figs[i]
diff --git a/spyder/plugins/preferences/api.py b/spyder/plugins/preferences/api.py
index 28a0aae3552..952fe0ce0a5 100644
--- a/spyder/plugins/preferences/api.py
+++ b/spyder/plugins/preferences/api.py
@@ -478,7 +478,7 @@ def show_message(is_checked):
return radiobutton
def create_lineedit(self, text, option, default=NoDefault,
- tip=None, alignment=Qt.Vertical, regex=None,
+ tip=None, alignment=Qt.Orientation.Vertical, regex=None,
restart=False, word_wrap=True, placeholder=None,
content_type=None, section=None):
if section is not None and section != self.CONF_SECTION:
@@ -487,7 +487,7 @@ def create_lineedit(self, text, option, default=NoDefault,
label.setWordWrap(word_wrap)
edit = QLineEdit()
edit.content_type = content_type
- layout = QVBoxLayout() if alignment == Qt.Vertical else QHBoxLayout()
+ layout = QVBoxLayout() if alignment == Qt.Orientation.Vertical else QHBoxLayout()
layout.addWidget(label)
layout.addWidget(edit)
layout.setContentsMargins(0, 0, 0, 0)
@@ -534,7 +534,7 @@ def create_textedit(self, text, option, default=NoDefault,
def create_browsedir(self, text, option, default=NoDefault, tip=None,
section=None):
widget = self.create_lineedit(text, option, default, section=section,
- alignment=Qt.Horizontal)
+ alignment=Qt.Orientation.Horizontal)
for edit in self.lineedits:
if widget.isAncestorOf(edit):
break
@@ -564,7 +564,7 @@ def select_directory(self, edit):
def create_browsefile(self, text, option, default=NoDefault, tip=None,
filters=None, section=None):
widget = self.create_lineedit(text, option, default, section=section,
- alignment=Qt.Horizontal)
+ alignment=Qt.Orientation.Horizontal)
for edit in self.lineedits:
if widget.isAncestorOf(edit):
break
@@ -641,7 +641,7 @@ def create_coloredit(self, text, option, default=NoDefault, tip=None,
if section is not None and section != self.CONF_SECTION:
self.cross_section_options[option] = section
label = QLabel(text)
- clayout = ColorLayout(QColor(Qt.black), self)
+ clayout = ColorLayout(QColor(Qt.GlobalColor.black), self)
clayout.lineedit.setMaximumWidth(80)
if tip is not None:
clayout.setToolTip(tip)
@@ -662,7 +662,7 @@ def create_scedit(self, text, option, default=NoDefault, tip=None,
if section is not None and section != self.CONF_SECTION:
self.cross_section_options[option] = section
label = QLabel(text)
- clayout = ColorLayout(QColor(Qt.black), self)
+ clayout = ColorLayout(QColor(Qt.GlobalColor.black), self)
clayout.lineedit.setMaximumWidth(80)
if tip is not None:
clayout.setToolTip(tip)
diff --git a/spyder/plugins/preferences/widgets/configdialog.py b/spyder/plugins/preferences/widgets/configdialog.py
index c2d8e2db660..211c9437b2e 100644
--- a/spyder/plugins/preferences/widgets/configdialog.py
+++ b/spyder/plugins/preferences/widgets/configdialog.py
@@ -161,7 +161,7 @@ def add_page(self, widget):
except TypeError:
pass
item.setText(widget.get_name())
- item.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled)
+ item.setFlags(Qt.ItemFlag.ItemIsSelectable|Qt.ItemFlag.ItemIsEnabled)
item.setSizeHint(QSize(0, 25))
def check_all_settings(self):
diff --git a/spyder/plugins/profiler/widgets/main_widget.py b/spyder/plugins/profiler/widgets/main_widget.py
index 21b5e26b0b9..d9949f631fc 100644
--- a/spyder/plugins/profiler/widgets/main_widget.py
+++ b/spyder/plugins/profiler/widgets/main_widget.py
@@ -898,31 +898,31 @@ def populate_tree(self, parentItem, children_list):
child_item.setToolTip(1, _('Time in function '
'(including sub-functions)'))
child_item.setData(1, Qt.DisplayRole, cum_time)
- child_item.setTextAlignment(1, Qt.AlignRight)
+ child_item.setTextAlignment(1, Qt.AlignmentFlag.AlignRight)
child_item.setData(2, Qt.DisplayRole, cum_time_dif[0])
child_item.setForeground(2, QColor(cum_time_dif[1]))
- child_item.setTextAlignment(2, Qt.AlignLeft)
+ child_item.setTextAlignment(2, Qt.AlignmentFlag.AlignLeft)
child_item.setToolTip(3, _('Local time in function '
'(not in sub-functions)'))
child_item.setData(3, Qt.DisplayRole, loc_time)
- child_item.setTextAlignment(3, Qt.AlignRight)
+ child_item.setTextAlignment(3, Qt.AlignmentFlag.AlignRight)
child_item.setData(4, Qt.DisplayRole, loc_time_dif[0])
child_item.setForeground(4, QColor(loc_time_dif[1]))
- child_item.setTextAlignment(4, Qt.AlignLeft)
+ child_item.setTextAlignment(4, Qt.AlignmentFlag.AlignLeft)
child_item.setToolTip(5, _('Total number of calls '
'(including recursion)'))
child_item.setData(5, Qt.DisplayRole, total_calls)
- child_item.setTextAlignment(5, Qt.AlignRight)
+ child_item.setTextAlignment(5, Qt.AlignmentFlag.AlignRight)
child_item.setData(6, Qt.DisplayRole, total_calls_dif[0])
child_item.setForeground(6, QColor(total_calls_dif[1]))
- child_item.setTextAlignment(6, Qt.AlignLeft)
+ child_item.setTextAlignment(6, Qt.AlignmentFlag.AlignLeft)
child_item.setToolTip(7, _('File:line '
'where function is defined'))
diff --git a/spyder/plugins/projects/widgets/main_widget.py b/spyder/plugins/projects/widgets/main_widget.py
index 074b525d5e4..60037e18b68 100644
--- a/spyder/plugins/projects/widgets/main_widget.py
+++ b/spyder/plugins/projects/widgets/main_widget.py
@@ -131,7 +131,7 @@ def __init__(self, directory=None):
hlayout1 = QHBoxLayout()
vlayout.addLayout(hlayout1)
label = QLabel("Open file:")
- label.setAlignment(Qt.AlignRight)
+ label.setAlignment(Qt.AlignmentFlag.AlignRight)
hlayout1.addWidget(label)
self.label1 = QLabel()
hlayout1.addWidget(self.label1)
@@ -140,7 +140,7 @@ def __init__(self, directory=None):
hlayout3 = QHBoxLayout()
vlayout.addLayout(hlayout3)
label = QLabel("Option changed:")
- label.setAlignment(Qt.AlignRight)
+ label.setAlignment(Qt.AlignmentFlag.AlignRight)
hlayout3.addWidget(label)
self.label3 = QLabel()
hlayout3.addWidget(self.label3)
diff --git a/spyder/plugins/projects/widgets/projectdialog.py b/spyder/plugins/projects/widgets/projectdialog.py
index 56d18b7b376..182f7b569ee 100644
--- a/spyder/plugins/projects/widgets/projectdialog.py
+++ b/spyder/plugins/projects/widgets/projectdialog.py
@@ -102,7 +102,7 @@ def __init__(self, parent, project_types):
self.button_cancel = QPushButton(_('Cancel'))
self.button_create = QPushButton(_('Create'))
- self.bbox = QDialogButtonBox(Qt.Horizontal)
+ self.bbox = QDialogButtonBox(Qt.Orientation.Horizontal)
self.bbox.addButton(self.button_cancel, QDialogButtonBox.ActionRole)
self.bbox.addButton(self.button_create, QDialogButtonBox.ActionRole)
diff --git a/spyder/plugins/pylint/plugin.py b/spyder/plugins/pylint/plugin.py
index d3e333a644d..eddca106e9f 100644
--- a/spyder/plugins/pylint/plugin.py
+++ b/spyder/plugins/pylint/plugin.py
@@ -83,7 +83,7 @@ def on_initialize(self):
tip=_("Run code analysis"),
icon=self.create_icon("pylint"),
triggered=self.start_code_analysis,
- context=Qt.ApplicationShortcut,
+ context=Qt.ShortcutContext.ApplicationShortcut,
register_shortcut=True
)
pylint_act.setEnabled(is_module_installed("pylint"))
diff --git a/spyder/plugins/pythonpath/widgets/pathmanager.py b/spyder/plugins/pythonpath/widgets/pathmanager.py
index 3422d2963b4..786a52d488e 100644
--- a/spyder/plugins/pythonpath/widgets/pathmanager.py
+++ b/spyder/plugins/pythonpath/widgets/pathmanager.py
@@ -191,14 +191,14 @@ def _create_item(self, path):
item.setIcon(ima.icon('DirClosedIcon'))
if path in self.project_path:
- item.setFlags(Qt.NoItemFlags | Qt.ItemIsUserCheckable)
- item.setCheckState(Qt.Checked)
+ item.setFlags(Qt.ItemFlag.NoItemFlags | Qt.ItemFlag.ItemIsUserCheckable)
+ item.setCheckState(Qt.CheckState.Checked)
elif path in self.not_active_path:
- item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
- item.setCheckState(Qt.Unchecked)
+ item.setFlags(item.flags() | Qt.ItemFlag.ItemIsUserCheckable)
+ item.setCheckState(Qt.CheckState.Unchecked)
else:
- item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
- item.setCheckState(Qt.Checked)
+ item.setFlags(item.flags() | Qt.ItemFlag.ItemIsUserCheckable)
+ item.setCheckState(Qt.CheckState.Checked)
return item
@@ -207,8 +207,8 @@ def _create_header(self, text):
header = QListWidgetItem(text)
# Header is centered and it can't be selected
- header.setTextAlignment(Qt.AlignHCenter)
- header.setFlags(Qt.ItemIsEnabled)
+ header.setTextAlignment(Qt.AlignmentFlag.AlignHCenter)
+ header.setFlags(Qt.ItemFlag.ItemIsEnabled)
# Make header appear in bold
font = header.font()
@@ -342,7 +342,7 @@ def get_path_dict(self, project_path=False):
if item not in self.headers:
if path in self.project_path and not project_path:
continue
- odict[path] = item.checkState() == Qt.Checked
+ odict[path] = item.checkState() == Qt.CheckState.Checked
return odict
def get_user_path(self):
@@ -433,7 +433,7 @@ def add_path(self, directory=None):
if directory in self.get_path_dict():
item = self.listwidget.findItems(directory, Qt.MatchExactly)[0]
- item.setCheckState(Qt.Checked)
+ item.setCheckState(Qt.CheckState.Checked)
answer = QMessageBox.question(
self,
_("Add path"),
diff --git a/spyder/plugins/pythonpath/widgets/tests/test_pathmanager.py b/spyder/plugins/pythonpath/widgets/tests/test_pathmanager.py
index f6e73a0e384..17416ca65b8 100644
--- a/spyder/plugins/pythonpath/widgets/tests/test_pathmanager.py
+++ b/spyder/plugins/pythonpath/widgets/tests/test_pathmanager.py
@@ -57,7 +57,7 @@ def test_check_uncheck_path(pathmanager):
for row in range(1, pathmanager.listwidget.count()):
item = pathmanager.listwidget.item(row)
if item not in pathmanager.headers:
- assert item.checkState() == Qt.Checked
+ assert item.checkState() == Qt.CheckState.Checked
@pytest.mark.skipif(os.name != 'nt' or not is_module_installed('win32con'),
@@ -88,7 +88,7 @@ def test_export_to_PYTHONPATH(pathmanager, mocker):
# Uncheck 'path2' and assert that it is removed from PYTHONPATH when it
# is synchronized with Spyder's path list
- pathmanager.listwidget.item(6).setCheckState(Qt.Unchecked)
+ pathmanager.listwidget.item(6).setCheckState(Qt.CheckState.Unchecked)
pathmanager.export_pythonpath()
expected_pathlist = ['p1', 'p3']
env = get_user_env()
@@ -101,7 +101,7 @@ def test_export_to_PYTHONPATH(pathmanager, mocker):
# Uncheck 'path3' and assert that it is kept in PYTHONPATH when it
# is synchronized with Spyder's path list
- pathmanager.listwidget.item(6).setCheckState(Qt.Unchecked)
+ pathmanager.listwidget.item(6).setCheckState(Qt.CheckState.Unchecked)
pathmanager.export_pythonpath()
expected_pathlist = ['p3', 'p1']
env = get_user_env()
@@ -126,7 +126,7 @@ def test_invalid_directories(qtbot, pathmanager):
def interact_message_box():
child = pathmanager.findChild(QMessageBox)
- qtbot.keyPress(child, Qt.Key_Enter)
+ qtbot.keyPress(child, Qt.Key.Key_Enter)
for path in paths:
timer = QTimer()
@@ -150,14 +150,14 @@ def interact_message_box():
buttons = messagebox.findChildren(QPushButton)
for button in buttons:
if 'no' in button.text().lower():
- qtbot.mouseClick(button, Qt.LeftButton)
+ qtbot.mouseClick(button, Qt.MouseButton.LeftButton)
break
timer = QTimer()
timer.setSingleShot(True)
timer.timeout.connect(interact_message_box)
timer.start(100)
- qtbot.mouseClick(pathmanager.remove_button, Qt.LeftButton)
+ qtbot.mouseClick(pathmanager.remove_button, Qt.MouseButton.LeftButton)
# Back to main thread
assert pathmanager.count() == count
@@ -176,7 +176,7 @@ def interact_message_box():
buttons = messagebox.findChildren(QPushButton)
for button in buttons:
if 'yes' in button.text().lower():
- qtbot.mouseClick(button, Qt.LeftButton)
+ qtbot.mouseClick(button, Qt.MouseButton.LeftButton)
break
timer = QTimer()
@@ -184,7 +184,7 @@ def interact_message_box():
timer.timeout.connect(interact_message_box)
timer.start(100)
pathmanager.listwidget.setCurrentRow(4)
- qtbot.mouseClick(pathmanager.remove_button, Qt.LeftButton)
+ qtbot.mouseClick(pathmanager.remove_button, Qt.MouseButton.LeftButton)
# Back to main thread
assert pathmanager.count() == (count - 1)
@@ -206,7 +206,7 @@ def test_add_repeated_item(qtbot, pathmanager, tmpdir):
pathmanager.add_path(dir1)
pathmanager.add_path(dir2)
pathmanager.add_path(dir3)
- pathmanager.set_row_check_state(2, Qt.Unchecked)
+ pathmanager.set_row_check_state(2, Qt.CheckState.Unchecked)
assert not all(pathmanager.get_path_dict().values())
def interact_message_box():
@@ -214,7 +214,7 @@ def interact_message_box():
buttons = messagebox.findChildren(QPushButton)
for button in buttons:
if 'yes' in button.text().lower():
- qtbot.mouseClick(button, Qt.LeftButton)
+ qtbot.mouseClick(button, Qt.MouseButton.LeftButton)
break
timer = QTimer()
diff --git a/spyder/plugins/shortcuts/plugin.py b/spyder/plugins/shortcuts/plugin.py
index 155a09a0569..3abb63ba2a5 100644
--- a/spyder/plugins/shortcuts/plugin.py
+++ b/spyder/plugins/shortcuts/plugin.py
@@ -79,7 +79,7 @@ def on_initialize(self):
text=_("Shortcuts Summary"),
triggered=self.show_summary,
register_shortcut=True,
- context=Qt.ApplicationShortcut,
+ context=Qt.ShortcutContext.ApplicationShortcut,
)
@on_plugin_available(plugin=Plugins.Preferences)
diff --git a/spyder/plugins/shortcuts/tests/test_shortcuts.py b/spyder/plugins/shortcuts/tests/test_shortcuts.py
index 40a1203c49f..208f944144f 100644
--- a/spyder/plugins/shortcuts/tests/test_shortcuts.py
+++ b/spyder/plugins/shortcuts/tests/test_shortcuts.py
@@ -140,7 +140,7 @@ def test_clear_shortcut(create_shortcut_editor, qtbot):
shortcut is working as expected.
"""
shortcut_editor = create_shortcut_editor('editor', 'delete line')
- qtbot.mouseClick(shortcut_editor.button_clear, Qt.LeftButton)
+ qtbot.mouseClick(shortcut_editor.button_clear, Qt.MouseButton.LeftButton)
assert shortcut_editor.new_sequence == ''
@@ -151,7 +151,7 @@ def test_press_new_sequence(create_shortcut_editor, qtbot):
"""
shortcut_editor = create_shortcut_editor('editor', 'delete line')
modifiers = Qt.ControlModifier | Qt.ShiftModifier | Qt.AltModifier
- qtbot.keyClick(shortcut_editor, Qt.Key_D, modifier=modifiers)
+ qtbot.keyClick(shortcut_editor, Qt.Key.Key_D, modifier=modifiers)
assert shortcut_editor.new_sequence == 'Ctrl+Alt+Shift+D'
assert shortcut_editor.warning == NO_WARNING
assert shortcut_editor.button_ok.isEnabled()
@@ -163,11 +163,11 @@ def test_press_new_compound_sequence(create_shortcut_editor, qtbot):
expected by the Shortcut Editor.
"""
shortcut_editor = create_shortcut_editor('editor', 'delete line')
- qtbot.keyClick(shortcut_editor, Qt.Key_D, modifier=Qt.ControlModifier)
- qtbot.keyClick(shortcut_editor, Qt.Key_A)
- qtbot.keyClick(shortcut_editor, Qt.Key_B, modifier=Qt.ControlModifier)
- qtbot.keyClick(shortcut_editor, Qt.Key_C)
- qtbot.keyClick(shortcut_editor, Qt.Key_D)
+ qtbot.keyClick(shortcut_editor, Qt.Key.Key_D, modifier=Qt.ControlModifier)
+ qtbot.keyClick(shortcut_editor, Qt.Key.Key_A)
+ qtbot.keyClick(shortcut_editor, Qt.Key.Key_B, modifier=Qt.ControlModifier)
+ qtbot.keyClick(shortcut_editor, Qt.Key.Key_C)
+ qtbot.keyClick(shortcut_editor, Qt.Key.Key_D)
assert shortcut_editor.new_sequence == 'Ctrl+D, A, Ctrl+B, C'
# The 'D' key press event is discarted because a compound sequence
# cannot be composed of more than 4 sub sequences.
@@ -181,26 +181,26 @@ def test_clear_back_new_sequence(create_shortcut_editor, qtbot):
key sequence from the Shortcut Editor is working as expected.
"""
shortcut_editor = create_shortcut_editor('editor', 'delete line')
- qtbot.keyClick(shortcut_editor, Qt.Key_X, modifier=Qt.ControlModifier)
- qtbot.keyClick(shortcut_editor, Qt.Key_A)
- qtbot.keyClick(shortcut_editor, Qt.Key_B, modifier=Qt.ControlModifier)
- qtbot.keyClick(shortcut_editor, Qt.Key_C)
- qtbot.keyClick(shortcut_editor, Qt.Key_D)
+ qtbot.keyClick(shortcut_editor, Qt.Key.Key_X, modifier=Qt.ControlModifier)
+ qtbot.keyClick(shortcut_editor, Qt.Key.Key_A)
+ qtbot.keyClick(shortcut_editor, Qt.Key.Key_B, modifier=Qt.ControlModifier)
+ qtbot.keyClick(shortcut_editor, Qt.Key.Key_C)
+ qtbot.keyClick(shortcut_editor, Qt.Key.Key_D)
# Remove last key sequence entered.
- qtbot.mouseClick(shortcut_editor.button_back_sequence, Qt.LeftButton)
+ qtbot.mouseClick(shortcut_editor.button_back_sequence, Qt.MouseButton.LeftButton)
assert shortcut_editor.new_sequence == 'Ctrl+X, A, Ctrl+B'
assert shortcut_editor.warning == SEQUENCE_CONFLICT
assert shortcut_editor.button_ok.isEnabled()
# Remove second to last key sequence entered.
- qtbot.mouseClick(shortcut_editor.button_back_sequence, Qt.LeftButton)
+ qtbot.mouseClick(shortcut_editor.button_back_sequence, Qt.MouseButton.LeftButton)
assert shortcut_editor.new_sequence == 'Ctrl+X, A'
assert shortcut_editor.warning == SEQUENCE_CONFLICT
assert shortcut_editor.button_ok.isEnabled()
# Clear all entered key sequences.
- qtbot.mouseClick(shortcut_editor.btn_clear_sequence, Qt.LeftButton)
+ qtbot.mouseClick(shortcut_editor.btn_clear_sequence, Qt.MouseButton.LeftButton)
assert shortcut_editor.new_sequence == ''
assert shortcut_editor.warning == SEQUENCE_EMPTY
assert not shortcut_editor.button_ok.isEnabled()
@@ -214,14 +214,14 @@ def test_sequence_conflict(create_shortcut_editor, qtbot):
shortcut_editor = create_shortcut_editor('editor', 'delete line')
# Check that the conflict is detected for a single key sequence.
- qtbot.keyClick(shortcut_editor, Qt.Key_X, modifier=Qt.ControlModifier)
+ qtbot.keyClick(shortcut_editor, Qt.Key.Key_X, modifier=Qt.ControlModifier)
assert shortcut_editor.new_sequence == 'Ctrl+X'
assert shortcut_editor.warning == SEQUENCE_CONFLICT
assert shortcut_editor.button_ok.isEnabled()
# Check that the conflict is detected for a compound of key sequences.
- qtbot.keyClick(shortcut_editor, Qt.Key_X)
+ qtbot.keyClick(shortcut_editor, Qt.Key.Key_X)
assert shortcut_editor.new_sequence == 'Ctrl+X, X'
assert shortcut_editor.warning == SEQUENCE_CONFLICT
assert shortcut_editor.button_ok.isEnabled()
@@ -236,20 +236,20 @@ def test_sequence_single_key(create_shortcut_editor, qtbot):
shortcut_editor = create_shortcut_editor('editor', 'delete line')
# Check this is working as expected for a single key sequence.
- qtbot.keyClick(shortcut_editor, Qt.Key_D)
+ qtbot.keyClick(shortcut_editor, Qt.Key.Key_D)
assert shortcut_editor.new_sequence == 'D'
assert shortcut_editor.warning == INVALID_KEY
assert not shortcut_editor.button_ok.isEnabled()
# Check this is working as expected for a compound of key sequences.
- qtbot.keyClick(shortcut_editor, Qt.Key_D, modifier=Qt.ControlModifier)
+ qtbot.keyClick(shortcut_editor, Qt.Key.Key_D, modifier=Qt.ControlModifier)
assert shortcut_editor.new_sequence == 'D, Ctrl+D'
assert shortcut_editor.warning == INVALID_KEY
assert not shortcut_editor.button_ok.isEnabled()
# Check this is working as expected when a valid single key is pressed.
- qtbot.mouseClick(shortcut_editor.btn_clear_sequence, Qt.LeftButton)
- qtbot.keyClick(shortcut_editor, Qt.Key_Home)
+ qtbot.mouseClick(shortcut_editor.btn_clear_sequence, Qt.MouseButton.LeftButton)
+ qtbot.keyClick(shortcut_editor, Qt.Key.Key_Home)
assert shortcut_editor.new_sequence == 'Home'
assert shortcut_editor.warning == NO_WARNING
assert shortcut_editor.button_ok.isEnabled()
@@ -264,7 +264,7 @@ def test_set_sequence_to_default(create_shortcut_editor, qtbot):
default_sequence = CONF.get(
'shortcuts', "{}/{}".format('editor', 'delete line'))
- qtbot.mouseClick(shortcut_editor.button_default, Qt.LeftButton)
+ qtbot.mouseClick(shortcut_editor.button_default, Qt.MouseButton.LeftButton)
assert shortcut_editor.new_sequence == default_sequence
assert shortcut_editor.warning == NO_WARNING
assert shortcut_editor.button_ok.isEnabled()
@@ -278,7 +278,7 @@ def test_invalid_char_in_sequence(create_shortcut_editor, qtbot):
shortcut_editor = create_shortcut_editor('editor', 'delete line')
# Check this is working as expected for a single key sequence.
- qtbot.keyClick(shortcut_editor, Qt.Key_Odiaeresis,
+ qtbot.keyClick(shortcut_editor, Qt.Key.Key_Odiaeresis,
modifier=Qt.ControlModifier | Qt.AltModifier)
assert shortcut_editor.warning == INVALID_KEY
assert not shortcut_editor.button_ok.isEnabled()
diff --git a/spyder/plugins/shortcuts/widgets/summary.py b/spyder/plugins/shortcuts/widgets/summary.py
index d1081d54c81..c6c351eef78 100644
--- a/spyder/plugins/shortcuts/widgets/summary.py
+++ b/spyder/plugins/shortcuts/widgets/summary.py
@@ -70,7 +70,7 @@ def __init__(self, parent=None):
font_title.setBold(True)
title_label = QLabel(self._shortcuts_summary_title)
- title_label.setAlignment(Qt.AlignCenter)
+ title_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
title_label.setFont(font_title)
# iter over shortcuts and create GroupBox for each context
diff --git a/spyder/plugins/shortcuts/widgets/table.py b/spyder/plugins/shortcuts/widgets/table.py
index 1f95d42778d..35df63cb06d 100644
--- a/spyder/plugins/shortcuts/widgets/table.py
+++ b/spyder/plugins/shortcuts/widgets/table.py
@@ -119,11 +119,11 @@ class ShortcutFinder(FinderLineEdit):
def keyPressEvent(self, event):
"""Qt and FilterLineEdit Override."""
key = event.key()
- if key in [Qt.Key_Up]:
+ if key in [Qt.Key.Key_Up]:
self._parent.previous_row()
- elif key in [Qt.Key_Down]:
+ elif key in [Qt.Key.Key_Down]:
self._parent.next_row()
- elif key in [Qt.Key_Enter, Qt.Key_Return]:
+ elif key in [Qt.Key.Key_Enter, Qt.Key.Key_Return]:
self._parent.show_editor()
else:
super(ShortcutFinder, self).keyPressEvent(event)
@@ -173,7 +173,7 @@ def setup(self):
_("Press the new shortcut and select 'Ok' to confirm, "
"click 'Cancel' to revert to the previous state, "
"or use 'Clear' to unbind the command from a shortcut."))
- self.label_info.setAlignment(Qt.AlignTop | Qt.AlignLeft)
+ self.label_info.setAlignment(Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignLeft)
self.label_info.setWordWrap(True)
layout_info = QHBoxLayout()
layout_info.setContentsMargins(0, 0, 0, 0)
@@ -192,7 +192,7 @@ def setup(self):
self.helper_button.setIcon(QIcon())
self.label_warning = QLabel()
self.label_warning.setWordWrap(True)
- self.label_warning.setAlignment(Qt.AlignTop | Qt.AlignLeft)
+ self.label_warning.setAlignment(Qt.AlignmentFlag.AlignTop | Qt.AlignmentFlag.AlignLeft)
self.button_default = QPushButton(_('Default'))
self.button_ok = QPushButton(_('Ok'))
@@ -270,14 +270,14 @@ def setup(self):
self.button_clear, self.button_default, self.button_cancel,
self.button_ok, self.btn_clear_sequence, self.button_back_sequence)
for w in widgets:
- w.setFocusPolicy(Qt.NoFocus)
+ w.setFocusPolicy(Qt.FocusPolicy.NoFocus)
w.clearFocus()
@Slot()
def reject(self):
"""Slot for rejected signal."""
# Added for spyder-ide/spyder#5426. Due to the focusPolicy of
- # Qt.NoFocus for the buttons, if the cancel button was clicked without
+ # Qt.FocusPolicy.NoFocus for the buttons, if the cancel button was clicked without
# first setting focus to the button, it would cause a seg fault crash.
self.button_cancel.setFocus()
super(ShortcutEditor, self).reject()
@@ -286,7 +286,7 @@ def reject(self):
def accept(self):
"""Slot for accepted signal."""
# Added for spyder-ide/spyder#5426. Due to the focusPolicy of
- # Qt.NoFocus for the buttons, if the cancel button was clicked without
+ # Qt.FocusPolicy.NoFocus for the buttons, if the cancel button was clicked without
# first setting focus to the button, it would cause a seg fault crash.
self.button_ok.setFocus()
super(ShortcutEditor, self).accept()
@@ -308,13 +308,13 @@ def event(self, event):
def keyPressEvent(self, event):
"""Qt method override."""
event_key = event.key()
- if not event_key or event_key == Qt.Key_unknown:
+ if not event_key or event_key == Qt.Key.Key_unknown:
return
if len(self._qsequences) == 4:
# QKeySequence accepts a maximum of 4 different sequences.
return
- if event_key in [Qt.Key_Control, Qt.Key_Shift,
- Qt.Key_Alt, Qt.Key_Meta]:
+ if event_key in [Qt.Key.Key_Control, Qt.Key.Key_Shift,
+ Qt.Key.Key_Alt, Qt.Key.Key_Meta]:
# The event corresponds to just and only a special key.
return
@@ -531,7 +531,7 @@ def sortByName(self):
def flags(self, index):
"""Qt Override."""
if not index.isValid():
- return Qt.ItemIsEnabled
+ return Qt.ItemFlag.ItemIsEnabled
return Qt.ItemFlags(int(QAbstractTableModel.flags(self, index)))
def data(self, index, role=Qt.DisplayRole):
@@ -572,18 +572,18 @@ def data(self, index, role=Qt.DisplayRole):
# hidden.
return to_qvariant(self.scores[row])
elif role == Qt.TextAlignmentRole:
- return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter))
+ return to_qvariant(int(Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignVCenter))
return to_qvariant()
def headerData(self, section, orientation, role=Qt.DisplayRole):
"""Qt Override."""
if role == Qt.TextAlignmentRole:
- if orientation == Qt.Horizontal:
- return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter))
- return to_qvariant(int(Qt.AlignRight | Qt.AlignVCenter))
+ if orientation == Qt.Orientation.Horizontal:
+ return to_qvariant(int(Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignVCenter))
+ return to_qvariant(int(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter))
if role != Qt.DisplayRole:
return to_qvariant()
- if orientation == Qt.Horizontal:
+ if orientation == Qt.Orientation.Horizontal:
if section == CONTEXT:
return to_qvariant(_("Context"))
elif section == NAME:
@@ -820,21 +820,21 @@ def previous_row(self):
def keyPressEvent(self, event):
"""Qt Override."""
key = event.key()
- if key in [Qt.Key_Enter, Qt.Key_Return]:
+ if key in [Qt.Key.Key_Enter, Qt.Key.Key_Return]:
self.show_editor()
- elif key in [Qt.Key_Tab]:
+ elif key in [Qt.Key.Key_Tab]:
self.finder.setFocus()
- elif key in [Qt.Key_Backtab]:
+ elif key in [Qt.Key.Key_Backtab]:
self.parent().reset_btn.setFocus()
- elif key in [Qt.Key_Up, Qt.Key_Down, Qt.Key_Left, Qt.Key_Right]:
+ elif key in [Qt.Key.Key_Up, Qt.Key.Key_Down, Qt.Key.Key_Left, Qt.Key.Key_Right]:
super(ShortcutsTable, self).keyPressEvent(event)
- elif key not in [Qt.Key_Escape, Qt.Key_Space]:
+ elif key not in [Qt.Key.Key_Escape, Qt.Key.Key_Space]:
text = event.text()
if text:
if re.search(VALID_FINDER_CHARS, text) is not None:
self.finder.setFocus()
self.finder.set_text(text)
- elif key in [Qt.Key_Escape]:
+ elif key in [Qt.Key.Key_Escape]:
self.finder.keyPressEvent(event)
def mouseDoubleClickEvent(self, event):
diff --git a/spyder/plugins/shortcuts/widgets/tests/test_summary.py b/spyder/plugins/shortcuts/widgets/tests/test_summary.py
index dbbaeb7d99f..ef204ada505 100644
--- a/spyder/plugins/shortcuts/widgets/tests/test_summary.py
+++ b/spyder/plugins/shortcuts/widgets/tests/test_summary.py
@@ -35,7 +35,7 @@ def test_shortcutssummary(dlg_shortcuts, qtbot):
assert not dlg_shortcuts._layout.isEmpty()
# Test that the dialog is closed properly on Esc keypress
- qtbot.keyClick(dlg_shortcuts, Qt.Key_Escape)
+ qtbot.keyClick(dlg_shortcuts, Qt.Key.Key_Escape)
assert not dlg_shortcuts.isVisible()
diff --git a/spyder/plugins/statusbar/widgets/tests/test_status.py b/spyder/plugins/statusbar/widgets/tests/test_status.py
index 57272f9b4ca..d92499c2807 100644
--- a/spyder/plugins/statusbar/widgets/tests/test_status.py
+++ b/spyder/plugins/statusbar/widgets/tests/test_status.py
@@ -79,7 +79,7 @@ def test_status_bar_widget_signal(status_bar, qtbot):
assert len(plugin.STATUS_WIDGETS) == 4
with qtbot.waitSignal(w.sig_clicked, timeout=1000):
- qtbot.mouseRelease(w, Qt.LeftButton)
+ qtbot.mouseRelease(w, Qt.MouseButton.LeftButton)
assert w.get_tooltip() == 'tooltip'
assert w.get_icon() == 'icon'
diff --git a/spyder/plugins/tours/widgets.py b/spyder/plugins/tours/widgets.py
index dfb82d6e898..217b0f54da3 100644
--- a/spyder/plugins/tours/widgets.py
+++ b/spyder/plugins/tours/widgets.py
@@ -176,7 +176,7 @@ def __init__(self, parent, opacity, duration, easing_curve, color,
self.setAttribute(Qt.WA_TranslucentBackground)
self.setAttribute(Qt.WA_TransparentForMouseEvents)
self.setModal(False)
- self.setFocusPolicy(Qt.NoFocus)
+ self.setFocusPolicy(Qt.FocusPolicy.NoFocus)
self.set_funcs_before_fade_in([self.update_canvas])
self.set_funcs_after_fade_out([lambda: self.update_widgets(None),
@@ -277,7 +277,7 @@ def paintEvent(self, event):
def reject(self):
"""Override Qt method"""
if not self.is_fade_running():
- key = Qt.Key_Escape
+ key = Qt.Key.Key_Escape
self.key_pressed = key
self.sig_key_pressed.emit()
@@ -345,7 +345,7 @@ def toolbutton(icon):
self.label_content.setMinimumWidth(self.fixed_width)
self.label_content.setMaximumWidth(self.fixed_width)
- self.label_current.setAlignment(Qt.AlignCenter)
+ self.label_current.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.label_content.setWordWrap(True)
@@ -382,9 +382,9 @@ def toolbutton(icon):
# Windows fix, slashes should be always in unix-style
self.stylesheet = self.stylesheet.replace('\\', '/')
- self.setFocusPolicy(Qt.StrongFocus)
+ self.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
for widget in self.widgets:
- widget.setFocusPolicy(Qt.NoFocus)
+ widget.setFocusPolicy(Qt.FocusPolicy.NoFocus)
widget.setStyleSheet(self.stylesheet)
layout_top = QHBoxLayout()
@@ -546,7 +546,7 @@ def paintEvent(self, event):
painter.fillPath(self.round_rect_path, self.color_back)
painter.fillPath(self.top_rect_path, self.color_top)
- painter.strokePath(self.round_rect_path, QPen(Qt.gray, 1))
+ painter.strokePath(self.round_rect_path, QPen(Qt.GlobalColor.gray, 1))
# TODO: Build the pointing arrow?
@@ -555,9 +555,9 @@ def keyReleaseEvent(self, event):
key = event.key()
self.key_pressed = key
- keys = [Qt.Key_Right, Qt.Key_Left, Qt.Key_Down, Qt.Key_Up,
- Qt.Key_Escape, Qt.Key_PageUp, Qt.Key_PageDown,
- Qt.Key_Home, Qt.Key_End, Qt.Key_Menu]
+ keys = [Qt.Key.Key_Right, Qt.Key.Key_Left, Qt.Key.Key_Down, Qt.Key.Key_Up,
+ Qt.Key.Key_Escape, Qt.Key.Key_PageUp, Qt.Key.Key_PageDown,
+ Qt.Key.Key_Home, Qt.Key.Key_End, Qt.Key.Key_Menu]
if key in keys:
if not self.is_fade_running():
@@ -569,7 +569,7 @@ def mousePressEvent(self, event):
self.parent.raise_()
self.raise_()
- if event.button() == Qt.RightButton:
+ if event.button() == Qt.MouseButton.RightButton:
pass
# clicked_widget = self.childAt(event.x(), event.y())
# if clicked_widget == self.label_current:
@@ -597,7 +597,7 @@ def context_menu_requested(self, event):
def reject(self):
"""Qt method to handle escape key event"""
if not self.is_fade_running():
- key = Qt.Key_Escape
+ key = Qt.Key.Key_Escape
self.key_pressed = key
self.sig_key_pressed.emit()
@@ -615,7 +615,7 @@ def __init__(self, parent):
self.duration_tips = [333, 333]
self.opacity_canvas = [0.0, 0.7]
self.opacity_tips = [0.0, 1.0]
- self.color = Qt.black
+ self.color = Qt.GlobalColor.black
self.easing_curve = [QEasingCurve.Linear]
self.current_step = 0
@@ -881,19 +881,19 @@ def _check_buttons(self):
def _key_pressed(self):
key = self.tips.key_pressed
- if ((key == Qt.Key_Right or key == Qt.Key_Down or
- key == Qt.Key_PageDown) and self.step_current != self.steps - 1):
+ if ((key == Qt.Key.Key_Right or key == Qt.Key.Key_Down or
+ key == Qt.Key.Key_PageDown) and self.step_current != self.steps - 1):
self.next_step()
- elif ((key == Qt.Key_Left or key == Qt.Key_Up or
- key == Qt.Key_PageUp) and self.step_current != 0):
+ elif ((key == Qt.Key.Key_Left or key == Qt.Key.Key_Up or
+ key == Qt.Key.Key_PageUp) and self.step_current != 0):
self.previous_step()
- elif key == Qt.Key_Escape:
+ elif key == Qt.Key.Key_Escape:
self.close_tour()
- elif key == Qt.Key_Home and self.step_current != 0:
+ elif key == Qt.Key.Key_Home and self.step_current != 0:
self.first_step()
- elif key == Qt.Key_End and self.step_current != self.steps - 1:
+ elif key == Qt.Key.Key_End and self.step_current != self.steps - 1:
self.last_step()
- elif key == Qt.Key_Menu:
+ elif key == Qt.Key.Key_Menu:
pos = self.tips.label_current.pos()
self.tips.context_menu_requested(pos)
diff --git a/spyder/plugins/variableexplorer/widgets/arrayeditor.py b/spyder/plugins/variableexplorer/widgets/arrayeditor.py
index 0aa4579d56f..06d5237a38a 100644
--- a/spyder/plugins/variableexplorer/widgets/arrayeditor.py
+++ b/spyder/plugins/variableexplorer/widgets/arrayeditor.py
@@ -294,7 +294,7 @@ def data(self, index, role=Qt.DisplayRole):
self.readonly = True
return repr(value)
elif role == Qt.TextAlignmentRole:
- return to_qvariant(int(Qt.AlignCenter|Qt.AlignVCenter))
+ return to_qvariant(int(Qt.AlignmentFlag.AlignCenter|Qt.AlignmentFlag.AlignVCenter))
elif (role == Qt.BackgroundColorRole and self.bgcolor_enabled
and value is not np.ma.masked and not self.has_inf):
try:
@@ -364,15 +364,15 @@ def setData(self, index, value, role=Qt.EditRole):
def flags(self, index):
"""Set editable flag"""
if not index.isValid():
- return Qt.ItemIsEnabled
+ return Qt.ItemFlag.ItemIsEnabled
return Qt.ItemFlags(int(QAbstractTableModel.flags(self, index) |
- Qt.ItemIsEditable))
+ Qt.ItemFlag.ItemIsEditable))
def headerData(self, section, orientation, role=Qt.DisplayRole):
"""Set header data"""
if role != Qt.DisplayRole:
return to_qvariant()
- labels = self.xlabels if orientation == Qt.Horizontal else self.ylabels
+ labels = self.xlabels if orientation == Qt.Orientation.Horizontal else self.ylabels
if labels is None:
return to_qvariant(int(section))
else:
@@ -403,7 +403,7 @@ def createEditor(self, parent, option, index):
elif value is not np.ma.masked:
editor = QLineEdit(parent)
editor.setFont(get_font(font_size_delta=DEFAULT_SMALL_DELTA))
- editor.setAlignment(Qt.AlignCenter)
+ editor.setAlignment(Qt.AlignmentFlag.AlignCenter)
if is_number(self.dtype):
validator = QDoubleValidator(editor)
validator.setLocale(QLocale('C'))
@@ -515,7 +515,7 @@ def load_more_data(self, value, rows=False, columns=False):
@Slot()
def resize_to_contents(self):
"""Resize cells to contents"""
- QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
+ QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
self.resizeColumnsToContents()
self.model().fetch_more(columns=True)
self.resizeColumnsToContents()
@@ -527,7 +527,7 @@ def setup_menu(self):
shortcut=keybinding('Copy'),
icon=ima.icon('editcopy'),
triggered=self.copy,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
menu = QMenu(self)
add_actions(menu, [self.copy_action, ])
return menu
diff --git a/spyder/plugins/variableexplorer/widgets/collectionsdelegate.py b/spyder/plugins/variableexplorer/widgets/collectionsdelegate.py
index d46707cae0b..2ef8c78957d 100644
--- a/spyder/plugins/variableexplorer/widgets/collectionsdelegate.py
+++ b/spyder/plugins/variableexplorer/widgets/collectionsdelegate.py
@@ -253,7 +253,7 @@ def createEditor(self, parent, option, index, object_explorer=False):
else:
editor = QLineEdit(parent=parent)
editor.setFont(get_font(font_size_delta=DEFAULT_SMALL_DELTA))
- editor.setAlignment(Qt.AlignLeft)
+ editor.setAlignment(Qt.AlignmentFlag.AlignLeft)
# This is making Spyder crash because the QLineEdit that it's
# been modified is removed and a new one is created after
# evaluation. So the object on which this method is trying to
@@ -532,7 +532,7 @@ def createEditor(self, parent, option, index):
else:
editor = QLineEdit(parent=parent)
editor.setFont(get_font(font_size_delta=DEFAULT_SMALL_DELTA))
- editor.setAlignment(Qt.AlignLeft)
+ editor.setAlignment(Qt.AlignmentFlag.AlignLeft)
# This is making Spyder crash because the QLineEdit that it's
# been modified is removed and a new one is created after
# evaluation. So the object on which this method is trying to
diff --git a/spyder/plugins/variableexplorer/widgets/dataframeeditor.py b/spyder/plugins/variableexplorer/widgets/dataframeeditor.py
index 615de975c44..56562d7d748 100644
--- a/spyder/plugins/variableexplorer/widgets/dataframeeditor.py
+++ b/spyder/plugins/variableexplorer/widgets/dataframeeditor.py
@@ -81,7 +81,7 @@
BACKGROUND_NUMBER_SATURATION = 0.7
BACKGROUND_NUMBER_VALUE = 1.0
BACKGROUND_NUMBER_ALPHA = 0.6
-BACKGROUND_NONNUMBER_COLOR = Qt.lightGray
+BACKGROUND_NONNUMBER_COLOR = Qt.GlobalColor.lightGray
BACKGROUND_INDEX_ALPHA = 0.8
BACKGROUND_STRING_ALPHA = 0.05
BACKGROUND_MISC_ALPHA = 0.3
@@ -429,7 +429,7 @@ def sort(self, column, order=Qt.AscendingOrder):
def flags(self, index):
"""Set flags"""
return Qt.ItemFlags(int(QAbstractTableModel.flags(self, index) |
- Qt.ItemIsEditable))
+ Qt.ItemFlag.ItemIsEditable))
def setData(self, index, value, role=Qt.EditRole, change_type=None):
"""Cell content change"""
@@ -617,7 +617,7 @@ def setup_menu(self):
shortcut=keybinding('Copy'),
icon=ima.icon('editcopy'),
triggered=self.copy,
- context=Qt.WidgetShortcut)
+ context=Qt.ShortcutContext.WidgetShortcut)
functions = ((_("To bool"), bool), (_("To complex"), complex),
(_("To int"), int), (_("To float"), float),
(_("To str"), to_text_string))
@@ -627,7 +627,7 @@ def slot():
self.change_type(func)
types_in_menu += [create_action(self, name,
triggered=slot,
- context=Qt.WidgetShortcut)]
+ context=Qt.ShortcutContext.WidgetShortcut)]
menu = QMenu(self)
add_actions(menu, types_in_menu)
return menu
@@ -765,15 +765,15 @@ def sort(self, column, order=Qt.AscendingOrder):
def headerData(self, section, orientation, role):
"""Get the information to put in the header."""
if role == Qt.TextAlignmentRole:
- if orientation == Qt.Horizontal:
- return Qt.AlignCenter
+ if orientation == Qt.Orientation.Horizontal:
+ return Qt.AlignmentFlag.AlignCenter
else:
- return int(Qt.AlignRight | Qt.AlignVCenter)
+ return int(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter)
if role != Qt.DisplayRole and role != Qt.ToolTipRole:
return None
if self.axis == 1 and self._shape[1] <= 1:
return None
- orient_axis = 0 if orientation == Qt.Horizontal else 1
+ orient_axis = 0 if orientation == Qt.Orientation.Horizontal else 1
if self.model.header_shape[orient_axis] > 1:
header = section
else:
@@ -857,19 +857,19 @@ def headerData(self, section, orientation, role):
By default it returns 'Index i', where i is the section in the index
"""
if role == Qt.TextAlignmentRole:
- if orientation == Qt.Horizontal:
- return Qt.AlignCenter
+ if orientation == Qt.Orientation.Horizontal:
+ return Qt.AlignmentFlag.AlignCenter
else:
- return int(Qt.AlignRight | Qt.AlignVCenter)
+ return int(Qt.AlignmentFlag.AlignRight | Qt.AlignmentFlag.AlignVCenter)
if role != Qt.DisplayRole and role != Qt.ToolTipRole:
return None
- if self.model.header_shape[0] <= 1 and orientation == Qt.Horizontal:
+ if self.model.header_shape[0] <= 1 and orientation == Qt.Orientation.Horizontal:
if self.model.name(1,section):
return self.model.name(1,section)
return _('Index')
elif self.model.header_shape[0] <= 1:
return None
- elif self.model.header_shape[1] <= 1 and orientation == Qt.Vertical:
+ elif self.model.header_shape[1] <= 1 and orientation == Qt.Orientation.Vertical:
return None
return _('Index') + ' ' + to_text_string(section)
@@ -941,8 +941,8 @@ def setup_and_check(self, data, title=''):
self.setWindowTitle(title)
- self.hscroll = QScrollBar(Qt.Horizontal)
- self.vscroll = QScrollBar(Qt.Vertical)
+ self.hscroll = QScrollBar(Qt.Orientation.Horizontal)
+ self.vscroll = QScrollBar(Qt.Orientation.Vertical)
# Create the view for the level
self.create_table_level()
@@ -1368,7 +1368,7 @@ def _fetch_more_rows(self):
@Slot()
def resize_to_contents(self):
- QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
+ QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
self.dataTable.resizeColumnsToContents()
self.dataModel.fetch_more(columns=True)
self.dataTable.resizeColumnsToContents()
diff --git a/spyder/plugins/variableexplorer/widgets/importwizard.py b/spyder/plugins/variableexplorer/widgets/importwizard.py
index 7fa46403e02..3d104fd8221 100644
--- a/spyder/plugins/variableexplorer/widgets/importwizard.py
+++ b/spyder/plugins/variableexplorer/widgets/importwizard.py
@@ -291,7 +291,7 @@ def data(self, index, role=Qt.DisplayRole):
return to_qvariant(get_color(
self._data[index.row()][index.column()], 0.5))
elif role == Qt.TextAlignmentRole:
- return to_qvariant(int(Qt.AlignRight|Qt.AlignVCenter))
+ return to_qvariant(int(Qt.AlignmentFlag.AlignRight|Qt.AlignmentFlag.AlignVCenter))
return to_qvariant()
def setData(self, index, value, role=Qt.EditRole):
diff --git a/spyder/plugins/variableexplorer/widgets/namespacebrowser.py b/spyder/plugins/variableexplorer/widgets/namespacebrowser.py
index e45eee5fd93..fe53a9e3069 100644
--- a/spyder/plugins/variableexplorer/widgets/namespacebrowser.py
+++ b/spyder/plugins/variableexplorer/widgets/namespacebrowser.py
@@ -218,7 +218,7 @@ def import_data(self, filenames=None):
except Exception as error:
error_message = str(error)
else:
- QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
+ QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
QApplication.processEvents()
error_message = self.shellwidget.load_data(self.filename,
extension)
@@ -259,7 +259,7 @@ def save_data(self):
else:
return False
- QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
+ QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
QApplication.processEvents()
error_message = self.shellwidget.save_namespace(self.filename)
@@ -305,15 +305,15 @@ def load_all_variables(self):
def keyPressEvent(self, event):
"""Qt and FilterLineEdit Override."""
key = event.key()
- if key in [Qt.Key_Up]:
+ if key in [Qt.Key.Key_Up]:
self.load_all_variables()
self._parent.previous_row()
- elif key in [Qt.Key_Down]:
+ elif key in [Qt.Key.Key_Down]:
self.load_all_variables()
self._parent.next_row()
- elif key in [Qt.Key_Escape]:
+ elif key in [Qt.Key.Key_Escape]:
self.main.sig_hide_finder_requested.emit()
- elif key in [Qt.Key_Enter, Qt.Key_Return]:
+ elif key in [Qt.Key.Key_Enter, Qt.Key.Key_Return]:
# TODO: Check if an editor needs to be shown
pass
else:
diff --git a/spyder/plugins/variableexplorer/widgets/objectexplorer/attribute_model.py b/spyder/plugins/variableexplorer/widgets/objectexplorer/attribute_model.py
index af27025d97e..1cece5c866e 100644
--- a/spyder/plugins/variableexplorer/widgets/objectexplorer/attribute_model.py
+++ b/spyder/plugins/variableexplorer/widgets/objectexplorer/attribute_model.py
@@ -42,8 +42,8 @@
# The cast to int is necessary to avoid a bug in PySide, See:
# https://bugreports.qt-project.org/browse/PYSIDE-20
-ALIGN_LEFT = int(Qt.AlignVCenter | Qt.AlignLeft)
-ALIGN_RIGHT = int(Qt.AlignVCenter | Qt.AlignRight)
+ALIGN_LEFT = int(Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignLeft)
+ALIGN_RIGHT = int(Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignRight)
logger = logging.getLogger(__name__)
diff --git a/spyder/plugins/variableexplorer/widgets/objectexplorer/objectexplorer.py b/spyder/plugins/variableexplorer/widgets/objectexplorer/objectexplorer.py
index 9ea20116b87..ca4e46b87c8 100644
--- a/spyder/plugins/variableexplorer/widgets/objectexplorer/objectexplorer.py
+++ b/spyder/plugins/variableexplorer/widgets/objectexplorer/objectexplorer.py
@@ -233,7 +233,7 @@ def _setup_views(self):
layout.setSpacing(0)
layout.addLayout(self.tools_layout)
- self.central_splitter = QSplitter(self, orientation=Qt.Vertical)
+ self.central_splitter = QSplitter(self, orientation=Qt.Orientation.Vertical)
layout.addWidget(self.central_splitter)
self.setLayout(layout)
diff --git a/spyder/plugins/variableexplorer/widgets/objectexplorer/tests/test_objectexplorer.py b/spyder/plugins/variableexplorer/widgets/objectexplorer/tests/test_objectexplorer.py
index 769b8d860a3..2b4b6fb8e09 100644
--- a/spyder/plugins/variableexplorer/widgets/objectexplorer/tests/test_objectexplorer.py
+++ b/spyder/plugins/variableexplorer/widgets/objectexplorer/tests/test_objectexplorer.py
@@ -65,37 +65,37 @@ def error_attribute(self):
header = editor.obj_tree.header()
header_model = header.model()
assert not header.isSectionHidden(0)
- assert header_model.headerData(0, Qt.Horizontal,
+ assert header_model.headerData(0, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "Name"
assert not header.isSectionHidden(1)
- assert header_model.headerData(1, Qt.Horizontal,
+ assert header_model.headerData(1, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "Type"
assert not header.isSectionHidden(2)
- assert header_model.headerData(2, Qt.Horizontal,
+ assert header_model.headerData(2, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "Size"
assert not header.isSectionHidden(3)
- assert header_model.headerData(3, Qt.Horizontal,
+ assert header_model.headerData(3, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "Value"
assert not header.isSectionHidden(4)
- assert header_model.headerData(4, Qt.Horizontal,
+ assert header_model.headerData(4, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "Callable"
assert not header.isSectionHidden(5)
- assert header_model.headerData(5, Qt.Horizontal,
+ assert header_model.headerData(5, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "Path"
assert header.isSectionHidden(6)
- assert header_model.headerData(6, Qt.Horizontal,
+ assert header_model.headerData(6, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "Id"
assert header.isSectionHidden(7)
- assert header_model.headerData(7, Qt.Horizontal,
+ assert header_model.headerData(7, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "Attribute"
assert header.isSectionHidden(8)
- assert header_model.headerData(8, Qt.Horizontal,
+ assert header_model.headerData(8, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "Routine"
assert header.isSectionHidden(9)
- assert header_model.headerData(9, Qt.Horizontal,
+ assert header_model.headerData(9, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "File"
assert header.isSectionHidden(10)
- assert header_model.headerData(10, Qt.Horizontal,
+ assert header_model.headerData(10, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "Source file"
model = editor.obj_tree.model()
diff --git a/spyder/plugins/variableexplorer/widgets/objectexplorer/toggle_column_mixin.py b/spyder/plugins/variableexplorer/widgets/objectexplorer/toggle_column_mixin.py
index c44d7c82354..68cbe1373b5 100644
--- a/spyder/plugins/variableexplorer/widgets/objectexplorer/toggle_column_mixin.py
+++ b/spyder/plugins/variableexplorer/widgets/objectexplorer/toggle_column_mixin.py
@@ -55,7 +55,7 @@ def add_header_context_menu(self, checked=None, checkable=None,
self.__toggle_functions = [] # for keeping references
for col in range(horizontal_header.count()):
- column_label = self.model().headerData(col, Qt.Horizontal,
+ column_label = self.model().headerData(col, Qt.Orientation.Horizontal,
Qt.DisplayRole)
logger.debug("Adding: col {}: {}".format(col, column_label))
action = QAction(str(column_label),
diff --git a/spyder/plugins/variableexplorer/widgets/objectexplorer/tree_model.py b/spyder/plugins/variableexplorer/widgets/objectexplorer/tree_model.py
index 54718738160..903a7a6a24b 100644
--- a/spyder/plugins/variableexplorer/widgets/objectexplorer/tree_model.py
+++ b/spyder/plugins/variableexplorer/widgets/objectexplorer/tree_model.py
@@ -174,12 +174,12 @@ def data(self, index, role):
def flags(self, index):
if not index.isValid():
- return Qt.NoItemFlags
+ return Qt.ItemFlag.NoItemFlags
- return Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsEditable
+ return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable | Qt.ItemFlag.ItemIsEditable
def headerData(self, section, orientation, role):
- if orientation == Qt.Horizontal and role == Qt.DisplayRole:
+ if orientation == Qt.Orientation.Horizontal and role == Qt.DisplayRole:
return self._attr_cols[section].name
else:
return None
diff --git a/spyder/plugins/variableexplorer/widgets/tests/test_arrayeditor.py b/spyder/plugins/variableexplorer/widgets/tests/test_arrayeditor.py
index 943fdd197fc..552a1d3d9e4 100644
--- a/spyder/plugins/variableexplorer/widgets/tests/test_arrayeditor.py
+++ b/spyder/plugins/variableexplorer/widgets/tests/test_arrayeditor.py
@@ -109,7 +109,7 @@ def test_type_errors(setup_arrayeditor, qtbot):
Fixes spyder-ide/spyder#5254.
"""
dlg = setup_arrayeditor
- qtbot.keyClick(dlg.arraywidget.view, Qt.Key_Down, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(dlg.arraywidget.view, Qt.Key.Key_Down, modifier=Qt.ShiftModifier)
contents = dlg.arraywidget.model.get_value(dlg.arraywidget.model.index(0, 0))
assert_array_equal(contents, np.ones(10))
@@ -123,14 +123,14 @@ def test_type_errors(setup_arrayeditor, qtbot):
def test_arrayeditor_format(setup_arrayeditor, qtbot):
"""Changes the format of the array and validates its selected content."""
dlg = setup_arrayeditor
- qtbot.keyClick(dlg.arraywidget.view, Qt.Key_Down, modifier=Qt.ShiftModifier)
- qtbot.keyClick(dlg.arraywidget.view, Qt.Key_Down, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(dlg.arraywidget.view, Qt.Key.Key_Down, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(dlg.arraywidget.view, Qt.Key.Key_Down, modifier=Qt.ShiftModifier)
contents = dlg.arraywidget.view._sel_to_text(dlg.arraywidget.view.selectedIndexes())
assert contents == "1\n2\n"
dlg.arraywidget.view.model().set_format("%.18e")
assert dlg.arraywidget.view.model().get_format() == "%.18e"
- qtbot.keyClick(dlg.arraywidget.view, Qt.Key_Down, modifier=Qt.ShiftModifier)
- qtbot.keyClick(dlg.arraywidget.view, Qt.Key_Down, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(dlg.arraywidget.view, Qt.Key.Key_Down, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(dlg.arraywidget.view, Qt.Key.Key_Down, modifier=Qt.ShiftModifier)
contents = dlg.arraywidget.view._sel_to_text(dlg.arraywidget.view.selectedIndexes())
assert contents == "1.000000000000000000e+00\n2.000000000000000000e+00\n"
@@ -225,13 +225,13 @@ def test_arrayeditor_edit_1d_array(qtbot):
dlg.show()
view = dlg.arraywidget.view
- qtbot.keyPress(view, Qt.Key_Down)
- qtbot.keyPress(view, Qt.Key_Up)
+ qtbot.keyPress(view, Qt.Key.Key_Down)
+ qtbot.keyPress(view, Qt.Key.Key_Up)
qtbot.keyClicks(view, '1')
- qtbot.keyPress(view, Qt.Key_Down)
+ qtbot.keyPress(view, Qt.Key.Key_Down)
qtbot.keyClicks(view, '0')
- qtbot.keyPress(view, Qt.Key_Down)
- qtbot.keyPress(view, Qt.Key_Return)
+ qtbot.keyPress(view, Qt.Key.Key_Down)
+ qtbot.keyPress(view, Qt.Key.Key_Return)
assert np.sum(exp_arr == dlg.get_value()) == 5
@@ -245,14 +245,14 @@ def test_arrayeditor_edit_2d_array(qtbot):
dlg.show()
view = dlg.arraywidget.view
- qtbot.keyPress(view, Qt.Key_Down)
- qtbot.keyPress(view, Qt.Key_Right)
+ qtbot.keyPress(view, Qt.Key.Key_Down)
+ qtbot.keyPress(view, Qt.Key.Key_Right)
qtbot.keyClicks(view, '3')
- qtbot.keyPress(view, Qt.Key_Down)
- qtbot.keyPress(view, Qt.Key_Right)
+ qtbot.keyPress(view, Qt.Key.Key_Down)
+ qtbot.keyPress(view, Qt.Key.Key_Right)
qtbot.keyClicks(view, '0')
- qtbot.keyPress(view, Qt.Key_Left)
- qtbot.keyPress(view, Qt.Key_Return)
+ qtbot.keyPress(view, Qt.Key.Key_Left)
+ qtbot.keyPress(view, Qt.Key.Key_Return)
assert np.sum(diff_arr != dlg.get_value()) == 2
@@ -270,7 +270,7 @@ def test_arrayeditor_edit_complex_array(qtbot):
with qtbot.waitExposed(dlg):
dlg.show()
view = dlg.arraywidget.view
- qtbot.keyPress(view, Qt.Key_Down)
+ qtbot.keyPress(view, Qt.Key.Key_Down)
# Prevent the test from failing
qtbot.wait(300)
@@ -278,7 +278,7 @@ def test_arrayeditor_edit_complex_array(qtbot):
# This is the actual editor widget on the cell
cell_editor = view.viewport().focusWidget()
qtbot.keyClicks(cell_editor, str(cnum))
- qtbot.keyPress(cell_editor, Qt.Key_Return)
+ qtbot.keyPress(cell_editor, Qt.Key.Key_Return)
dlg.accept()
@@ -338,19 +338,19 @@ def test_arrayeditor_edit_overflow(qtbot, monkeypatch):
dialog.show()
view = dialog.arraywidget.view
- qtbot.keyClick(view, Qt.Key_Down)
- qtbot.keyClick(view, Qt.Key_Up)
+ qtbot.keyClick(view, Qt.Key.Key_Down)
+ qtbot.keyClick(view, Qt.Key.Key_Up)
qtbot.keyClicks(view, '5')
- qtbot.keyClick(view, Qt.Key_Down)
- qtbot.keyClick(view, Qt.Key_Space)
+ qtbot.keyClick(view, Qt.Key.Key_Down)
+ qtbot.keyClick(view, Qt.Key.Key_Space)
qtbot.keyClicks(view.focusWidget(), str(int(2 ** bit_exponent)))
- qtbot.keyClick(view.focusWidget(), Qt.Key_Down)
+ qtbot.keyClick(view.focusWidget(), Qt.Key.Key_Down)
MockQMessageBox.critical.assert_called_with(ANY, "Error", ANY)
assert MockQMessageBox.critical.call_count == idx
qtbot.keyClicks(view, '7')
- qtbot.keyClick(view, Qt.Key_Up)
+ qtbot.keyClick(view, Qt.Key.Key_Up)
qtbot.keyClicks(view, '6')
- qtbot.keyClick(view, Qt.Key_Down)
+ qtbot.keyClick(view, Qt.Key.Key_Down)
qtbot.wait(200)
dialog.accept()
qtbot.wait(500)
diff --git a/spyder/plugins/variableexplorer/widgets/tests/test_dataframeeditor.py b/spyder/plugins/variableexplorer/widgets/tests/test_dataframeeditor.py
index 4bc08156076..f5cc3d547e9 100644
--- a/spyder/plugins/variableexplorer/widgets/tests/test_dataframeeditor.py
+++ b/spyder/plugins/variableexplorer/widgets/tests/test_dataframeeditor.py
@@ -113,9 +113,9 @@ def test_dataframe_to_type(qtbot):
# Show context menu and select option `To bool`
view.menu.show()
- qtbot.keyPress(view.menu, Qt.Key_Down)
- qtbot.keyPress(view.menu, Qt.Key_Down)
- qtbot.keyPress(view.menu, Qt.Key_Return)
+ qtbot.keyPress(view.menu, Qt.Key.Key_Down)
+ qtbot.keyPress(view.menu, Qt.Key.Key_Down)
+ qtbot.keyPress(view.menu, Qt.Key.Key_Return)
# Check that changes where made from the editor
assert editor.btn_save_and_close.isEnabled()
@@ -139,11 +139,11 @@ def test_dataframe_simpleindex(qtbot):
editor = DataFrameEditor(None)
editor.setup_and_check(df)
header = editor.table_header.model()
- assert header.headerData(0, Qt.Horizontal,
+ assert header.headerData(0, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "0"
- assert header.headerData(1, Qt.Horizontal,
+ assert header.headerData(1, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "1"
- assert header.headerData(5, Qt.Horizontal,
+ assert header.headerData(5, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "5"
@@ -154,11 +154,11 @@ def test_dataframe_simpleindex_custom_columns():
editor = DataFrameEditor(None)
editor.setup_and_check(df)
header = editor.table_header.model()
- assert header.headerData(0, Qt.Horizontal,
+ assert header.headerData(0, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "a"
- assert header.headerData(1, Qt.Horizontal,
+ assert header.headerData(1, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "b"
- assert header.headerData(4, Qt.Horizontal,
+ assert header.headerData(4, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "e"
@@ -175,7 +175,7 @@ def test_dataframe_multiindex():
editor = DataFrameEditor(None)
editor.setup_and_check(df)
header = editor.table_header.model()
- assert header.headerData(0, Qt.Horizontal,
+ assert header.headerData(0, Qt.Orientation.Horizontal,
Qt.DisplayRole) == 0
assert data_header(header, 0, 0) == 'bar'
assert data_header(header, 1, 0) == 'one'
@@ -197,7 +197,7 @@ def test_header_bom():
editor = DataFrameEditor(None)
editor.setup_and_check(df)
header = editor.table_header.model()
- assert header.headerData(0, Qt.Horizontal,
+ assert header.headerData(0, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "Date (MMM-YY)"
@@ -209,17 +209,17 @@ def test_header_encoding():
editor = DataFrameEditor(None)
editor.setup_and_check(df)
header = editor.table_header.model()
- assert header.headerData(0, Qt.Horizontal,
+ assert header.headerData(0, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "Unnamed: 0"
- assert "Unieke_Idcode" in header.headerData(1, Qt.Horizontal,
+ assert "Unieke_Idcode" in header.headerData(1, Qt.Orientation.Horizontal,
Qt.DisplayRole)
- assert header.headerData(2, Qt.Horizontal,
+ assert header.headerData(2, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "a"
- assert header.headerData(3, Qt.Horizontal,
+ assert header.headerData(3, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "b"
- assert header.headerData(4, Qt.Horizontal,
+ assert header.headerData(4, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "c"
- assert header.headerData(5, Qt.Horizontal,
+ assert header.headerData(5, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "d"
@@ -394,7 +394,7 @@ def test_dataframeeditor_with_various_indexes():
assert dfm.rowCount() == 20
assert dfm.columnCount() == 1
header = editor.table_header.model()
- assert header.headerData(0, Qt.Horizontal,
+ assert header.headerData(0, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "0"
if rng_name == "Index":
@@ -538,19 +538,19 @@ def test_dataframeeditor_edit_overflow(qtbot, monkeypatch):
dialog.show()
view = dialog.dataTable
- qtbot.keyClick(view, Qt.Key_Right)
+ qtbot.keyClick(view, Qt.Key.Key_Right)
qtbot.keyClicks(view, '5')
- qtbot.keyClick(view, Qt.Key_Down)
- qtbot.keyClick(view, Qt.Key_Space)
- qtbot.keyClick(view.focusWidget(), Qt.Key_Backspace)
+ qtbot.keyClick(view, Qt.Key.Key_Down)
+ qtbot.keyClick(view, Qt.Key.Key_Space)
+ qtbot.keyClick(view.focusWidget(), Qt.Key.Key_Backspace)
qtbot.keyClicks(view.focusWidget(), str(int(2 ** bit_exponet)))
- qtbot.keyClick(view.focusWidget(), Qt.Key_Down)
+ qtbot.keyClick(view.focusWidget(), Qt.Key.Key_Down)
MockQMessageBox.critical.assert_called_with(ANY, "Error", ANY)
assert MockQMessageBox.critical.call_count == idx
qtbot.keyClicks(view, '7')
- qtbot.keyClick(view, Qt.Key_Up)
+ qtbot.keyClick(view, Qt.Key.Key_Up)
qtbot.keyClicks(view, '6')
- qtbot.keyClick(view, Qt.Key_Down)
+ qtbot.keyClick(view, Qt.Key.Key_Down)
qtbot.wait(200)
dialog.accept()
qtbot.wait(500)
@@ -615,17 +615,17 @@ def test_dataframeeditor_edit_complex(qtbot, monkeypatch):
dialog.show()
view = dialog.dataTable
- qtbot.keyClick(view, Qt.Key_Right)
- qtbot.keyClick(view, Qt.Key_Down)
- qtbot.keyClick(view, Qt.Key_Space)
- qtbot.keyClick(view.focusWidget(), Qt.Key_Backspace)
+ qtbot.keyClick(view, Qt.Key.Key_Right)
+ qtbot.keyClick(view, Qt.Key.Key_Down)
+ qtbot.keyClick(view, Qt.Key.Key_Space)
+ qtbot.keyClick(view.focusWidget(), Qt.Key.Key_Backspace)
qtbot.keyClicks(view.focusWidget(), "42")
- qtbot.keyClick(view.focusWidget(), Qt.Key_Down)
+ qtbot.keyClick(view.focusWidget(), Qt.Key.Key_Down)
MockQMessageBox.critical.assert_called_with(ANY, "Error", ANY)
assert MockQMessageBox.critical.call_count == count * 2 - 1
- qtbot.keyClick(view, Qt.Key_Down)
+ qtbot.keyClick(view, Qt.Key.Key_Down)
qtbot.keyClick(view, '1')
- qtbot.keyClick(view.focusWidget(), Qt.Key_Down)
+ qtbot.keyClick(view.focusWidget(), Qt.Key.Key_Down)
MockQMessageBox.critical.assert_called_with(
ANY, "Error", ("Editing dtype {0!s} not yet supported."
.format(type(test_df.iloc[1, 0]).__name__)))
@@ -688,12 +688,12 @@ def test_dataframeeditor_edit_bool(qtbot, monkeypatch):
dialog.show()
view = dialog.dataTable
- qtbot.keyClick(view, Qt.Key_Right)
+ qtbot.keyClick(view, Qt.Key.Key_Right)
for test_str in test_strs:
- qtbot.keyClick(view, Qt.Key_Space)
- qtbot.keyClick(view.focusWidget(), Qt.Key_Backspace)
+ qtbot.keyClick(view, Qt.Key.Key_Space)
+ qtbot.keyClick(view.focusWidget(), Qt.Key.Key_Backspace)
qtbot.keyClicks(view.focusWidget(), test_str)
- qtbot.keyClick(view.focusWidget(), Qt.Key_Down)
+ qtbot.keyClick(view.focusWidget(), Qt.Key.Key_Down)
assert not MockQMessageBox.critical.called
qtbot.wait(200)
dialog.accept()
@@ -721,7 +721,7 @@ def test_non_ascii_index():
header = editor.table_header.model()
dfm = editor.model()
- assert header.headerData(0, Qt.Horizontal,
+ assert header.headerData(0, Qt.Orientation.Horizontal,
Qt.DisplayRole) == "кодирование"
assert data_index(index, 0, 0) == 'пример'
assert data(dfm, 0, 0) == 'файла'
@@ -741,7 +741,7 @@ def test_no_convert_strings_to_unicode():
header = editor.table_header.model()
dfm = editor.model()
- assert header.headerData(0, Qt.Horizontal,
+ assert header.headerData(0, Qt.Orientation.Horizontal,
Qt.DisplayRole) != u"кодирование"
assert data_index(index, 0, 0) != u'пример'
assert data(dfm, 0, 0) != u'файла'
diff --git a/spyder/plugins/variableexplorer/widgets/tests/test_namespacebrowser.py b/spyder/plugins/variableexplorer/widgets/tests/test_namespacebrowser.py
index 7d761754026..b2a57be4662 100644
--- a/spyder/plugins/variableexplorer/widgets/tests/test_namespacebrowser.py
+++ b/spyder/plugins/variableexplorer/widgets/tests/test_namespacebrowser.py
@@ -95,7 +95,7 @@ def test_sort_by_column(namespacebrowser, qtbot):
with qtbot.waitSignal(header.sectionClicked):
browser.show()
- qtbot.mouseClick(header.viewport(), Qt.LeftButton, pos=QPoint(1, 1))
+ qtbot.mouseClick(header.viewport(), Qt.MouseButton.LeftButton, pos=QPoint(1, 1))
# Check sort effect
assert data_table(model, 2, 4) == [['b_variable', 'a_variable'],
@@ -145,7 +145,7 @@ def test_keys_sorted_and_sort_with_large_rows(namespacebrowser, qtbot):
# Sort
header = browser.editor.horizontalHeader()
with qtbot.waitSignal(header.sectionClicked):
- qtbot.mouseClick(header.viewport(), Qt.LeftButton, pos=QPoint(1, 1))
+ qtbot.mouseClick(header.viewport(), Qt.MouseButton.LeftButton, pos=QPoint(1, 1))
# Assert we loaded all data before performing the sort.
assert data(model, 0, 0) == 'i'
diff --git a/spyder/utils/qthelpers.py b/spyder/utils/qthelpers.py
index 70f81e03f54..ce09a391e45 100644
--- a/spyder/utils/qthelpers.py
+++ b/spyder/utils/qthelpers.py
@@ -246,7 +246,7 @@ def create_toolbutton(parent, text=None, shortcut=None, icon=None, tip=None,
if text is not None or tip is not None:
button.setToolTip(text if tip is None else tip)
if text_beside_icon:
- button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
+ button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
button.setAutoRaise(autoraise)
if triggered is not None:
button.clicked.connect(triggered)
@@ -296,7 +296,7 @@ def action2button(action, autoraise=True, text_beside_icon=False, parent=None,
button.setDefaultAction(action)
button.setAutoRaise(autoraise)
if text_beside_icon:
- button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
+ button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
if icon:
action.setIcon(icon)
return button
@@ -312,7 +312,7 @@ def toggle_actions(actions, enable):
def create_action(parent, text, shortcut=None, icon=None, tip=None,
toggled=None, triggered=None, data=None, menurole=None,
- context=Qt.WindowShortcut, option=None, section=None,
+ context=Qt.ShortcutContext.WindowShortcut, option=None, section=None,
id_=None, plugin=None, context_name=None,
register_action=False, overwrite=False):
"""Create a QAction"""
@@ -333,11 +333,11 @@ def create_action(parent, text, shortcut=None, icon=None, tip=None,
if menurole is not None:
action.setMenuRole(menurole)
- # Workround for Mac because setting context=Qt.WidgetShortcut
+ # Workround for Mac because setting context=Qt.ShortcutContext.WidgetShortcut
# there doesn't have any effect
if sys.platform == 'darwin':
action._shown_shortcut = None
- if context == Qt.WidgetShortcut:
+ if context == Qt.ShortcutContext.WidgetShortcut:
if shortcut is not None:
action._shown_shortcut = shortcut
else:
diff --git a/spyder/utils/syntaxhighlighters.py b/spyder/utils/syntaxhighlighters.py
index 40d2999eac0..f436f833dc8 100644
--- a/spyder/utils/syntaxhighlighters.py
+++ b/spyder/utils/syntaxhighlighters.py
@@ -383,7 +383,7 @@ def highlight_extras(self, text, offset=0):
self.highlight_patterns(text, offset=offset)
def rehighlight(self):
- QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
+ QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
QSyntaxHighlighter.rehighlight(self)
QApplication.restoreOverrideCursor()
diff --git a/spyder/utils/test.py b/spyder/utils/test.py
index e21f186ffd1..12b05849e94 100644
--- a/spyder/utils/test.py
+++ b/spyder/utils/test.py
@@ -21,4 +21,4 @@ def close_message_box(qtbot):
top_level_widgets = QApplication.topLevelWidgets()
for w in top_level_widgets:
if isinstance(w, QMessageBox):
- qtbot.keyClick(w, Qt.Key_Enter)
+ qtbot.keyClick(w, Qt.Key.Key_Enter)
diff --git a/spyder/widgets/about.py b/spyder/widgets/about.py
index 82a3aed03e0..5c12e914293 100644
--- a/spyder/widgets/about.py
+++ b/spyder/widgets/about.py
@@ -168,7 +168,7 @@ def __init__(self, parent):
for label in [self.label_overview, self.label_community,
self.label_legal]:
label.setWordWrap(True)
- label.setAlignment(Qt.AlignTop)
+ label.setAlignment(Qt.AlignmentFlag.AlignTop)
label.setOpenExternalLinks(True)
label.setTextInteractionFlags(Qt.TextBrowserInteraction)
label.setContentsMargins(15, 0, 25, 0)
@@ -178,7 +178,7 @@ def __init__(self, parent):
self.label_pic = QLabel(self)
self.label_pic.setPixmap(
pixmap.scaledToWidth(100, Qt.SmoothTransformation))
- self.label_pic.setAlignment(Qt.AlignBottom)
+ self.label_pic.setAlignment(Qt.AlignmentFlag.AlignBottom)
self.info = QLabel((
"""
item_identation:
# When hovering over results
- self.setCursor(Qt.PointingHandCursor)
+ self.setCursor(Qt.CursorShape.PointingHandCursor)
else:
# On every other element
- self.setCursor(Qt.ArrowCursor)
+ self.setCursor(Qt.CursorShape.ArrowCursor)
diff --git a/spyder/widgets/reporterror.py b/spyder/widgets/reporterror.py
index 56870a4f7d1..9678979ea7e 100644
--- a/spyder/widgets/reporterror.py
+++ b/spyder/widgets/reporterror.py
@@ -83,14 +83,14 @@ def keyPressEvent(self, event):
if cursor_position < self.header_end_pos:
self.restrict_cursor_position(self.header_end_pos, 'eof')
- elif key == Qt.Key_Backspace:
+ elif key == Qt.Key.Key_Backspace:
if self.has_selected_text():
self.remove_text()
elif self.header_end_pos == cursor_position:
return
else:
self.stdkey_backspace()
- elif key == Qt.Key_X and ctrl:
+ elif key == Qt.Key.Key_X and ctrl:
self.cut()
else:
super().keyPressEvent(event)
@@ -159,7 +159,7 @@ def __init__(self, parent=None, is_report=False):
project_url=__project_url__))
self.main_label.setOpenExternalLinks(True)
self.main_label.setWordWrap(True)
- self.main_label.setAlignment(Qt.AlignJustify)
+ self.main_label.setAlignment(Qt.AlignmentFlag.AlignJustify)
self.main_label.setStyleSheet('font-size: 12px;')
# Issue title
@@ -184,7 +184,7 @@ def __init__(self, parent=None, is_report=False):
"clear way to reproduce them will be closed.")
)
self.steps_text.setWordWrap(True)
- self.steps_text.setAlignment(Qt.AlignJustify)
+ self.steps_text.setAlignment(Qt.AlignmentFlag.AlignJustify)
self.steps_text.setStyleSheet('font-size: 12px;')
# Field to input the description of the problem
diff --git a/spyder/widgets/simplecodeeditor.py b/spyder/widgets/simplecodeeditor.py
index 986b9c8cae7..ac93e8965ec 100644
--- a/spyder/widgets/simplecodeeditor.py
+++ b/spyder/widgets/simplecodeeditor.py
@@ -395,14 +395,14 @@ def linenumberarea_paint_event(self, event):
else:
font.setWeight(font.Normal)
painter.setFont(font)
- painter.setPen(QColor(Qt.darkGray))
+ painter.setPen(QColor(Qt.GlobalColor.darkGray))
right_padding = self.linenumberarea._right_padding
painter.drawText(
0,
top,
self.linenumberarea.width() - right_padding,
self.fontMetrics().height(),
- Qt.AlignRight, str(number),
+ Qt.AlignmentFlag.AlignRight, str(number),
)
block = block.next()
diff --git a/spyder/widgets/switcher.py b/spyder/widgets/switcher.py
index 72bcc002a0f..deeb9522367 100644
--- a/spyder/widgets/switcher.py
+++ b/spyder/widgets/switcher.py
@@ -64,13 +64,13 @@ class KeyPressFilter(QObject):
def eventFilter(self, src, e):
"""Override Qt eventFilter."""
if e.type() == QEvent.KeyPress:
- if e.key() == Qt.Key_Up:
+ if e.key() == Qt.Key.Key_Up:
self.sig_up_key_pressed.emit()
return True
- elif e.key() == Qt.Key_Down:
+ elif e.key() == Qt.Key.Key_Down:
self.sig_down_key_pressed.emit()
return True
- elif (e.key() == Qt.Key_Return):
+ elif (e.key() == Qt.Key.Key_Return):
self.sig_enter_key_pressed.emit()
return True
return super(KeyPressFilter, self).eventFilter(src, e)
@@ -79,7 +79,7 @@ def eventFilter(self, src, e):
class SwitcherDelegate(HTMLDelegate):
"""
This delegate allows the list view of the switcher to look like it has
- the focus, even when its focus policy is set to Qt.NoFocus.
+ the focus, even when its focus policy is set to Qt.FocusPolicy.NoFocus.
"""
def paint(self, painter, option, index):
@@ -194,7 +194,7 @@ def __init__(self, parent=None, styles=_STYLES):
"""Separator Item represented as
."""
super(SwitcherSeparatorItem, self).__init__(parent=parent,
styles=styles)
- self.setFlags(Qt.NoItemFlags)
+ self.setFlags(Qt.ItemFlag.NoItemFlags)
self._set_rendered_text()
# --- Helpers
@@ -305,7 +305,7 @@ def __init__(self, parent=None, icon=None, title=None, description=None,
self._section_visible = True
# Setup
- self.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
+ self.setFlags(Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable)
if icon:
self.setIcon(icon)
@@ -573,7 +573,7 @@ def __init__(self, parent, help_text=None, item_styles=ITEM_STYLES,
self.edit.setPlaceholderText(help_text if help_text else '')
self.list.setMinimumWidth(self._MIN_WIDTH)
self.list.setItemDelegate(SwitcherDelegate(self))
- self.list.setFocusPolicy(Qt.NoFocus)
+ self.list.setFocusPolicy(Qt.FocusPolicy.NoFocus)
self.list.setSelectionBehavior(self.list.SelectItems)
self.list.setSelectionMode(self.list.SingleSelection)
self.list.setVerticalScrollMode(QAbstractItemView.ScrollPerItem)
diff --git a/spyder/widgets/tabs.py b/spyder/widgets/tabs.py
index c64d2cde3f8..ffba5449b10 100644
--- a/spyder/widgets/tabs.py
+++ b/spyder/widgets/tabs.py
@@ -77,7 +77,7 @@ def eventFilter(self, widget, event):
if ((event.type() == QEvent.MouseButtonPress and
not self.geometry().contains(event.globalPos())) or
(event.type() == QEvent.KeyPress and
- event.key() == Qt.Key_Escape)):
+ event.key() == Qt.Key.Key_Escape)):
# Exits editing
self.hide()
return True
@@ -157,7 +157,7 @@ def __init__(self, parent, ancestor, rename_tabs=False, split_char='',
def mousePressEvent(self, event):
"""Reimplement Qt method"""
- if event.button() == Qt.LeftButton:
+ if event.button() == Qt.MouseButton.LeftButton:
self.__drag_start_pos = QPoint(event.pos())
QTabBar.mousePressEvent(self, event)
@@ -167,7 +167,7 @@ def mouseMoveEvent(self, event):
# between plugins, but righit now it's breaking the regular
# Qt drag behavior for tabs, so we're commenting it for
# now
- #if event.buttons() == Qt.MouseButtons(Qt.LeftButton) and \
+ #if event.buttons() == Qt.MouseButtons(Qt.MouseButton.LeftButton) and \
# (event.pos() - self.__drag_start_pos).manhattanLength() > \
# QApplication.startDragDistance():
# drag = QDrag(self)
@@ -224,7 +224,7 @@ def dropEvent(self, event):
def mouseDoubleClickEvent(self, event):
"""Override Qt method to trigger the tab name editor."""
if self.rename_tabs is True and \
- event.buttons() == Qt.MouseButtons(Qt.LeftButton):
+ event.buttons() == Qt.MouseButtons(Qt.MouseButton.LeftButton):
# Tab index
index = self.tabAt(event.pos())
if index >= 0:
@@ -389,13 +389,13 @@ def keyPressEvent(self, event):
handled = False
if ctrl and self.count() > 0:
index = self.currentIndex()
- if key == Qt.Key_PageUp:
+ if key == Qt.Key.Key_PageUp:
if index > 0:
self.setCurrentIndex(index - 1)
else:
self.setCurrentIndex(self.count() - 1)
handled = True
- elif key == Qt.Key_PageDown:
+ elif key == Qt.Key.Key_PageDown:
if index < self.count() - 1:
self.setCurrentIndex(index + 1)
else:
diff --git a/spyder/widgets/tests/test_array_builder.py b/spyder/widgets/tests/test_array_builder.py
index 49eea0658e7..4100271e30b 100644
--- a/spyder/widgets/tests/test_array_builder.py
+++ b/spyder/widgets/tests/test_array_builder.py
@@ -48,7 +48,7 @@ def botarray(qtbot):
def test_array_inline_array(botinline):
qtbot, dialog, widget = botinline
qtbot.keyClicks(widget, '1 2 3 4 5 6')
- qtbot.keyPress(widget, Qt.Key_Return)
+ qtbot.keyPress(widget, Qt.Key.Key_Return)
value = dialog.text()
assert value == 'np.array([[1, 2, 3],\n [4, 5, 6]])'
@@ -56,7 +56,7 @@ def test_array_inline_array(botinline):
def test_array_inline_matrix(botinline):
qtbot, dialog, widget = botinline
qtbot.keyClicks(widget, '4 5 6 7 8 9')
- qtbot.keyPress(widget, Qt.Key_Return, modifier=Qt.ControlModifier)
+ qtbot.keyPress(widget, Qt.Key.Key_Return, modifier=Qt.ControlModifier)
value = dialog.text()
assert value == 'np.matrix([[4, 5, 6],\n [7, 8, 9]])'
@@ -64,7 +64,7 @@ def test_array_inline_matrix(botinline):
def test_array_inline_array_invalid(botinline):
qtbot, dialog, widget = botinline
qtbot.keyClicks(widget, '1 2 3 4 5 6 7')
- qtbot.keyPress(widget, Qt.Key_Return)
+ qtbot.keyPress(widget, Qt.Key.Key_Return)
dialog.update_warning()
assert not dialog.is_valid()
@@ -72,7 +72,7 @@ def test_array_inline_array_invalid(botinline):
def test_array_inline_1d_array(botinline):
qtbot, dialog, widget = botinline
qtbot.keyClicks(widget, '4 5 6')
- qtbot.keyPress(widget, Qt.Key_Return, modifier=Qt.ControlModifier)
+ qtbot.keyPress(widget, Qt.Key.Key_Return, modifier=Qt.ControlModifier)
value = dialog.text()
assert value == 'np.matrix([4, 5, 6])'
@@ -80,7 +80,7 @@ def test_array_inline_1d_array(botinline):
def test_array_inline_nan_array(botinline):
qtbot, dialog, widget = botinline
qtbot.keyClicks(widget, '4 nan 6 8 9')
- qtbot.keyPress(widget, Qt.Key_Return, modifier=Qt.ControlModifier)
+ qtbot.keyPress(widget, Qt.Key.Key_Return, modifier=Qt.ControlModifier)
value = dialog.text()
assert value == 'np.matrix([4, np.nan, 6, 8, 9])'
@@ -88,7 +88,7 @@ def test_array_inline_nan_array(botinline):
def test_array_inline_inf_array(botinline):
qtbot, dialog, widget = botinline
qtbot.keyClicks(widget, '4 inf 6 8 9')
- qtbot.keyPress(widget, Qt.Key_Return, modifier=Qt.ControlModifier)
+ qtbot.keyPress(widget, Qt.Key.Key_Return, modifier=Qt.ControlModifier)
value = dialog.text()
assert value == 'np.matrix([4, np.inf, 6, 8, 9])'
@@ -96,7 +96,7 @@ def test_array_inline_inf_array(botinline):
def test_array_inline_force_float_array(botinlinefloat):
qtbot, dialog, widget = botinlinefloat
qtbot.keyClicks(widget, '4 5 6 8 9')
- qtbot.keyPress(widget, Qt.Key_Return, modifier=Qt.ControlModifier)
+ qtbot.keyPress(widget, Qt.Key.Key_Return, modifier=Qt.ControlModifier)
value = dialog.text()
assert value == 'np.matrix([4.0, 5.0, 6.0, 8.0, 9.0])'
@@ -104,65 +104,65 @@ def test_array_inline_force_float_array(botinlinefloat):
def test_array_inline_force_float_error_array(botinlinefloat):
qtbot, dialog, widget = botinlinefloat
qtbot.keyClicks(widget, '4 5 6 a 9')
- qtbot.keyPress(widget, Qt.Key_Return, modifier=Qt.ControlModifier)
+ qtbot.keyPress(widget, Qt.Key.Key_Return, modifier=Qt.ControlModifier)
value = dialog.text()
assert value == 'np.matrix([4.0, 5.0, 6.0, a, 9.0])'
def test_array_table_array(botarray):
qtbot, dialog, widget = botarray
- qtbot.keyClick(widget, Qt.Key_1)
- qtbot.keyClick(widget, Qt.Key_Tab)
- qtbot.keyClick(widget, Qt.Key_2)
- qtbot.keyClick(widget, Qt.Key_Tab)
- qtbot.keyClick(widget, Qt.Key_Backtab) # Hack: in the tests the selected cell is wrong
- qtbot.keyClick(widget, Qt.Key_3)
- qtbot.keyClick(widget, Qt.Key_Tab)
- qtbot.keyClick(widget, Qt.Key_4)
- qtbot.keyClick(widget, Qt.Key_Tab)
- qtbot.keyClick(widget, Qt.Key_5)
- qtbot.keyClick(widget, Qt.Key_Tab)
- qtbot.keyClick(widget, Qt.Key_6)
- qtbot.keyClick(widget, Qt.Key_Tab) # Hack: in the tests the selected cell is wrong
- qtbot.keyClick(widget, Qt.Key_Return, modifier=Qt.NoModifier)
+ qtbot.keyClick(widget, Qt.Key.Key_1)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab)
+ qtbot.keyClick(widget, Qt.Key.Key_2)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab)
+ qtbot.keyClick(widget, Qt.Key.Key_Backtab) # Hack: in the tests the selected cell is wrong
+ qtbot.keyClick(widget, Qt.Key.Key_3)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab)
+ qtbot.keyClick(widget, Qt.Key.Key_4)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab)
+ qtbot.keyClick(widget, Qt.Key.Key_5)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab)
+ qtbot.keyClick(widget, Qt.Key.Key_6)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab) # Hack: in the tests the selected cell is wrong
+ qtbot.keyClick(widget, Qt.Key.Key_Return, modifier=Qt.KeyboardModifier.NoModifier)
value = dialog.text()
assert value == 'np.array([[1, 2, 3],\n [4, 5, 6]])'
def test_array_table_matrix(botarray): # analysis:ignore
qtbot, dialog, widget = botarray
- qtbot.keyClick(widget, Qt.Key_1)
- qtbot.keyClick(widget, Qt.Key_Tab)
- qtbot.keyClick(widget, Qt.Key_2)
- qtbot.keyClick(widget, Qt.Key_Tab)
- qtbot.keyClick(widget, Qt.Key_Backtab) # Hack: in the tests the selected cell is wrong
- qtbot.keyClick(widget, Qt.Key_3)
- qtbot.keyClick(widget, Qt.Key_Tab)
- qtbot.keyClick(widget, Qt.Key_4)
- qtbot.keyClick(widget, Qt.Key_Tab)
- qtbot.keyClick(widget, Qt.Key_5)
- qtbot.keyClick(widget, Qt.Key_Tab)
- qtbot.keyClick(widget, Qt.Key_6)
- qtbot.keyClick(widget, Qt.Key_Tab) # Hack: in the tests the selected cell is wrong
- qtbot.keyClick(widget, Qt.Key_Return, modifier=Qt.ControlModifier)
+ qtbot.keyClick(widget, Qt.Key.Key_1)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab)
+ qtbot.keyClick(widget, Qt.Key.Key_2)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab)
+ qtbot.keyClick(widget, Qt.Key.Key_Backtab) # Hack: in the tests the selected cell is wrong
+ qtbot.keyClick(widget, Qt.Key.Key_3)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab)
+ qtbot.keyClick(widget, Qt.Key.Key_4)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab)
+ qtbot.keyClick(widget, Qt.Key.Key_5)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab)
+ qtbot.keyClick(widget, Qt.Key.Key_6)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab) # Hack: in the tests the selected cell is wrong
+ qtbot.keyClick(widget, Qt.Key.Key_Return, modifier=Qt.ControlModifier)
value = dialog.text()
assert value == 'np.matrix([[1, 2, 3],\n [4, 5, 6]])'
def test_array_table_array_empty_items(botarray): # analysis:ignore
qtbot, dialog, widget = botarray
- qtbot.keyClick(widget, Qt.Key_Tab)
- qtbot.keyClick(widget, Qt.Key_2)
- qtbot.keyClick(widget, Qt.Key_Tab)
- qtbot.keyClick(widget, Qt.Key_Backtab) # Hack: in the tests the selected cell is wrong
- qtbot.keyClick(widget, Qt.Key_3)
- qtbot.keyClick(widget, Qt.Key_Tab)
- qtbot.keyClick(widget, Qt.Key_Tab)
- qtbot.keyClick(widget, Qt.Key_5)
- qtbot.keyClick(widget, Qt.Key_Tab)
- qtbot.keyClick(widget, Qt.Key_6)
- qtbot.keyClick(widget, Qt.Key_Tab) # Hack: in the tests the selected cell is wrong
- qtbot.keyClick(widget, Qt.Key_Return, modifier=Qt.NoModifier)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab)
+ qtbot.keyClick(widget, Qt.Key.Key_2)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab)
+ qtbot.keyClick(widget, Qt.Key.Key_Backtab) # Hack: in the tests the selected cell is wrong
+ qtbot.keyClick(widget, Qt.Key.Key_3)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab)
+ qtbot.keyClick(widget, Qt.Key.Key_5)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab)
+ qtbot.keyClick(widget, Qt.Key.Key_6)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab) # Hack: in the tests the selected cell is wrong
+ qtbot.keyClick(widget, Qt.Key.Key_Return, modifier=Qt.KeyboardModifier.NoModifier)
value = dialog.text()
assert value == 'np.array([[0, 2, 3],\n [0, 5, 6]])'
@@ -170,18 +170,18 @@ def test_array_table_array_empty_items(botarray): # analysis:ignore
def test_array_table_array_spaces_in_item(botarray): # analysis:ignore
qtbot, dialog, widget = botarray
qtbot.keyClicks(widget, ' ')
- qtbot.keyClick(widget, Qt.Key_Tab)
- qtbot.keyClick(widget, Qt.Key_2)
- qtbot.keyClick(widget, Qt.Key_Tab)
- qtbot.keyClick(widget, Qt.Key_Backtab)
- qtbot.keyClick(widget, Qt.Key_3)
- qtbot.keyClick(widget, Qt.Key_Tab)
- qtbot.keyClick(widget, Qt.Key_Tab)
- qtbot.keyClick(widget, Qt.Key_5)
- qtbot.keyClick(widget, Qt.Key_Tab)
- qtbot.keyClick(widget, Qt.Key_6)
- qtbot.keyClick(widget, Qt.Key_Tab) # Hack: in the tests the selected cell is wrong
- qtbot.keyClick(widget, Qt.Key_Return, modifier=Qt.NoModifier)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab)
+ qtbot.keyClick(widget, Qt.Key.Key_2)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab)
+ qtbot.keyClick(widget, Qt.Key.Key_Backtab)
+ qtbot.keyClick(widget, Qt.Key.Key_3)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab)
+ qtbot.keyClick(widget, Qt.Key.Key_5)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab)
+ qtbot.keyClick(widget, Qt.Key.Key_6)
+ qtbot.keyClick(widget, Qt.Key.Key_Tab) # Hack: in the tests the selected cell is wrong
+ qtbot.keyClick(widget, Qt.Key.Key_Return, modifier=Qt.KeyboardModifier.NoModifier)
value = dialog.text()
assert value == 'np.array([[0, 2, 3],\n [0, 5, 6]])'
@@ -189,6 +189,6 @@ def test_array_table_array_spaces_in_item(botarray): # analysis:ignore
@pytest.mark.skipif(sys.platform == 'darwin', reason="It fails on macOS")
def test_array_table_matrix_empty(botarray): # analysis:ignore
qtbot, dialog, widget = botarray
- qtbot.keyClick(widget, Qt.Key_Return, modifier=Qt.NoModifier)
+ qtbot.keyClick(widget, Qt.Key.Key_Return, modifier=Qt.KeyboardModifier.NoModifier)
value = dialog.text()
assert value == ''
diff --git a/spyder/widgets/tests/test_collectioneditor.py b/spyder/widgets/tests/test_collectioneditor.py
index 056191f48ec..73c2053a1b1 100644
--- a/spyder/widgets/tests/test_collectioneditor.py
+++ b/spyder/widgets/tests/test_collectioneditor.py
@@ -758,16 +758,16 @@ def test_edit_nonsettable_objects(qtbot, nonsettable_objects_data):
indicies = [view.source_model.get_index_from_key(key) for key in keys]
for _ in range(3):
- qtbot.keyClick(view, Qt.Key_Right)
+ qtbot.keyClick(view, Qt.Key.Key_Right)
last_row = -1
rows_to_test = [index.row() for index in indicies]
for row in rows_to_test:
for _ in range(row - last_row - 1):
- qtbot.keyClick(view, Qt.Key_Down)
- qtbot.keyClick(view, Qt.Key_Space)
- qtbot.keyClick(view.focusWidget(), Qt.Key_Backspace)
+ qtbot.keyClick(view, Qt.Key.Key_Down)
+ qtbot.keyClick(view, Qt.Key.Key_Space)
+ qtbot.keyClick(view.focusWidget(), Qt.Key.Key_Backspace)
qtbot.keyClicks(view.focusWidget(), "2")
- qtbot.keyClick(view.focusWidget(), Qt.Key_Down)
+ qtbot.keyClick(view.focusWidget(), Qt.Key.Key_Down)
last_row = row
qtbot.wait(100)
@@ -834,7 +834,7 @@ def test_collectionseditor_when_clicking_on_header_and_large_rows(qtbot):
view = editor.widget.editor
header = view.horizontalHeader()
with qtbot.waitSignal(header.sectionClicked, timeout=200):
- qtbot.mouseClick(header.viewport(), Qt.LeftButton, pos=QPoint(1, 1))
+ qtbot.mouseClick(header.viewport(), Qt.MouseButton.LeftButton, pos=QPoint(1, 1))
# Assert data was sorted correctly.
assert data(view.model, 0, 0) == 9999
diff --git a/spyder/widgets/tests/test_findreplace.py b/spyder/widgets/tests/test_findreplace.py
index 9f93f703db7..86c426580ea 100644
--- a/spyder/widgets/tests/test_findreplace.py
+++ b/spyder/widgets/tests/test_findreplace.py
@@ -123,7 +123,7 @@ def test_messages_action(findreplace_editor, qtbot):
# Assert messages_action is not visible when there's no text
edit.selectAll()
- qtbot.keyClick(edit, Qt.Key_Delete)
+ qtbot.keyClick(edit, Qt.Key.Key_Delete)
assert not findreplace.messages_action.isVisible()
# Search with wrong regexp
@@ -160,7 +160,7 @@ def test_replace_text_button(findreplace_editor, qtbot):
assert findreplace.replace_text_button.isChecked()
# Hide with the close button and show find row only
- qtbot.mouseClick(findreplace.close_button, Qt.LeftButton)
+ qtbot.mouseClick(findreplace.close_button, Qt.MouseButton.LeftButton)
findreplace.show(hide_replace=True)
qtbot.wait(500)
assert not findreplace.replace_text_button.isChecked()
@@ -203,7 +203,7 @@ def test_update_matches(findreplace_editor, qtbot):
# Check we don't update matches when the widget is hidden
findreplace.hide()
qtbot.wait(500)
- qtbot.keyClick(editor, Qt.Key_Return)
+ qtbot.keyClick(editor, Qt.Key.Key_Return)
qtbot.keyClicks(editor, 'foo')
qtbot.wait(500)
assert findreplace.number_matches_text.text() == '3 matches'
diff --git a/spyder/widgets/tests/test_reporterror.py b/spyder/widgets/tests/test_reporterror.py
index 67647d410bc..4490fd39e95 100644
--- a/spyder/widgets/tests/test_reporterror.py
+++ b/spyder/widgets/tests/test_reporterror.py
@@ -69,17 +69,17 @@ def test_dialog(error_dialog, qtbot):
# Assert backspace works as expected
qtbot.keyClicks(dlg.input_description, desc_text)
- qtbot.keyPress(dlg.input_description, Qt.Key_Backspace)
+ qtbot.keyPress(dlg.input_description, Qt.Key.Key_Backspace)
assert not dlg.submit_btn.isEnabled()
dlg.input_description.selectAll()
- qtbot.keyPress(dlg.input_description, Qt.Key_Backspace)
+ qtbot.keyPress(dlg.input_description, Qt.Key.Key_Backspace)
assert dlg.input_description.toPlainText() == dlg.input_description.header
ini_pos = dlg.input_description.get_position('sof')
dlg.input_description.set_cursor_position(ini_pos)
dlg.input_description.set_cursor_position('eol')
- qtbot.keyPress(dlg.input_description, Qt.Key_Backspace)
+ qtbot.keyPress(dlg.input_description, Qt.Key.Key_Backspace)
assert dlg.input_description.toPlainText() == dlg.input_description.header
# Assert chars label works as expected
diff --git a/spyder/widgets/tests/test_switcher.py b/spyder/widgets/tests/test_switcher.py
index 55a014fd7d6..949ec1826d9 100644
--- a/spyder/widgets/tests/test_switcher.py
+++ b/spyder/widgets/tests/test_switcher.py
@@ -64,7 +64,7 @@ def test_switcher(dlg_switcher, qtbot):
assert dlg_switcher.isVisible()
# Test that the dialog is closed properly on Esc keypress
- qtbot.keyClick(dlg_switcher.edit, Qt.Key_Escape)
+ qtbot.keyClick(dlg_switcher.edit, Qt.Key.Key_Escape)
assert not dlg_switcher.isVisible()
diff --git a/spyder/widgets/waitingspinner.py b/spyder/widgets/waitingspinner.py
index 463c676a3a5..05be4c0a576 100644
--- a/spyder/widgets/waitingspinner.py
+++ b/spyder/widgets/waitingspinner.py
@@ -51,7 +51,7 @@ def __init__(self, parent, centerOnParent=True,
self._disableParentWhenSpinning = disableParentWhenSpinning
# WAS IN initialize()
- self._color = QColor(Qt.black)
+ self._color = QColor(Qt.GlobalColor.black)
self._roundness = 100.0
self._minimumTrailOpacity = 3.14159265358979323846
self._trailFadePercentage = 80.0
@@ -81,7 +81,7 @@ def paintEvent(self, QPaintEvent):
self.updatePosition()
painter = QPainter(self)
- painter.fillRect(self.rect(), Qt.transparent)
+ painter.fillRect(self.rect(), Qt.GlobalColor.transparent)
painter.setRenderHint(QPainter.Antialiasing, True)
if self._currentCounter >= self._numberOfLines:
@@ -199,7 +199,7 @@ def isSpinning(self):
def setRoundness(self, roundness):
self._roundness = max(0.0, min(100.0, roundness))
- def setColor(self, color=Qt.black):
+ def setColor(self, color=Qt.GlobalColor.black):
self._color = QColor(color)
def setRevolutionsPerSecond(self, revolutionsPerSecond):