UltimateListControl setting item background colour & font

I’ve been fiddling with this for a while, but have been having a few issues with row background colour and font.

In the name of legibility, I wanted to have this list colour every other row a light grey colour, and set all lines to 18 point font.

The problem I’m having is, if I set the font before changing the colour, the font completely resets back to the system size;

If I set the colour first, the font overrides the background colours with white. Is there something I’m doing wrong?

Also, I’d like to be able to set individual cell fonts, for example everything in the Name column to boldfont, but I’ve

only seen so far the ultimateListCtrl.SetItemFont() method, which only controls a single row.

UltimateList.py (4.87 KB)

Hi,

I've been fiddling with this for a while, but have been having a few issues
with row background colour and font.
In the name of legibility, I wanted to have this list colour every other row
a light grey colour, and set all lines to 18 point font.

The problem I'm having is, if I set the font before changing the colour, the
font completely resets back to the system size;
If I set the colour first, the font overrides the background colours with
white. Is there something I'm doing wrong?

Nothing that I can see, it's probably a bug in ULC but I am unable to
pin it down. Fortunately, there is a workaround. You should do the
following:

1) If you dont have it already, get the SVN version of ULC here:

http://svn.wxwidgets.org/viewvc/wx/wxPython/3rdParty/AGW/agw/ultimatelistctrl.py?view=co

And overwrite the one in wx.lib.agw;

2) In ultimatelistctrl.py, comment out the line 2676 (i.e., the line
that contains the "del self._backColour" code);

3) Try the attached file.

I'll fix the SVN version tonight when I get home.

Also, I'd like to be able to set individual cell fonts, for example
everything in the Name column to boldfont, but I've
only seen so far the ultimateListCtrl.SetItemFont() method, which only
controls a single row.

Something like this should work:

        mask = ULC.ULC_MASK_FONT

        item = self.ultimateList.GetItem(row, col)
        item.SetMask(mask)
        item.SetFont(your_font)
        self.ultimateList.SetItem(item)

Andrea.

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

UltimateList.py (4.8 KB)

···

On 25 April 2012 09:39, redxine wrote:

Thank you for the quick reply. I originally was almost certain that the problem was

in my own code, but I guess I wasn’t brave enough to venture into wx’s standard

library haha. Commenting out line 2676 alone didn’t work, but after a bit studying

the SetItemFont() method, I fixed it with an added line. I’ve attached the patch

against the SVN version you linked me to. (By no means is it special or thorough,

this is the first patch I’ve ever submitted lol). The magical addition was an:

info.SetBackgroundColour(self.GetItemBackgroundColour(item))

in the SetItemFont() method.

ulc.patch (163 KB)

···

On Wednesday, 25 April 2012 14:18:32 UTC+2, Infinity77 wrote:

Hi,
On 25 April 2012 09:39, redxine wrote:

I’ve been fiddling with this for a while, but have been having a few issues
with row background colour and font.
In the name of legibility, I wanted to have this list colour every other row
a light grey colour, and set all lines to 18 point font.

The problem I’m having is, if I set the font before changing the colour, the
font completely resets back to the system size;
If I set the colour first, the font overrides the background colours with
white. Is there something I’m doing wrong?

Nothing that I can see, it’s probably a bug in ULC but I am unable to
pin it down. Fortunately, there is a workaround. You should do the
following:

  1. If you dont have it already, get the SVN version of ULC here:

http://svn.wxwidgets.org/viewvc/wx/wxPython/3rdParty/AGW/agw/ultimatelistctrl.py?view=co

And overwrite the one in wx.lib.agw;

  1. In ultimatelistctrl.py, comment out the line 2676 (i.e., the line
    that contains the “del self._backColour” code);
  1. Try the attached file.

I’ll fix the SVN version tonight when I get home.

Also, I’d like to be able to set individual cell fonts, for example
everything in the Name column to boldfont, but I’ve
only seen so far the ultimateListCtrl.SetItemFont() method, which only
controls a single row.

Something like this should work:

mask = ULC.ULC_MASK_FONT

item = self.ultimateList.GetItem(row, col)
item.SetMask(mask)
item.SetFont(your_font)
self.ultimateList.SetItem(item)

Andrea.

“Imagination Is The Only Weapon In The War Against Reality.”
http://xoomer.alice.it/infinity77/

Hi,

Thank you for the quick reply. I originally was almost certain that the
problem was
in my own code, but I guess I wasn't brave enough to venture into wx's
standard
library haha. Commenting out line 2676 alone didn't work, but after a bit
studying
the SetItemFont() method, I fixed it with an added line. I've attached the
patch
against the SVN version you linked me to. (By no means is it special
or thorough,
this is the first patch I've ever submitted lol). The magical addition was
an:

info.SetBackgroundColour(self.GetItemBackgroundColour(item))

in the SetItemFont() method.

Thank you for the patch, I have applied it in SVN, although it's just
a workaround because setting the font and the background colour should
not have failed in the first place and these attributes should be
handled by the item "_attr" structure.

Anyway, I have applied in nevertheless; as a suggestion, next time
please use the unified diff to create a patch, possibly discarding
white spaces differences... your real patch was just one line but the
patch file ended up being 170 KB :wink:

Andrea.

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

···

On 25 April 2012 15:18, redxine wrote:

Strange, I specified -u. I didn't think there'd be more than 3 lines
disunity.
Ah well. :3

···

On 25 April 2012 19:06, Andrea Gavana <andrea.gavana@gmail.com> wrote:

Hi,

On 25 April 2012 15:18, redxine wrote:
> Thank you for the quick reply. I originally was almost certain that the
> problem was
> in my own code, but I guess I wasn't brave enough to venture into wx's
> standard
> library haha. Commenting out line 2676 alone didn't work, but after a bit
> studying
> the SetItemFont() method, I fixed it with an added line. I've attached
the
> patch
> against the SVN version you linked me to. (By no means is it special
> or thorough,
> this is the first patch I've ever submitted lol). The magical addition
was
> an:
>
> info.SetBackgroundColour(self.GetItemBackgroundColour(item))
>
>
> in the SetItemFont() method.

Thank you for the patch, I have applied it in SVN, although it's just
a workaround because setting the font and the background colour should
not have failed in the first place and these attributes should be
handled by the item "_attr" structure.

Anyway, I have applied in nevertheless; as a suggestion, next time
please use the unified diff to create a patch, possibly discarding
white spaces differences... your real patch was just one line but the
patch file ended up being 170 KB :wink:

Andrea.

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

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en