Create or reuse a singleton ReplaceDialog instance. The singleton dialog saves user entries and preferences across instances. Args: text: Text widget containing the text to be searched.
(text, insert_tags=None)
| 12 | |
| 13 | |
| 14 | def replace(text, insert_tags=None): |
| 15 | """Create or reuse a singleton ReplaceDialog instance. |
| 16 | |
| 17 | The singleton dialog saves user entries and preferences |
| 18 | across instances. |
| 19 | |
| 20 | Args: |
| 21 | text: Text widget containing the text to be searched. |
| 22 | """ |
| 23 | root = text._root() |
| 24 | engine = searchengine.get(root) |
| 25 | if not hasattr(engine, "_replacedialog"): |
| 26 | engine._replacedialog = ReplaceDialog(root, engine) |
| 27 | dialog = engine._replacedialog |
| 28 | searchphrase = text.get("sel.first", "sel.last") |
| 29 | dialog.open(text, searchphrase, insert_tags=insert_tags) |
| 30 | |
| 31 | |
| 32 | class ReplaceDialog(SearchDialogBase): |
searching dependent graphs…