Getting default font of items in a (Custom)Tree(List)Ctrl

Hi list,

How do I get the font that is used by default for items in a TreeCtrl,
a TreeListCtrl and a CustomTreeCtrl?

I tried tree.GetItemFont(item) but that returns wx.NullFont

I tried wx.TreeCtrl.GetClassDefaultAttributes().font but that returns
wx.NullFont too. BTW, CustomTreeCtrl.GetClassDefaultAttributes is not
a class method, is that a bug?

I tried tree.GetFont(), and that works for a wx.TreeCtrl. But for a
wx.gizmos.TreeListCtrl, tree.GetFont returns a font that is smaller
than the default font used for tree items and for CustomTreeCtrl it
returns a font that is bigger than the default font...

Thanks, Frank

Hi Frank,

How do I get the font that is used by default for items in a TreeCtrl,
a TreeListCtrl and a CustomTreeCtrl?

Uhm, after all your comments and your work of trial-and-error, I
honestly admit that I have no idea on how to do it consistently over
the 3 treectrls wxPython has.

I tried wx.TreeCtrl.GetClassDefaultAttributes().font but that returns
wx.NullFont too. BTW, CustomTreeCtrl.GetClassDefaultAttributes is not
a class method, is that a bug?

I think it's a bug. I didn't even know it had to be a class method. I
will make a small patch for Robin, if he can apply it for the next
release.

I tried tree.GetFont(), and that works for a wx.TreeCtrl. But for a
wx.gizmos.TreeListCtrl, tree.GetFont returns a font that is smaller
than the default font used for tree items and for CustomTreeCtrl it
returns a font that is bigger than the default font...

That's nice, eh? :wink: . Well, if someone is able to make wx.TreeCtrl
*and* wx.gizmos.TreeListCtrl behave in the same way, I think that
CustomTreeCtrl can be easily hacked to conform to them.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/

···

On 2/7/07, Frank Niessink wrote:

Frank Niessink wrote:

Hi list,

How do I get the font that is used by default for items in a TreeCtrl,
a TreeListCtrl and a CustomTreeCtrl?

I tried tree.GetItemFont(item) but that returns wx.NullFont

I tried wx.TreeCtrl.GetClassDefaultAttributes().font but that returns
wx.NullFont too. BTW, CustomTreeCtrl.GetClassDefaultAttributes is not
a class method, is that a bug?

I tried tree.GetFont(), and that works for a wx.TreeCtrl. But for a
wx.gizmos.TreeListCtrl, tree.GetFont returns a font that is smaller
than the default font used for tree items and for CustomTreeCtrl it
returns a font that is bigger than the default font...

wx.TreeCtrl on Windows will use whatever MS thinks is the default font for the native TreeView control, and it may or may not be influenced by the current theme on XP. For GTK and OSX it uses similar code to TreeListCtrl described below.

TreeListCtrl uses wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) for MSW and GTK. On OSX it uses the port-specific function MacCreateThemeFont(kThemeViewsFont).

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

wx.TreeCtrl on Windows will use whatever MS thinks is the default font
for the native TreeView control, and it may or may not be influenced by
the current theme on XP. For GTK and OSX it uses similar code to
TreeListCtrl described below.

OK, but how do I ask a TreeCtrl which font is it is using for tree
items? Is TreeCtrl.GetFont() supposed to be used for that?

TreeListCtrl uses wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) for
MSW and GTK. On OSX it uses the port-specific function
MacCreateThemeFont(kThemeViewsFont).

Same question here: how do I ask the TreeListCtrl what that font is?

Thanks, Frank

···

2007/2/8, Robin Dunn <robin@alldunn.com>:

Frank Niessink wrote:

···

2007/2/8, Robin Dunn <robin@alldunn.com>:

wx.TreeCtrl on Windows will use whatever MS thinks is the default font
for the native TreeView control, and it may or may not be influenced by
the current theme on XP. For GTK and OSX it uses similar code to
TreeListCtrl described below.

OK, but how do I ask a TreeCtrl which font is it is using for tree
items? Is TreeCtrl.GetFont() supposed to be used for that?

TreeListCtrl uses wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) for
MSW and GTK. On OSX it uses the port-specific function
MacCreateThemeFont(kThemeViewsFont).

Same question here: how do I ask the TreeListCtrl what that font is?

Yes, in most cases GetFont should do it, although on the Mac where it is changing the platform specific theme property it may end up not being the same thing from a wx vs. the UI perspective.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!