On Thu, 30 May 2013 10:55:14 -0500
"Edward K. Ream" <[email protected]> wrote:

> 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.

I don't think anything in the shared code base would have been broken,
but I guess this protects local scripts.

> 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.

I think this is all ok as long as it all works together.  I didn't
think it was worth restoring the bg parameter because I think it's not
dynamic enough for scripting ;-)  It only sets the background color,
which is very limited, compared to

b = sc.createIconButton(p.h,command="",statusLine=p.h)
b.button.setStylesheet("""QPushButton {
    background: #123;
    foreground: #fda;
    border: solid red 3px;
}
QPushButton:hover {
    border-color: green;
}
""")

etc. etc.

Also with dark and light themes in existence it's not really safe to
specify only the background color - setting only one of foreground /
background is considered bad styling style.

But if nothing's broken right now, let's leave it that way.

Cheers -Terry

-- 
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