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