Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

Thanks.

share|improve this question
    
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
add comment

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer
    
Great! Thanks for your answer, I'll try it later. –  iBelieve Nov 26 '12 at 20:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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