set individual items and not whole row in UltimateListCtrl

I'd like to try out a few different looks for data presentation, and
am trying to use UltimateListCtrl. One thing I'd like to try is to
put one column (the whole column of items, not the col header) in bold
or a color, but I can't get that to work on even one row, let alone
all of them. I'm doing this:

count = self.listCtrl1.GetItemCount()
item = self.listCtrl1.InsertStringItem(count,my_text)
self.listCtrl1.SetStringItem(item,1,more_text)

#now set just the col 1 part of this row to blue
ULCitem = self.listCtrl1.GetItem(item,1)
ULCitem.SetTextColour(wx.BLUE)
self.listCtrl1.SetItem(ULCitem)

But when I do this, the whole row is blue, not just the 2nd col's
text. What am I doing wrong?

Also, I didn't see a method to just set all items in a given column to
bold or a color--did I miss it?

Thanks,
Che

Andrea may have a better answer as I've only looked at the ULC code very breifly, but until he is able to respond I'll give it a shot. The ULC is based on the C++ implementation of the generic wx.ListCtrl, and the wx.ListCtrl is not able to do what you want. So unless Andrea has added some new capabilities in this area then I'm afraid that you are probably out of luck. Each row in a report mode listctrl is considered a single item, and the only thing you can set independently for each column in the row is the text. All other attributes apply to the whole row.

If you dig into the ULC code you may find a different answer, or you may even be able to come up with a patch that adds the functionality that you want.

···

On 5/3/11 11:48 PM, C M wrote:

I'd like to try out a few different looks for data presentation, and
am trying to use UltimateListCtrl. One thing I'd like to try is to
put one column (the whole column of items, not the col header) in bold
or a color, but I can't get that to work on even one row, let alone
all of them. I'm doing this:

count = self.listCtrl1.GetItemCount()
item = self.listCtrl1.InsertStringItem(count,my_text)
self.listCtrl1.SetStringItem(item,1,more_text)

#now set just the col 1 part of this row to blue
ULCitem = self.listCtrl1.GetItem(item,1)
ULCitem.SetTextColour(wx.BLUE)
self.listCtrl1.SetItem(ULCitem)

But when I do this, the whole row is blue, not just the 2nd col's
text. What am I doing wrong?

Also, I didn't see a method to just set all items in a given column to
bold or a color--did I miss it?

--
Robin Dunn
Software Craftsman

But when I do this, the whole row is blue, not just the 2nd col's
text. What am I doing wrong?

Also, I didn't see a method to just set all items in a given column to
bold or a color--did I miss it?

Andrea may have a better answer as I've only looked at the ULC code very
breifly, but until he is able to respond I'll give it a shot. The ULC is
based on the C++ implementation of the generic wx.ListCtrl, and the
wx.ListCtrl is not able to do what you want. So unless Andrea has added
some new capabilities in this area then I'm afraid that you are probably out
of luck. Each row in a report mode listctrl is considered a single item,
and the only thing you can set independently for each column in the row is
the text. All other attributes apply to the whole row.

Unless I'm misunderstanding something, it seems it must be possible
with ULC, because it is shown doing just this in the demo. (e.g.
"Sinead O'Connor" is in light pink text in col 0 and "Nothing Compares
to You" is in bold blue text in col 1, in the same row). I'll keep
trying and if I get it post what I did, or failing that hope that
Andrea will emerge from the depths of an oil well and provide the
clue. :smiley:

-Che

···

If you dig into the ULC code you may find a different answer, or you may
even be able to come up with a patch that adds the functionality that you
want.

--
Robin Dunn
Software Craftsman
http://wxPython.org

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

But when I do this, the whole row is blue, not just the 2nd col's
text. What am I doing wrong?

I can answer my own question. A dumb mistake: I thought I was
changing things in an UltimateListCtrl, but I forgot that in my code I
swap out a regular ListCtrl for an AutoWidthListCtrl (which is not on
the palette in Boa), and forgot to replace the ULC at that point. So
anything I did was acting on an AutoWidthListCtrl, not an ULC.

...But now I am trying to create a smaller runnable sample to see what
I can do with the ULC but am having problems with even that. I'm
attaching what I have. Can someone help me get this to simply display
two columns, and 2-3 rows with at least one item (meaning just one
word in its own "cell") bolded and in a different color? Like just
row2, col1 (where col 1 = 2nd column).

Thanks,
Che

ULC_test.py (2.8 KB)

This is an improved small runnable sample that at least shows a
running UltimateListCtrl, but the call to .SetTextColour() is not
changing the color for me eve for the whole row (on WinXP, python 2.5,
wxPython 2.8.10.1).

What am I missing?

Thanks,
Che

ULC_test.py (3.03 KB)

self.listCtrl1.SetItem(item)

You need to send the changes in the item back to the ULC.

···

On 5/4/11 9:34 PM, C M wrote:

This is an improved small runnable sample that at least shows a
running UltimateListCtrl, but the call to .SetTextColour() is not
changing the color for me eve for the whole row (on WinXP, python 2.5,
wxPython 2.8.10.1).

What am I missing?

--
Robin Dunn
Software Craftsman

Thanks, but just tried it; unfortunately the color is still black.

···

On Thu, May 5, 2011 at 1:09 PM, Robin Dunn <robin@alldunn.com> wrote:

On 5/4/11 9:34 PM, C M wrote:

This is an improved small runnable sample that at least shows a
running UltimateListCtrl, but the call to .SetTextColour() is not
changing the color for me eve for the whole row (on WinXP, python 2.5,
wxPython 2.8.10.1).

What am I missing?

self.listCtrl1.SetItem(item)

You need to send the changes in the item back to the ULC.

It works for me in your sample, perhaps you have an older version of the ULC code? If not, then you have the ULC source code so perhaps you can figure out what needs to be done differently or what is going wrong by tracing through it with a debugger. From a quick glance at the demo it looks like if all else fails you can at least plug in a renderer that draws the content however you want it to be drawn.

···

On 5/5/11 10:53 AM, C M wrote:

On Thu, May 5, 2011 at 1:09 PM, Robin Dunn<robin@alldunn.com> wrote:

On 5/4/11 9:34 PM, C M wrote:

This is an improved small runnable sample that at least shows a
running UltimateListCtrl, but the call to .SetTextColour() is not
changing the color for me eve for the whole row (on WinXP, python 2.5,
wxPython 2.8.10.1).

What am I missing?

self.listCtrl1.SetItem(item)

You need to send the changes in the item back to the ULC.

Thanks, but just tried it; unfortunately the color is still black.

--
Robin Dunn
Software Craftsman

Thanks, but just tried it; unfortunately the color is still black.

It works for me in your sample, perhaps you have an older version of the ULC
code?

Thanks--that must have been it; I upgraded from SVN and it worked.
Unfortunately I still can't get a subitem to be its own color, despite
exactly that being shown in the demo and the demo's code showing that
.GetItem() takes both row and col as arguments, so it seems like if I
did:

item = listCtrl.GetItem(0,1)
item.SetTextColour(wx.RED)
listCtrl.SetItem(item)

then only the text in the 0th row, 1st col should be red. But no,
it's the whole row when I do this.

Plus every time I get an error using ULC in my sample, it crashes with
"Python.exe has had an error and has to close." sort of error, and
therefore no error message to give me clues, so it has been hard to
figure this out.

Che

Thanks for this thread! It would be really nice if the ULC docs could be updated so they’re a bit more clear.

Unfortunately the idea isn’t working completely for me… I’m trying to set only certain items ( (index, column) based, not the whole row) to be editable.

First I tried adding a checkbox to only certain items (index, column based) using ULC_MASK_CHECK which didn’t seem to work, I ended up just adding a wx.CheckBox to the specific item instead using SetWindow (since when is a CheckBox a window anyway???) so I guess trying to set ULC_EDIT_LABELS is no different.

I can only hope I’m wrong and that I’m missing something trivial, as I really don’t want to spend time subclassing listctrl so I can make StaticText into TextCtrl on click/double-click, and then I’d probably also have to figure out how to manually add a CheckBox to any cell also…

Here is what I’ve got code-wise so far:

···

On Thursday, May 5, 2011 11:59:32 PM UTC-7, Che M wrote:

Thanks, but just tried it; unfortunately the color is still black.
It works for me in your sample, perhaps you have an older version of the ULC
code?

Thanks–that must have been it; I upgraded from SVN and it worked.
Unfortunately I still can’t get a subitem to be its own color, despite
exactly that being shown in the demo and the demo’s code showing that
.GetItem() takes both row and col as arguments, so it seems like if I
did:

item = listCtrl.GetItem(0,1)
item.SetTextColour(wx.RED)
listCtrl.SetItem(item)

then only the text in the 0th row, 1st col should be red. But no,
it’s the whole row when I do this.

Plus every time I get an error using ULC in my sample, it crashes with
“Python.exe has had an error and has to close.” sort of error, and
therefore no error message to give me clues, so it has been hard to
figure this out.

Che

I just realized that even the UltimateListControl demo only allows the first column to be editable…

···

On Friday, May 2, 2014 2:40:03 PM UTC-7, Nathan McCorkle wrote:

Thanks for this thread! It would be really nice if the ULC docs could be updated so they’re a bit more clear.

Unfortunately the idea isn’t working completely for me… I’m trying to set only certain items ( (index, column) based, not the whole row) to be editable.

First I tried adding a checkbox to only certain items (index, column based) using ULC_MASK_CHECK which didn’t seem to work, I ended up just adding a wx.CheckBox to the specific item instead using SetWindow (since when is a CheckBox a window anyway???) so I guess trying to set ULC_EDIT_LABELS is no different.

I can only hope I’m wrong and that I’m missing something trivial, as I really don’t want to spend time subclassing listctrl so I can make StaticText into TextCtrl on click/double-click, and then I’d probably also have to figure out how to manually add a CheckBox to any cell also…

Here is what I’ve got code-wise so far:

http://pastebin.com/A1JyKKNC

On Thursday, May 5, 2011 11:59:32 PM UTC-7, Che M wrote:

Thanks, but just tried it; unfortunately the color is still black.
It works for me in your sample, perhaps you have an older version of the ULC
code?

Thanks–that must have been it; I upgraded from SVN and it worked.
Unfortunately I still can’t get a subitem to be its own color, despite
exactly that being shown in the demo and the demo’s code showing that
.GetItem() takes both row and col as arguments, so it seems like if I
did:

item = listCtrl.GetItem(0,1)
item.SetTextColour(wx.RED)
listCtrl.SetItem(item)

then only the text in the 0th row, 1st col should be red. But no,
it’s the whole row when I do this.

Plus every time I get an error using ULC in my sample, it crashes with
“Python.exe has had an error and has to close.” sort of error, and
therefore no error message to give me clues, so it has been hard to
figure this out.

Che