17 |
17 |
18 class HelpDialog(QDialog, Ui_HelpDialog): |
18 class HelpDialog(QDialog, Ui_HelpDialog): |
19 """ |
19 """ |
20 Class implementing a dialog to show help about rope. |
20 Class implementing a dialog to show help about rope. |
21 """ |
21 """ |
|
22 |
22 def __init__(self, title, helpfile, parent=None): |
23 def __init__(self, title, helpfile, parent=None): |
23 """ |
24 """ |
24 Constructor |
25 Constructor |
25 |
26 |
26 @param title window title |
27 @param title window title |
27 @type str |
28 @type str |
28 @param helpfile filename of the helpfile |
29 @param helpfile filename of the helpfile |
29 @type str |
30 @type str |
30 @param parent reference to the parent widget |
31 @param parent reference to the parent widget |
31 @type QWidget |
32 @type QWidget |
32 """ |
33 """ |
33 QDialog.__init__(self, parent) |
34 QDialog.__init__(self, parent) |
34 self.setupUi(self) |
35 self.setupUi(self) |
35 self.setWindowFlags(Qt.WindowType.Window) |
36 self.setWindowFlags(Qt.WindowType.Window) |
36 |
37 |
37 if Globals.isWindowsPlatform(): |
38 if Globals.isWindowsPlatform(): |
38 self.helpEdit.setFontFamily("Lucida Console") |
39 self.helpEdit.setFontFamily("Lucida Console") |
39 else: |
40 else: |
40 self.helpEdit.setFontFamily("Monospace") |
41 self.helpEdit.setFontFamily("Monospace") |
41 |
42 |
42 try: |
43 try: |
43 with open(helpfile, "r", encoding="utf-8") as f: |
44 with open(helpfile, "r", encoding="utf-8") as f: |
44 txt = f.read() |
45 txt = f.read() |
45 self.helpEdit.setPlainText(txt) |
46 self.helpEdit.setPlainText(txt) |
46 except OSError as err: |
47 except OSError as err: |
47 self.helpEdit.setPlainText( |
48 self.helpEdit.setPlainText( |
48 self.tr("Could not read file {0}.\nReason: {1}") |
49 self.tr("Could not read file {0}.\nReason: {1}").format( |
49 .format(helpfile, str(err))) |
50 helpfile, str(err) |
50 |
51 ) |
|
52 ) |
|
53 |
51 self.searchWidget.attachTextEdit(self.helpEdit) |
54 self.searchWidget.attachTextEdit(self.helpEdit) |