Hi again Frank,
Hi Frank,
> Hi Andrea, I was trying to add support for Italic items and it seems
> like CustomTreeCtrl.SetItemItalic() isn't working. I tried it in the
> wxPython demo (look for SetItemBold and replace by SetItemItalic) and
> it doesn't work there either. Any ideas?
It looks like the if condition at line 2493 in customtreectrl.py:
if itemFont != wx.NullFont:
is not True, i.e. the item font is really a wx.NullFont (!). I don't
know how this is possible, I mean, the items are drawn with a font
(whether it is the default system font or not I don't care), so the
font can't be a wx.NullFont.
Ok, I think I found the problem. GetItemFont() returns something like:
item.Attr().GetFont()
Where Attr() is the TreeItemAttr class, where fonts and
foreground/background colours are set. The main problem is that, by
default, that class is initialized as:
class TreeItemAttr:
"""Creates the item attributes (text colour, background colour and font)."""
def __init__(self, colText=wx.NullColour, colBack=wx.NullColour,
font=wx.NullFont):
"""
Default class constructor.
For internal use: do not call it in your code!
"""
self._colText = colText
self._colBack = colBack
self._font = font
So, normally the item font (unless explicitely set by the programmer),
is really a wx.NullFont.
The simplest fix I can think of is to substitute the line:
self._font = font
With these 2 lines in the TreeItemAttr class initialization:
systemFont = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
self._font = (font == wx.NullFont and [systemFont] or [font])[0]
It works for me here. What do you all think?
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/
···
On 2/7/07, Andrea Gavana wrote: