Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The app is written in HTML and is running using webkit and Quickly. The opacity can be changed using Glade.

I want to add a slider functionality in HTML which will change the title of the HTML document according to the opacity.

How to code the main app/ so that it will change the opacity dynamically according to the HTML document title?

share|improve this question
up vote 1 down vote accepted

You can use the set_opacity() method of GtkWindow object.

It will expect a float, so you should do a type conversion before.

except ValueError:
    pass  # Do something with the invalid value here.
share|improve this answer

Glade doesn't add any magic function or properties to the widgets, it just uses what GTK provides.

Looking at the docs, I can find that GtkWidget has a set_opacity() method. This only works since 3.8 and is the preferred way to do it. If your code also has to support GTK 3.6 and lower, use GtkWindow.set_opacity()

share|improve this answer
I have found a command self.set_opacity() which works statically. When I dynamically code self.set_opacity(title) python says Traceback (most recent call last): File "/home/archisman/up-clock/up_clock/", line 86, in title_changed self.set_opacity("title") TypeError: Must be number, not str – Archisman Panigrahi Mar 14 '14 at 11:27
Why are you using "title" as a parameter for set_opacity?. It expects a number between 0 and 1, where 0 is invisible and 1 totally opaque. – Javier Rivera Mar 17 '14 at 7:56
@JavierRivera So that I could change the document title using a slider in HTML like this. And Python would set opacity same as the title. But since it isn't supporting string variables I had to do all this.… – Archisman Panigrahi Mar 18 '14 at 7:06
OMG!!!!... you know, you can convert between types ;). Just do self.set_opacity(float(title)). But please note that if title has a value than can't be converted to a float the program will break. – Javier Rivera Mar 18 '14 at 8:01
That piece of code is a stab to the programmmer's heart :-). Just convert it to a float like Javier said and catch the ValueError exception. – Timo Mar 18 '14 at 9:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.