Stylesheets and plasma widgets

alanm me at alandmoore.com
Thu Sep 10 21:19:36 CEST 2009


I have a plasmoid (in Python) which uses Plasma.ToolButton widgets.  I would 
like to allow the user to override the default style (taken from the plasma 
theme) of the buttons (for instance, to change font/size/colors).

I have two problems/misunderstandings I need help with here:
 - First, I find that if I give the button a stylesheet using setStyleSheet(), 
the style sheet in use is totally blown away.  Is there any way to just append 
or override settings of the stylesheet in use?  I tried this:
button = Plasma.PushButton()
bstyle = button.styleSheet()
bstyle += "font: 8pt;"
button.setStyleSheet(bstyle)

But that doesn't work -- it sets the font size alright, but the other style 
aspects set by the plasma theme (font, color, etc) are gone.  Interestingly, 
button.styleSheet() returns an empty string.

 - Second, if I must override the entire style sheet for the button, how do I 
set the hover style of the button?  setStyle() on the button object only seems 
to allow me to set the default style for the button.  I would assume I could 
do this in the "master" stylesheet if I could access it, but I'm not sure how 
to get at it or change it.  Is there an object I can call styleSheet() on to 
get the "master" stylesheet in use?

Or... are style sheets just the wrong way to go about this?


More information about the Plasma-devel mailing list