3

I spent few hours searching on google and I gave up now...

I need to change background for popup menu in my app. It set to whatever system default theme is... and I need this to be set to Radiance for all the time.

any ideas how to achieve this?

Here is how it looks now and this need to be light color

10
  • I don't think that property is properly exposed in any pygtk methods. So using normal methods, you can't Feb 24, 2013 at 0:46
  • I can change toolbar style so why should be a problem changing menu style ?
    – Majster-pl
    Feb 24, 2013 at 0:47
  • There's not a method for it: pygtk.org/docs/pygtk/class-gtkmenu.html Feb 24, 2013 at 0:54
  • 1
    Congrats, you just proved your question to be off-topic, already answered, and a duplicate all at once. Feb 24, 2013 at 1:33
  • 2
    @Majster-pl: I think AskUbuntu is a perfectly reasonable place to ask a programming question like this, especially as Canonical is trying very hard to encourage a new developer community. Please hang in there
    – Ian B.
    Feb 24, 2013 at 13:54

1 Answer 1

4

I theme my popup windows like so:

#Use Css themes
css = Gtk.CssProvider()
css.load_from_data("""
        .popup {background-color: rgba(0,0,0,0); border: 0px rgba(255,255,255,0);  border-radius: 14px; border-width: 0;  }
    """ 
Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), css,
        Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

#Get popup parent and set rgba visual so I can do transparency
pwindow=self.popup.get_parent()
screen=pwindow.get_screen()
pwindow.set_visual(screen.get_rgba_visual())

#Give popups the popup CSS class
self.popup.get_style_context().add_class('popup')

I also use cairo to draw the popup window and give it a nice texture. To do that I just connect its 'draw' signal to a call back.

I would look at the Radiance Gtk theme to find out what the background color is and use that for the background-color css setting. You can find it in /usr/share/themes/Radiance/Gtk-3.0/gtk.css. If you don't need transparency, then skip the pwindow stuff above and just add the style_context to your popup.

3
  • This is what I was looking for ;-) Thank you so much @Ian B. I will only need to tweak it a little bit for my purpose
    – Majster-pl
    Feb 24, 2013 at 14:33
  • @Ian - Isn't that pygi not pygtk? Feb 24, 2013 at 15:14
  • @AbrahamVanHelpsing, Yes- but I have found that many people (especially beginners) are using the term pygtk interchangeably. If he is developing an app using quickly, more than likely he's really using pygi. If not, he should migrate anyway
    – Ian B.
    Feb 24, 2013 at 23:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .