Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

silx view: Stopped displaying a message box for each error #3955

Merged
merged 2 commits into from
Oct 25, 2023

Conversation

t20100
Copy link
Member

@t20100 t20100 commented Oct 23, 2023

This PR makes silx view using a dedicated sys.excepthook to stop showing a QMessageBox for each exception.
Instead, it keeps logging the error and adds a "permanent" widget in the application status bar.

I hesitated with a temporary error message, but since the effects of an exception might make the application unstable afterwards, I decided to use a permanent message instead.

closes #3880

Screenshot from 2023-10-23 17-08-34

@t20100 t20100 added this to the 2.0.0 milestone Oct 23, 2023
@t20100 t20100 requested a review from vallsv October 23, 2023 15:12
@t20100 t20100 marked this pull request as draft October 24, 2023 07:16
@vallsv
Copy link
Contributor

vallsv commented Oct 24, 2023

You better to use a system icon for the icon.

Maybe if you replace the QLabel by a QPushButton, or a QToolButton. Or just create a small panel.

Maybe a button is anyway better, because you could reset the error if you click, and display it in a message box (to allow to copy paste it)

BTW not totally related, but i have logging window in Flint, maybe that something i could backport here.
Capture d%u2019écran de 2022-12-09 17-28-51

@vallsv
Copy link
Contributor

vallsv commented Oct 24, 2023

What i have used in flint instead of a QLabel is a QToolBar+ a single QAction (maybe not the best idea).

And here is the stuff i use to display the message in flint

    def __doubleClicked(self, index):
        record = self.__logWidget.recordFromIndex(index)
        if record is None:
            return

        # _logger.error("%s %s %s", type_, value, ''.join(traceback.format_tb(trace)))
        msg = qt.QMessageBox()
        msg.setWindowTitle("Logging record")

        if record.levelno > logging.WARNING:
            icon = qt.QMessageBox.Critical
        elif record.levelno > logging.INFO:
            icon = qt.QMessageBox.Warning
        else:
            icon = qt.QMessageBox.Information
        msg.setIcon(icon)

        try:
            message = record.getMessage()
        except Exception as e:
            # In case there is a wrong call of logging methods
            message = "Error in logs: " + e.args[0]
            message += "\nMessage: %r" % record.msg
            message += "\nArguments: %s" % record.args

        cuts = message.split("\n", 1)

        msg.setInformativeText(cuts[0])
        msg.setDetailedText(message)
        msg.raise_()
        msg.exec()

@t20100
Copy link
Member Author

t20100 commented Oct 24, 2023

Having a widget to display logging info would be nice in silx, if you find the time to move it here!

I reworked the way to display the error: It is now a toolbutton in the right corner of the menu bar which show a message box with the last exception when clicked.

Ready for review.

@t20100 t20100 marked this pull request as ready for review October 24, 2023 15:55
@t20100 t20100 requested a review from vallsv October 24, 2023 15:56
@t20100 t20100 merged commit 3666465 into silx-kit:main Oct 25, 2023
7 of 8 checks passed
@t20100 t20100 deleted the silx-view-no-error-messagebox branch October 25, 2023 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

silx view: remove popups for unhandled exceptions
2 participants