Friday, September 29, 2023
 Popular · Latest · Hot · Upcoming
rated 0 times [  19] [ 0]  / answers: 1 / hits: 2856  / 1 Year 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()
toolbutton = Gtk.ToolButton(stock_id=Gtk.STOCK_NEW)

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


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()

applying that context to the question example results in this:


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

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

Location: Anguilla
Member since Sun, Jan 29, 2023
9 Months ago
uccase questions
Sat, Apr 22, 23, 05:59, 6 Months ago
Sat, Jul 30, 22, 14:46, 1 Year ago
Sat, Dec 25, 21, 16:52, 2 Years ago
Thu, Nov 24, 22, 22:05, 11 Months ago