On Tuesday, February 7, 2017 at 5:34:20 AM UTC-6, Edward K. Ream wrote:
>
> Rev 37ca40b36 contains yesterday's work on demo.py. The plugin works, but
> when I awoke I saw that there are four or five ways to make the plugin
> easier to use.
>
The ENB post eliminated most confusion. This post will be pre-writing for
revised docs.
Rev 7911ff7 is a big step forward. Everything is class based. Each class
deals with its own configuration setting, defaulting to the base-class
settings as usual. No more bozo config args to the Demo class. This new
approach rules any function-based scheme.
The only complication is making classes aware of each other. This requires
two easy steps:
1. Define wrappers in the top-level script that bind demo to the demo
instance:
def callout(text, demo=demo, **keys):
demo.Callout(text, **keys)
def title(text, demo=demo, **keys):
demo.Title(text, **keys)
2. Call demo.register_name to make names known to the demo instance. For
example:
d = demo.Demo(c)
d.register_name('callout', callout)
d.register_name('title', title)
Putting this all together, here is my top-level testing code (in an
@command node):
<< imports >>
# Uses imp.reload for TDD.
@others
# Defines the wrappers shown above, and script_string.
d = demo.Demo(c, trace=False)
# Creates the g.app.demo instance.
d.register_name('callout', callout)
d.register_name('title', title)
# Binds callout and title so they can be used in demo scripts.
d.delete_widgets()
# Easier than over-riding demo.setup.
d.start(script_string=script_string)
# script_string is a *single* string.
# Lines starting with '###' split script_string into separate demo
scripts.
This is super flexible. Two items remain on the to-do list.
1. demo.script_setup/teardown methods. These would execute code
before/after each script.
For example, this would eliminate the need to call demo.delete_widgets a
the start of each demo script:
def script_setup(demo):
demo.delete_widgets()
This probably should *not *be the default.
2. I would like a *single* key binding to do (in effect) both demo-start
and demo-next commands. It's surprisingly irritating to use two keys.
Expect both these improvements today.
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.