pygtk tree view expanders custom color

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

pygtk tree view expanders custom color

Giuseppe Penone
Hi,
in my application users can control the foreground and background color of the treeview.
The problem is that the expanders arrows color does not change and so it happens that is not visible.
Does anybody know if it is possible to override the gtk theme in use about this?
Cheers,
Giuseppe.

_______________________________________________
pygtk mailing list   [hidden email]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
Reply | Threaded
Open this post in threaded view
|

Re: pygtk tree view expanders custom color

Timo List
Op 08-09-13 21:27, Giuseppe Penone schreef:
> Hi,
> in my application users can control the foreground and background
> color of the treeview.
> The problem is that the expanders arrows color does not change and so
> it happens that is not visible.
> Does anybody know if it is possible to override the gtk theme in use
> about this?

You can change it like any other part or widget in GTK3. Just add the
following to your stylesheet:

.expander {
     color: rgb(32, 74, 135);
}


Or be more precise about which treeview and do:

GtkTreeView#MyCustomView .expander {
     color: rgb(32, 74, 135);
}

And in your code:
     treeview.set_name("MyCustomView")

Cheers,
Timo

> Cheers,
> Giuseppe.
>
>
> _______________________________________________
> pygtk mailing list   [hidden email]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/

_______________________________________________
pygtk mailing list   [hidden email]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
Reply | Threaded
Open this post in threaded view
|

Re: pygtk tree view expanders custom color

Giuseppe Penone
Hello Timo,
thank you very much for the reply,
unfortunately I cannot upgrade to GTK3 because my app (http://www.giuspen.com/cherrytree/)
has to fully work on microsoft windows and I see that pyGI or whatever is the name of python-GTK3
still doesn't work on windows.
It's sad to say but if GTK people will not spend time to support cross-platform rather than just adding functionalities
more and more people will leave it for Qt and python-Qt.
Cheers,
Giuseppe.


On Mon, Sep 9, 2013 at 1:00 PM, Timo <[hidden email]> wrote:
Op <a href="tel:08-09-13%2021" value="+3908091321" target="_blank">08-09-13 21:27, Giuseppe Penone schreef:

Hi,
in my application users can control the foreground and background color of the treeview.
The problem is that the expanders arrows color does not change and so it happens that is not visible.
Does anybody know if it is possible to override the gtk theme in use about this?

You can change it like any other part or widget in GTK3. Just add the following to your stylesheet:

.expander {
    color: rgb(32, 74, 135);
}


Or be more precise about which treeview and do:

GtkTreeView#MyCustomView .expander {
    color: rgb(32, 74, 135);
}

And in your code:
    treeview.set_name("MyCustomView")

Cheers,
Timo

Cheers,
Giuseppe.


_______________________________________________
pygtk mailing list   [hidden email]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

_______________________________________________
pygtk mailing list   [hidden email]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


_______________________________________________
pygtk mailing list   [hidden email]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
Reply | Threaded
Open this post in threaded view
|

Re: pygtk tree view expanders custom color

Timo List
Op 09-09-13 13:36, Giuseppe Penone schreef:

> Hello Timo,
> thank you very much for the reply,
> unfortunately I cannot upgrade to GTK3 because my app
> (http://www.giuspen.com/cherrytree/)
> has to fully work on microsoft windows and I see that pyGI or whatever
> is the name of python-GTK3
> still doesn't work on windows.
> It's sad to say but if GTK people will not spend time to support
> cross-platform rather than just adding functionalities
> more and more people will leave it for Qt and python-Qt.
I completely agree Giuseppe. My cross-platform applications also still
use GTK2 for that same reason.

For a Linux only project I'm using GTK3 and I really like it (like the
CSS theming for example), but I would probably think twice again in the
future when starting a new large project. Which is a real shame if you
look at how awesome GTK is.

I can't help you with GTK2 theming though, sorry.

Timo


> Cheers,
> Giuseppe.
>
>
> On Mon, Sep 9, 2013 at 1:00 PM, Timo <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Op 08-09-13 21 <tel:08-09-13%2021>:27, Giuseppe Penone schreef:
>
>         Hi,
>         in my application users can control the foreground and
>         background color of the treeview.
>         The problem is that the expanders arrows color does not change
>         and so it happens that is not visible.
>         Does anybody know if it is possible to override the gtk theme
>         in use about this?
>
>
>     You can change it like any other part or widget in GTK3. Just add
>     the following to your stylesheet:
>
>     .expander {
>         color: rgb(32, 74, 135);
>     }
>
>
>     Or be more precise about which treeview and do:
>
>     GtkTreeView#MyCustomView .expander {
>         color: rgb(32, 74, 135);
>     }
>
>     And in your code:
>         treeview.set_name("MyCustomView")
>
>     Cheers,
>     Timo
>
>         Cheers,
>         Giuseppe.
>
>
>         _______________________________________________
>         pygtk mailing list [hidden email] <mailto:[hidden email]>
>         http://www.daa.com.au/mailman/listinfo/pygtk
>         Read the PyGTK FAQ: http://faq.pygtk.org/
>
>
>     _______________________________________________
>     pygtk mailing list [hidden email] <mailto:[hidden email]>
>     http://www.daa.com.au/mailman/listinfo/pygtk
>     Read the PyGTK FAQ: http://faq.pygtk.org/
>
>

_______________________________________________
pygtk mailing list   [hidden email]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
Reply | Threaded
Open this post in threaded view
|

Re: pygtk tree view expanders custom color

Giuseppe Penone

On Mon, Sep 9, 2013 at 7:30 PM, Timo <[hidden email]> wrote:
For a Linux only project I'm using GTK3 and I really like it (like the CSS theming for example), but I would probably think twice again in the future when starting a new large project. Which is a real shame if you look at how awesome GTK is.

I'm also using GTK (mm) 3 in a linux only project but at my company we're dropping GTK (that I personally introduced) because we absolutely need to reuse the code in other cross platform projects.

GTK3 is like a beautiful car that performs great when it's sunny but cannot travel when it's rainy, only good for people that can afford two cars.

Cheers,
Giuseppe.



_______________________________________________
pygtk mailing list   [hidden email]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
Reply | Threaded
Open this post in threaded view
|

Re: pygtk tree view expanders custom color

Adam Tauno Williams
In reply to this post by Giuseppe Penone
On Sun, 2013-09-08 at 21:27 +0200, Giuseppe Penone wrote:

> in my application users can control the foreground and background
> color of the treeview
> The problem is that the expanders arrows color does not change and so
> it happens that is not visible.
> Does anybody know if it is possible to override the gtk theme in use
> about this?

I do not know how to override the theme, but you can set any color you
want using a custom cell renderer.


...    def render_task_id(column, cell, model, titer, store):
        if model[titer][0].objectid:
            cell.set_property('text', str(model[titer][0].objectid))
        else:
            cell.set_property('text', '-')
        TaskList.apply_cell_effects(titer, cell, model,
store.configuration['PRESENTATION'])
...

    def apply_cell_effects(titer, cell, model, prefs):

        def get_stroke(value):
            if value == 0: return pango.WEIGHT_ULTRALIGHT
            elif value == 1: return pango.WEIGHT_LIGHT
            elif value == 2: return pango.WEIGHT_NORMAL
            elif value == 3: return pango.WEIGHT_BOLD
            elif value == 4: return pango.WEIGHT_ULTRABOLD
            else: return pango.WEIGHT_HEAVY

        # Line-out completed and rejected tasks

        if model[titer][0]['status'] in ('25_done', '02_rejected'):
            cell.set_property('strikethrough', True)
        else:
            cell.set_property('strikethrough', False)

        # Background color & font [driven by priority]

        if (model[titer][0]['priority'] == 5):
            color = gtk.gdk.color_parse(prefs['VERYLOW']['COLOR'])
            font = prefs['VERYLOW']['FONT']
        elif (model[titer][0]['priority'] == 4):
            color = gtk.gdk.color_parse(prefs['LOW']['COLOR'])
            font = pango.FontDescription(prefs['LOW']['FONT'])
        elif (model[titer][0]['priority'] == 3):
            color = gtk.gdk.color_parse(prefs['AVERAGE']['COLOR'])
            font = pango.FontDescription(prefs['AVERAGE']['FONT'])
        elif (model[titer][0]['priority'] == 2):
            color = gtk.gdk.color_parse(prefs['HIGH']['COLOR'])
            font = pango.FontDescription(prefs['HIGH']['FONT'])
        elif (model[titer][0]['priority'] == 1):
            color = gtk.gdk.color_parse(prefs['VERYHIGH']['COLOR'])
            font = pango.FontDescription(prefs['VERYHIGH']['FONT'])
        cell.set_property('cell-background', color)
        cell.set_property('font', font)

        # Foreground Stroke & Color [driven by curreny]

        if ('OVERDUE' in model[titer][0]['FLAGS']):
            stroke = get_stroke(prefs['OVERDUE']['STROKE'])
            color = gtk.gdk.color_parse(prefs['OVERDUE']['COLOR'])
        elif ('UPCOMING' in model[titer][0]['FLAGS']):
            stroke = get_stroke(prefs['UPCOMING']['STROKE'])
            color = gtk.gdk.color_parse(prefs['UPCOMING']['COLOR'])
        else:
            stroke = get_stroke(prefs['CURRENT']['STROKE'])
            color = gtk.gdk.color_parse(prefs['CURRENT']['COLOR'])
        cell.set_property('weight-set', True)
        cell.set_property('weight', stroke)
        cell.set_property('foreground', color)



--
Adam Tauno Williams <mailto:[hidden email]> GPG D95ED383
Systems Administrator, Python Developer, LPI / NCLA

_______________________________________________
pygtk mailing list   [hidden email]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
Reply | Threaded
Open this post in threaded view
|

Re: pygtk tree view expanders custom color

Giuseppe Penone
Hi and thanks for reply, I already control the background and foreground of the cells,
what I cannot control is the color of the expander arrows (the ones that when clicked show/hide the children rows)
Giuseppe.


On Tue, Dec 3, 2013 at 8:47 PM, Adam Tauno Williams <[hidden email]> wrote:
On Sun, 2013-09-08 at 21:27 +0200, Giuseppe Penone wrote:

> in my application users can control the foreground and background
> color of the treeview
> The problem is that the expanders arrows color does not change and so
> it happens that is not visible.
> Does anybody know if it is possible to override the gtk theme in use
> about this?

I do not know how to override the theme, but you can set any color you
want using a custom cell renderer.


...    def render_task_id(column, cell, model, titer, store):
        if model[titer][0].objectid:
            cell.set_property('text', str(model[titer][0].objectid))
        else:
            cell.set_property('text', '-')
        TaskList.apply_cell_effects(titer, cell, model,
store.configuration['PRESENTATION'])
...

    def apply_cell_effects(titer, cell, model, prefs):

        def get_stroke(value):
            if value == 0: return pango.WEIGHT_ULTRALIGHT
            elif value == 1: return pango.WEIGHT_LIGHT
            elif value == 2: return pango.WEIGHT_NORMAL
            elif value == 3: return pango.WEIGHT_BOLD
            elif value == 4: return pango.WEIGHT_ULTRABOLD
            else: return pango.WEIGHT_HEAVY

        # Line-out completed and rejected tasks

        if model[titer][0]['status'] in ('25_done', '02_rejected'):
            cell.set_property('strikethrough', True)
        else:
            cell.set_property('strikethrough', False)

        # Background color & font [driven by priority]

        if (model[titer][0]['priority'] == 5):
            color = gtk.gdk.color_parse(prefs['VERYLOW']['COLOR'])
            font = prefs['VERYLOW']['FONT']
        elif (model[titer][0]['priority'] == 4):
            color = gtk.gdk.color_parse(prefs['LOW']['COLOR'])
            font = pango.FontDescription(prefs['LOW']['FONT'])
        elif (model[titer][0]['priority'] == 3):
            color = gtk.gdk.color_parse(prefs['AVERAGE']['COLOR'])
            font = pango.FontDescription(prefs['AVERAGE']['FONT'])
        elif (model[titer][0]['priority'] == 2):
            color = gtk.gdk.color_parse(prefs['HIGH']['COLOR'])
            font = pango.FontDescription(prefs['HIGH']['FONT'])
        elif (model[titer][0]['priority'] == 1):
            color = gtk.gdk.color_parse(prefs['VERYHIGH']['COLOR'])
            font = pango.FontDescription(prefs['VERYHIGH']['FONT'])
        cell.set_property('cell-background', color)
        cell.set_property('font', font)

        # Foreground Stroke & Color [driven by curreny]

        if ('OVERDUE' in model[titer][0]['FLAGS']):
            stroke = get_stroke(prefs['OVERDUE']['STROKE'])
            color = gtk.gdk.color_parse(prefs['OVERDUE']['COLOR'])
        elif ('UPCOMING' in model[titer][0]['FLAGS']):
            stroke = get_stroke(prefs['UPCOMING']['STROKE'])
            color = gtk.gdk.color_parse(prefs['UPCOMING']['COLOR'])
        else:
            stroke = get_stroke(prefs['CURRENT']['STROKE'])
            color = gtk.gdk.color_parse(prefs['CURRENT']['COLOR'])
        cell.set_property('weight-set', True)
        cell.set_property('weight', stroke)
        cell.set_property('foreground', color)



--
Adam Tauno Williams <mailto:[hidden email]> GPG D95ED383
Systems Administrator, Python Developer, LPI / NCLA

_______________________________________________
pygtk mailing list   [hidden email]


_______________________________________________
pygtk mailing list   [hidden email]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/