How do I create a toolbar with buttons that look like the ones in Software Center?

I've figured out out to set the style of the toolbar to Gtk.STYLE_CLASS_PRIMARY_TOOLBAR, but I want to set the buttons to look like page selectors instead of regular buttons.

I'm trying to create a bunch of buttons to switch between pages according to this specification: Contributor Console


  • Quick tip: Software Center is also written in Python/GTK3. Head over to their Launchpad page, grab the source and have a look at how they do it. – Timo Nov 23 '12 at 11:36
  • I've looked through the code and can't figure out what it does to make the buttons look like that. – iBelieve Nov 23 '12 at 13:40

The Global Pane in the code sets up the toolbar: softwarecenter/ui/gtk3/panes/globalpane.py

While the ViewSwitcher class draws the buttons on the Global Pane: softwarecenter/ui/gtk3/panes/viewswitcher.py

Each button is added as a custom SectionSelector class composed of a custom cairo drawn Gtk.Image (SymbolicIcon class), a label and an optional drop down channel selector. You should check out the viewswitcher.py file for more detail.

The SectionSelector class is in: softwarecenter/ui/gtk3/widgets/buttons.py and is itself built from a custom class in that file.

Luckily, most of the code looks very reusable so you can probably copy and use them in your software.

  • Great! Thanks for your answer, I'll try it later. – iBelieve Nov 26 '12 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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