Skip to content

Commit

Permalink
Merge pull request #409 from ccordoba12/issue-408
Browse files Browse the repository at this point in the history
Replace QApp by qApp
  • Loading branch information
ccordoba12 committed Feb 9, 2020
2 parents 4e08946 + 9e753a0 commit e3917f1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -4,7 +4,7 @@ sudo: false

env:
global:
- CONDA_DEPENDENCIES='pyqt qtpy traitlets ipython_genutils jupyter_core jupyter_client pygments ipykernel pytest pytest-cov mock'
- CONDA_DEPENDENCIES='pyqt qtpy traitlets ipython_genutils jupyter_core jupyter_client pygments ipykernel pytest pytest-cov mock flaky'
- PIP_DEPENDENCIES='coveralls pytest-xvfb pytest-qt'

matrix:
Expand Down
4 changes: 2 additions & 2 deletions qtconsole/call_tip_widget.py
Expand Up @@ -155,7 +155,7 @@ def show_tip(self, tip):
# location based trying to minimize the area that goes off-screen.
padding = 3 # Distance in pixels between cursor bounds and tip box.
cursor_rect = text_edit.cursorRect(cursor)
screen_rect = QtWidgets.QApp.desktop().screenGeometry(text_edit)
screen_rect = QtWidgets.qApp.desktop().screenGeometry(text_edit)
point = text_edit.mapToGlobal(cursor_rect.bottomRight())
point.setY(point.y() + padding)
tip_height = self.size().height()
Expand Down Expand Up @@ -240,7 +240,7 @@ def _leave_event_hide(self):
# If Enter events always came after Leave events, we wouldn't need
# this check. But on Mac OS, it sometimes happens the other way
# around when the tooltip is created.
QtWidgets.QApp.topLevelAt(QtGui.QCursor.pos()) != self):
QtWidgets.qApp.topLevelAt(QtGui.QCursor.pos()) != self):
self._hide_timer.start(300, self)

def _format_tooltip(self, doc):
Expand Down
16 changes: 8 additions & 8 deletions qtconsole/console_widget.py
Expand Up @@ -420,7 +420,7 @@ def eventFilter(self, obj, event):
new_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress,
self._ctrl_down_remap[key],
QtCore.Qt.NoModifier)
QtWidgets.QApp.sendEvent(obj, new_event)
QtWidgets.qApp.sendEvent(obj, new_event)
return True

elif obj == self._control:
Expand Down Expand Up @@ -1326,13 +1326,13 @@ def callback(complete, indent):
new_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress,
QtCore.Qt.Key_Return,
QtCore.Qt.NoModifier)
QtWidgets.QApp.sendEvent(self._control, new_event)
QtWidgets.qApp.sendEvent(self._control, new_event)
intercepted = True
else:
new_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress,
QtCore.Qt.Key_Delete,
QtCore.Qt.NoModifier)
QtWidgets.QApp.sendEvent(self._control, new_event)
QtWidgets.qApp.sendEvent(self._control, new_event)
intercepted = True

#------ Alt modifier ---------------------------------------------------
Expand Down Expand Up @@ -1565,30 +1565,30 @@ def _event_filter_page_keypress(self, event):
new_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress,
QtCore.Qt.Key_PageDown,
QtCore.Qt.NoModifier)
QtWidgets.QApp.sendEvent(self._page_control, new_event)
QtWidgets.qApp.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)
QtWidgets.QApp.sendEvent(self._page_control, new_event)
QtWidgets.qApp.sendEvent(self._page_control, new_event)
return True

# vi/less -like key bindings
elif key == QtCore.Qt.Key_J:
new_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress,
QtCore.Qt.Key_Down,
QtCore.Qt.NoModifier)
QtWidgets.QApp.sendEvent(self._page_control, new_event)
QtWidgets.qApp.sendEvent(self._page_control, new_event)
return True

# vi/less -like key bindings
elif key == QtCore.Qt.Key_K:
new_event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress,
QtCore.Qt.Key_Up,
QtCore.Qt.NoModifier)
QtWidgets.QApp.sendEvent(self._page_control, new_event)
QtWidgets.qApp.sendEvent(self._page_control, new_event)
return True

return False
Expand Down Expand Up @@ -2092,7 +2092,7 @@ def _insert_plain_text(self, cursor, text, flush=False):
cursor.StartOfLine, cursor.KeepAnchor)

elif act.action == 'beep':
QtWidgets.QApp.beep()
QtWidgets.qApp.beep()

elif act.action == 'backspace':
if not cursor.atBlockStart():
Expand Down
16 changes: 11 additions & 5 deletions qtconsole/tests/test_00_console_widget.py
@@ -1,17 +1,20 @@
import sys
import unittest

from flaky import flaky
import pytest
from qtpy import QtCore, QtGui, QtWidgets
from qtpy.QtTest import QTest

from qtconsole.console_widget import ConsoleWidget
from qtconsole.qtconsoleapp import JupyterQtConsoleApp
from . import no_display

if sys.version[0] == '2': # Python 2
from IPython.core.inputsplitter import InputSplitter as TransformerManager
else:
from IPython.core.inputtransformer2 import TransformerManager

from qtpy import QtCore, QtGui, QtWidgets
from qtconsole.console_widget import ConsoleWidget
from qtconsole.qtconsoleapp import JupyterQtConsoleApp
from . import no_display
from qtpy.QtTest import QTest

SHELL_TIMEOUT = 20000

Expand All @@ -29,6 +32,7 @@ def qtconsole(qtbot):
return console


@flaky(max_runs=3)
@pytest.mark.parametrize(
"debug", [True, False])
def test_scroll(qtconsole, qtbot, debug):
Expand Down Expand Up @@ -135,6 +139,7 @@ def run_line(line, block=True):
assert scroll_bar.value() > prev_position


@flaky(max_runs=3)
def test_input(qtconsole, qtbot):
"""
Test input function
Expand Down Expand Up @@ -170,6 +175,7 @@ def test_input(qtconsole, qtbot):
assert 'name: test\ntest' in control.toPlainText()


@flaky(max_runs=3)
def test_debug(qtconsole, qtbot):
"""
Make sure the cursor works while debugging
Expand Down

0 comments on commit e3917f1

Please sign in to comment.