12 from Ui_HelpDialog import Ui_HelpDialog |
12 from Ui_HelpDialog import Ui_HelpDialog |
13 from SearchDialog import SearchDialog |
13 from SearchDialog import SearchDialog |
14 |
14 |
15 import Globals |
15 import Globals |
16 |
16 |
|
17 |
17 class HelpDialog(QDialog, Ui_HelpDialog): |
18 class HelpDialog(QDialog, Ui_HelpDialog): |
18 """ |
19 """ |
19 Class implementing a dialog to show help about rope. |
20 Class implementing a dialog to show help about rope. |
20 """ |
21 """ |
21 def __init__(self, title, helpfile, parent = None): |
22 def __init__(self, title, helpfile, parent=None): |
22 """ |
23 """ |
23 Constructor |
24 Constructor |
24 |
25 |
25 @param title window title (string) |
26 @param title window title (string) |
26 @param helpfile filename of the helpfile (string) |
27 @param helpfile filename of the helpfile (string) |
37 self.helpEdit.setFontFamily("Lucida Console") |
38 self.helpEdit.setFontFamily("Lucida Console") |
38 else: |
39 else: |
39 self.helpEdit.setFontFamily("Monospace") |
40 self.helpEdit.setFontFamily("Monospace") |
40 |
41 |
41 try: |
42 try: |
42 f = open(helpfile, "r", encoding = "utf-8") |
43 f = open(helpfile, "r", encoding="utf-8") |
43 txt = f.read() |
44 txt = f.read() |
44 f.close() |
45 f.close() |
45 self.helpEdit.setPlainText(txt) |
46 self.helpEdit.setPlainText(txt) |
46 except IOError as err: |
47 except IOError as err: |
47 self.helpEdit.setPlainText( |
48 self.helpEdit.setPlainText( |
78 findFlags |= QTextDocument.FindWholeWords |
79 findFlags |= QTextDocument.FindWholeWords |
79 if backwards: |
80 if backwards: |
80 findFlags |= QTextDocument.FindBackward |
81 findFlags |= QTextDocument.FindBackward |
81 |
82 |
82 if cur.hasSelection(): |
83 if cur.hasSelection(): |
83 cur.setPosition(backwards and cur.anchor() or cur.position(), |
84 cur.setPosition(backwards and cur.anchor() or cur.position(), |
84 QTextCursor.MoveAnchor) |
85 QTextCursor.MoveAnchor) |
85 newCur = doc.find(txt, cur, findFlags) |
86 newCur = doc.find(txt, cur, findFlags) |
86 if newCur.isNull(): |
87 if newCur.isNull(): |
87 return False |
88 return False |
88 else: |
89 else: |