This is an Engineering Notebook post. Feel free to ignore it. Part of me wants to rush right in on demo.py. However, this post will be pre-writing for the official docs <https://github.com/leo-editor/leo-editor/blob/master/leo/doc/demo.md>, so I may as well talk out loud.
*Classes and configuration* Yesterday's work created the Label class, a subclass of QLabel. Useful and simple. At present, this is the foundation for demo.callout and demo.subtitle. But this is poor. Configuration involves setting various keyword args in the Demo ctor. Instead, top-level scripts can define zero or more subclass of Label. Call these *callout classes*. These *per-demonstration* classes are the natural place to set the appearance of arbitrarily many *kinds* of callouts. This is *much* more flexible than baking in just two kinds of callouts into the Demo class. Doh! *Demo scripts* Originally, demo.py required all demo scripts to be a tree. The Demo class traverses this tree, creating *demo.script_list*. This won't go away. You could call it the most Leonine way. As of yesterday, the top-level demo can use a list of strings instead of a tree of node. This is also convenient. Two more ways appeared when I awoke this morning. 1. A *single string*, containing some reasonable delimiter. The Demo class will split this string into the script list. This may actually be the simplest thing that could possibly work. 2. A list of *Script objects*. As I think about this now, I don't see any real benefits. Script objects would just be wrappers for strings. No matter how we define demo.script_list, the Demo class will eventually exec it. Script objects provide no additional security. *Summary* It's amazing how much writing helps me clarify issues. Several things have just become clear. 1. Defining callouts as subclasses of Label is *much* more general (and simpler) than using fixed configuration keyword args in Demo.__init__. 2. demo.parse_string(s, delim=some_default) will create demo.script_list from a single string. This is likely to be simpler than representing the script_list as a tree. 3. The Demo class eventually exec's all demo strings. This is a security issue that can't be cured by defining Script classes. The exec has access to all user-defined classes. The 40 minutes writing this ENB post have been a great investment. 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.
