diff options
| author | Mattias Andrée <maandree@operamail.com> | 2013-09-11 13:01:07 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@operamail.com> | 2013-09-11 13:01:07 +0200 |
| commit | 82b7deb229d0bfa56d25de457c12640914f4821d (patch) | |
| tree | 1675c65ff0d132651acf19a25efc2740344f444d | |
| parent | can do terminal initialisation (diff) | |
| download | pytagomacs-82b7deb229d0bfa56d25de457c12640914f4821d.tar.gz pytagomacs-82b7deb229d0bfa56d25de457c12640914f4821d.tar.bz2 pytagomacs-82b7deb229d0bfa56d25de457c12640914f4821d.tar.xz | |
only run editor if the module is executed, not imported
Signed-off-by: Mattias Andrée <maandree@operamail.com>
| -rw-r--r-- | src/editor.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/editor.py b/src/editor.py index 3ae23b7..dee7c91 100644 --- a/src/editor.py +++ b/src/editor.py @@ -673,14 +673,15 @@ class TextArea(): edited = True -def phonysaver(): - return True -area = None -try: - area = TextArea(('a be se de e eff ge hå i ji kå ell emm enn o pe ku ärr ess te u ve dubbel-ve eks y säta å ä ö').split(' '), {}, 6, 4, 40, 10) - area.initialise(True) - area.run(phonysaver) -finally: - if area is not None: - area.close() +if __name__ == '__main__': # For testing + def phonysaver(): + return True + area = None + try: + area = TextArea(('a be se de e eff ge hå i ji kå ell emm enn o pe ku ärr ess te u ve dubbel-ve eks y säta å ä ö').split(' '), {}, 6, 4, 40, 10) + area.initialise(True) + area.run(phonysaver) + finally: + if area is not None: + area.close() |
