Unable to add new annotation description in raw browser

@amyt @richard
I think I could fix the problem with the inaccessible IPython-Console after raw.plot(block=True) in this new Pull-Request.

@amyt
I could not resolve the problem with raw.plot(block=False) and the “Add Description”-dialogue though.
The modified modal-dialog-example below shows that this is a problem between Spyder and modal dialogs from Qt when the event loop is not run inside the script itself (not calling app.exec() inside the script and letting “%gui qt” and Spyder handle it).

%gui qt
import sys
from PyQt5.QtWidgets import QApplication, QInputDialog, QMainWindow, \
    QPushButton, QVBoxLayout, QWidget


class TestWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        widget = QWidget()
        layout = QVBoxLayout()
        test_bt = QPushButton('Test modal dialog')
        test_bt.clicked.connect(self.open_modal_dialog)
        layout.addWidget(test_bt)
        widget.setLayout(layout)
        self.setCentralWidget(widget)
        self.show()

    def open_modal_dialog(self):
        QInputDialog.getText(self, 'Modal Dialog', 'This is a modal dialog!')

test_win = TestWindow()

Maybe Spyder is somehow forcing the focus on the Qt-Console inside Spyder, because if you try the same from IPython outside Spyder, the IPython-console stays inaccessible as long as a modal dialog is opened.

@cbrnr @GuillaumeFavelier Do you know something of this interaction between modal dialogs and qt-console?

The MNEQtBrowser won’t be shown in the “Plots”-Tab since it supports only matplotlib plots.
I hope not being able to fully use raw.plot(block=False) inside Spyder is not too much of an obstacle for your work at the moment.

No, but since Spyder is also based on PyQt/PySide, I can imagine that they might tweak things that could cause exotic issues like this. I don’t use Spyder myself so I didn’t really follow all the details in this thread, but this seems like it would be interesting for the Spyder devs?

Absolutely won’t be too much of an obstacle :slight_smile: Very happy to be able to carry on with my analysis and learning MNE. Thank you for your help everyone. It’s amazing that people are so responsive.

1 Like

Not sure if you have tried this (and if this even works), but the %gui qt5 magic command is supposed to handle event loop integration: Built-in magic commands — IPython 8.3.0 documentation

We already suggested this above, and unfortunately it didn’t fix all of the issues :frowning:

OK, I didn’t see that.