Friday, April 26, 2024
 Popular · Latest · Hot · Upcoming
19
rated 0 times [  19] [ 0]  / answers: 1 / hits: 2978  / 2 Years ago, sun, september 18, 2022, 10:43:10

In some of the ubuntu programs (ubuntu control panel, system settings), but not e.g. in banshee, the top part of the window contains elements in dark tone (with the Ambience theme). But I cant find a standard widget that does this automatically.



Are these colors all set by hand (instead of standard widget+theme)? And if they are set by hand, where do they come from in the theme (what are the parameters in gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &color)) ?



EDIT: It does not seem to be a simple Gtk.Toolbar. If I run the following code:



from gi.repository import Gtk
window = Gtk.Window()
window.set_default_size(200, -1)
window.connect("destroy", lambda q: Gtk.main_quit())
toolbar = Gtk.Toolbar()
window.add(toolbar)
toolbutton = Gtk.ToolButton(stock_id=Gtk.STOCK_NEW)
toolbar.add(toolbutton)
window.show_all()
Gtk.main()


I get a window like this:
enter image description here
which does not have a dark tone for the toolbar.



EDIT2: Although the 'toolbar with special context' answer by j-johan-edwards is true in most of the programs, it is not the case in the ubuntuone-control-panel. This program has a GtkVBox which can include any range of widgets (unlike a toolbar). I'm still unable to determine how the gtk-theme knows how to paint that part of the window.
enter image description here



But anyway: for now a toolbar is enough for me...


More From » python

 Answers
4

Do you mean these?



GTK3 Toolbar



They're just Gtk.Toolbars. The reason some applications like Banshee don't use them is that they haven't yet ported to GTK+ 3, and received the new theming capabilities that enable toolbars like that.



To port your own Python application to GTK+ 3, you need to use PyGObject instead of PyGTK. As of 12.04, Quickly will generate PyGObject projects by default.



You also need to add primary-toolbar to the toolbar style context. Like so:



toolbar = Gtk.Toolbar()
context = toolbar.get_style_context()
context.add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)


applying that context to the question example results in this:



demo


[#42936] Tuesday, September 20, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
uccase

Total Points: 473
Total Questions: 100
Total Answers: 110

Location: Anguilla
Member since Sun, Jan 29, 2023
1 Year ago
uccase questions
;