On Thu, May 30, 2013 at 9:30 AM, Terry Brown <[email protected]>wrote:

> At last I remember.  leo_color_database in leoColor.py is a dict whose
> keys
> > are color names and whose values are Qt color values (strings, starting
> > with '#'.
>
> I you think it's necessary, that dict could be injected into the new
> stylesheet macro expansion system.  Currently I think the stylesheet
> uses 2-3 named colors, so it's no big deal to define them directly in
> the stylesheet, in a comment which is processed by the new stylesheet
> macro expansion system.
>

We definitely should support expanded colors somehow.

Rev 5800 does the following:

1. Restores the bg keyword arg to sc.createIconButton, in its original
place, that is, before the "kind" keyword arg.

This is compatible with your code, because it always uses kind=kind.  This
change ensures that no scripts or plugins can be broken by recent changes
to createIconButton.

2. Adds the following code to createIconButton::

        if not bg.startswith('#'):
            d = leoColor.leo_color_database
            bg2 = d.get(bg.lower())
            if not bg2:
                print('bad color? %s' % bg)
            bg = bg2
        if bg:
            try:
                b.button.setStyleSheet("QPushButton{background-color: %s}"
% (bg))
            except Exception:
                # g.es_exception()
                pass # Might not be a valid color.

As a result, the following Leo script now works::

    from leo.plugins.mod_scripting import scriptingController
    sc = scriptingController(c)
    sc.createIconButton(p.h,command="",statusLine=p.h,bg='MistyRose1')

I hope we are not working at cross purposes here.  I like the general idea
of using stylesheets to specify defaults, but I think stylesheets aren't
dynamic enough for scripting.  I plan no further changes to mod_scripting.
Please feel free to make further changes as you will.

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 http://groups.google.com/group/leo-editor?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to