GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Aug 25, 2016 4:42 pm

All times are UTC

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: GTK Fade with state change
PostPosted: Thu Aug 30, 2012 8:05 pm 

Joined: Fri Jul 13, 2012 3:25 pm
Posts: 2
Using GTK 3.4.2 on ubuntu with python.

Hi Guys,

I've looked everywhere for this:

I have a horizontal box with 2 buttons, 2 labels and a seperator that I want to fade out to transparent. At first I thought I could just remove a class from a StyleContext and add another to achieve the effect (like you would do with javascript / CSS). Something like


But that didn't work out, because the box was not redrawn.

My next approach was (or better is) to set the box to insensitive. I can then style the box with #status_bar_box:insensitive { ... } (CSS) but there is no transition (note that I added the transition to both, normal and :insensitive).

self.status_bar.set_state_flags(Gtk.StateFlags.INSENSITIVE, True)

Has anyone solved this? Or is there a simple ""cairo"" approach that I could choose? (I would prefer CSS, it's so clean ... )

Many Thanks,


 Post subject: Re: GTK Fade with state change
PostPosted: Sat Sep 01, 2012 5:38 am 
GTK+ Guru

Joined: Fri Mar 25, 2011 5:16 pm
Posts: 181
Location: USA
I don't know Python at all only C but I'll try to help.

When you say "fade out to transparent" and "transition" I assume your talking about when your cursor hovers over any part of the horizontal box.
You can't apply CSS to a container widget. They don't have any gtk_widget_class_install_style_property() in their main files. (compare gtkgrid.c to gtkbutton.c)

There's an example for a transparent window in the GTK+ tests folder (testgtk.c) called alpha window.

I'm not sure how you would get an animated fade but you could use a drawing area in place of the horizontal box. Then detect when the mouse enters using gtk_widget_add_events() and modify the drawing area and widgets inside to be transparent.

Other than that you might have to wait for gtk+3.6 to be release in October with Ubuntu Quantal . It's supposed to have better support for transitions and CSS animations. Again that's GTK+ I'm not sure about Python.
(Link below says 3.4 but also talks about 3.6 and has a video)

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group