[pygtk] Treeview: How to set Font Size in Column Titles?

darethehair darethehair at gmail.com
Thu Feb 5 07:22:12 WST 2009

John Finlay wrote:
> darethehair wrote:
>> Hello all!
>>  From the PyGTK docs, I know the various ways to change the font size 
>> in 'treeview' columns/cells, but they appear to only work on the 
>> column *data*, and not the column *titles*.  The effect of this is 
>> that I can make my fonts (for example) smaller and get more rows in 
>> the screen, but the title font sizes do not change, and so it looks 
>> silly.
>> Any tips?
> Try using a custom widget for the header using 
> TreeViewColumn.set_widget()
> JOhn
Thanks for the tip!  This appears to be the technique to set the column 
*title* font style/size:

                self.note_type_column = gtk.TreeViewColumn('')
                label = gtk.Label('Type')
                label.modify_font(pango.FontDescription("sans 7"))

...and (for completeness) this code changes the column *data* font 

                font = pango.FontDescription('sans 7')
                self.note_type_cell = gtk.CellRendererText()
                self.note_type_cell.set_property('font-desc', font)


More information about the pygtk mailing list