On Mon, Mar 12, 2018 at 7:43 AM, Chris George <[email protected]> wrote:
So I guess I am really just looking for the easiest way to close and
> reopen a Leo file programmatically.
>
> An @button would save a lot of time.
>
On Windows I use the following @command node to open a test file. Change
it to @button if you like:
@command F5-open-test @key=F5
@language python
import os
c.saveAll()
os.system("start cmd /c t")
# Open ~/test.leo in a separate console.
# t.bat ends with exit so the console closes when I close Leo.
leo_dir = g.os_path_finalize_join(g.app.loadDir, '..', '..')
os.chdir(leo_dir)
# print(g.os_path_abspath(os.curdir))
Imo this is even better than closing and opening your dev .leo file.
F5 saves any work in your dev .leo file and opens the *small* test file in
a console. The console closes automatically when you close the test file.
Your big dev .leo file never needs to be reloaded. os.curdir remains
unchanged.
Note: the call to os.system happens after c.saveAll completes fully, so you
are always testing the latest code. If, say, there is a syntax error in
your python code, loading the test file would fail, but your dev .leo file
remains running.
On Linux, use something like this:
os.system('x-terminal-emulator -e python <path-to>launchLeo.py
<path-to>test.leo')
HTH.
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.