RefactoringRope/HelpDialog.py

Tue, 10 Dec 2024 15:49:01 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 10 Dec 2024 15:49:01 +0100
branch
eric7
changeset 426
7592a1c052e8
parent 420
fa31c3a0df1d
permissions
-rw-r--r--

Updated copyright for 2025.

# -*- coding: utf-8 -*-

# Copyright (c) 2010 - 2025 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing a dialog to show help about rope.
"""

from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import QDialog

from .Ui_HelpDialog import Ui_HelpDialog

try:
    from eric7.SystemUtilities.OSUtilities import isWindowsPlatform
except ImportError:
    # backward compatibility for eric < 23.1
    from eric7.Globals import isWindowsPlatform


class HelpDialog(QDialog, Ui_HelpDialog):
    """
    Class implementing a dialog to show help about rope.
    """

    def __init__(self, title, helpfile, parent=None):
        """
        Constructor

        @param title window title
        @type str
        @param helpfile filename of the helpfile
        @type str
        @param parent reference to the parent widget
        @type QWidget
        """
        QDialog.__init__(self, parent)
        self.setupUi(self)
        self.setWindowFlags(Qt.WindowType.Window)

        if isWindowsPlatform():
            self.helpEdit.setFontFamily("Lucida Console")
        else:
            self.helpEdit.setFontFamily("Monospace")

        try:
            with open(helpfile, "r", encoding="utf-8") as f:
                txt = f.read()
            self.helpEdit.setPlainText(txt)
        except OSError as err:
            self.helpEdit.setPlainText(
                self.tr("Could not read file {0}.\nReason: {1}").format(
                    helpfile, str(err)
                )
            )

        self.searchWidget.attachTextEdit(self.helpEdit)

eric ide

mercurial