ListCtrl with LC_LIST style and font problem

I’ve recently migrated from using Python 2.5 and wxpython 2.8.11.0 to Python 2.7.3 and 2.9.4.0. Most of this went smoothly, save for this one problem I’m having with ListCtrl’s. I’m using Windows 7 64bit, but 32bit Python and packages.

Basically I want a wx.ListCtrl with the LC_LIST style to display some items. Because this will be viewed from a distance, I need to change increase the font size to 16pt. I also need to change the text color for each item as well change the font weight for each item. This worked fine for me in 2.8.11.0. I also tested 2.8.12.1 and it worked too. But in 2.9.4.0 the wx.ListCtrl seems to ignore my calls to SetItemTextColour and SetItemFont.

I thought I might be able to work around this by using UltimateListCtrl instead, but is has a problem of it’s own. Whichever method was the last called is the one that affects the list item. For example calling SetItemTextColour and then SetItemFont only changes the font, and calling SetItemFont and then SetItemTextColour only changes the color. And in 2.8.11.0, SetItemTextColour seems to have no effect.

If I change the style to use LC_REPORT instead, everything works fine. I’d rather have the LC_LIST though, since it scrolls horizontally instead of vertically. This makes sense for my use case because I have more horizontal space and the interface is not going to be interacted with. It’s basically displaying some items on TV screens.

Another interesting note, I previously used:

font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)

font.SetPointSize(16)

Which worked fine in Python 2.5, but I had to switch to using:

font = wx.Font(pointSize=16, family=wx.FONTFAMILY_DEFAULT, style=wx.FONTSTYLE_ITALIC, weight=wx.FONTWEIGHT_NORMAL)

For Python 2.7.3 because the text in wx.ListCtrl was invisible… I guess something changed in the way system fonts are handled?

Attached is a sample application and screenshots from the different versions. Any help would be greatly appreciated.

Kyle Rickey

lists.py (1.63 KB)

2.8.12.1.png

2.9.4.0.png

2.8.11.0.png

I've recently migrated from using Python 2.5 and wxpython 2.8.11.0 to
Python 2.7.3 and 2.9.4.0. Most of this went smoothly, save for this one
problem I'm having with ListCtrl's. I'm using Windows 7 64bit, but 32bit
Python and packages.

Basically I want a wx.ListCtrl with the LC_LIST style to display some
items. Because this will be viewed from a distance, I need to change
increase the font size to 16pt. I also need to change the text color for
each item as well change the font weight for each item. This worked fine
for me in 2.8.11.0. I also tested 2.8.12.1 and it worked too. But in
2.9.4.0 the wx.ListCtrl seems to ignore my calls to SetItemTextColour
and SetItemFont.

I thought I might be able to work around this by using UltimateListCtrl
instead, but is has a problem of it's own. Whichever method was the last
called is the one that affects the list item. For example
calling SetItemTextColour and then SetItemFont only changes the font,
and calling SetItemFont and then SetItemTextColour only changes the
color. And in 2.8.11.0, SetItemTextColour seems to have no effect.

If I change the style to use LC_REPORT instead, everything works fine.
I'd rather have the LC_LIST though, since it scrolls horizontally
instead of vertically. This makes sense for my use case because I have
more horizontal space and the interface is not going to be interacted
with. It's basically displaying some items on TV screens.

Please create tickets about these issues at trac.wxwidgets.org (use separate tickets for the MSW and AGW parts of the problem.)

Another interesting note, I previously used:
     font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
     font.SetPointSize(16)
Which worked fine in Python 2.5, but I had to switch to using:
     font = wx.Font(pointSize=16, family=wx.FONTFAMILY_DEFAULT,
style=wx.FONTSTYLE_ITALIC, weight=wx.FONTWEIGHT_NORMAL)
For Python 2.7.3 because the text in wx.ListCtrl was invisible.. I guess
something changed in the way system fonts are handled?

I don't see that problem here. What does font.Ok() return?

···

On 8/8/12 8:29 AM, Kyle Rickey wrote:

--
Robin Dunn
Software Craftsman

The problem with the invisible test was only in 2.8. font.Ok() returns True when the font is created, but when getting the font of the item again with self.list.GetItem(0).GetFont().Ok() returns False. I’ll open a ticket on that as well.

···

On Wednesday, August 8, 2012 12:43:22 PM UTC-5, Robin Dunn wrote:

On 8/8/12 8:29 AM, Kyle Rickey wrote:

I’ve recently migrated from using Python 2.5 and wxpython 2.8.11.0 to

Python 2.7.3 and 2.9.4.0. Most of this went smoothly, save for this one

problem I’m having with ListCtrl’s. I’m using Windows 7 64bit, but 32bit

Python and packages.

Basically I want a wx.ListCtrl with the LC_LIST style to display some

items. Because this will be viewed from a distance, I need to change

increase the font size to 16pt. I also need to change the text color for

each item as well change the font weight for each item. This worked fine

for me in 2.8.11.0. I also tested 2.8.12.1 and it worked too. But in

2.9.4.0 the wx.ListCtrl seems to ignore my calls to SetItemTextColour

and SetItemFont.

I thought I might be able to work around this by using UltimateListCtrl

instead, but is has a problem of it’s own. Whichever method was the last

called is the one that affects the list item. For example

calling SetItemTextColour and then SetItemFont only changes the font,

and calling SetItemFont and then SetItemTextColour only changes the

color. And in 2.8.11.0, SetItemTextColour seems to have no effect.

If I change the style to use LC_REPORT instead, everything works fine.

I’d rather have the LC_LIST though, since it scrolls horizontally

instead of vertically. This makes sense for my use case because I have

more horizontal space and the interface is not going to be interacted

with. It’s basically displaying some items on TV screens.

Please create tickets about these issues at trac.wxwidgets.org (use
separate tickets for the MSW and AGW parts of the problem.)

Another interesting note, I previously used:

 font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
 font.SetPointSize(16)

Which worked fine in Python 2.5, but I had to switch to using:

 font = wx.Font(pointSize=16, family=wx.FONTFAMILY_DEFAULT,

style=wx.FONTSTYLE_ITALIC, weight=wx.FONTWEIGHT_NORMAL)

For Python 2.7.3 because the text in wx.ListCtrl was invisible… I guess

something changed in the way system fonts are handled?

I don’t see that problem here. What does font.Ok() return?


Robin Dunn

Software Craftsman

http://wxPython.org

Is it possible to use the generic ListCtrl on MSW? vadz made a comment about it on the ticket that I opened. "
SetItemTextColour() is explicitly documented as only working in report view. However testing this with the generic version (i.e. in wxGTK) I noticed that it did actually work in the list view there."

I noticed that you can force using the generic version on mac using:

wx.SystemOptions.SetOptionInt(``"mac.listctrl.always_use_generic", 1)

Anyway to do that on Windows?

Hi,

Is it possible to use the generic ListCtrl on MSW? vadz made a comment about
it on the ticket that I opened. " SetItemTextColour() is explicitly
documented as only working in report view. However testing this with the
generic version (i.e. in wxGTK) I noticed that it did actually work in the
list view there."

I noticed that you can force using the generic version on mac using:
wx.SystemOptions.SetOptionInt("mac.listctrl.always_use_generic", 1)

Anyway to do that on Windows?

You can not, as far as I know. But I have just committed a fix to
UltimateListCtrl in SVN which should correct the behaviour you were
seeing before. Please let me know if it works.

Andrea.

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

# ------------------------------------------------------------- #
def ask_mailing_list_support(email):

    if mention_platform_and_version() and include_sample_app():
        send_message(email)
    else:
        install_malware()
        erase_hard_drives()
# ------------------------------------------------------------- #

···

On 9 August 2012 19:26, Kyle Rickey wrote:

Andrea,

Your fix works as expected. Thanks a lot for fixing it so quickly, I owe you a beer!

Kyle Rickey

No worries, I will come and claim my beer as soon as I get close to
wherever you are :slight_smile:

Andrea.

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

# ------------------------------------------------------------- #
def ask_mailing_list_support(email):

    if mention_platform_and_version() and include_sample_app():
        send_message(email)
    else:
        install_malware()
        erase_hard_drives()
# ------------------------------------------------------------- #

···

On 9 August 2012 22:10, Kyle Rickey wrote:

Andrea,

Your fix works as expected. Thanks a lot for fixing it so quickly, I owe you
a beer!

No, at least not the C++ generic version. The AGW class is basically the generic version converted to Python and with lots of extra features added.

···

On 8/9/12 10:26 AM, Kyle Rickey wrote:

Is it possible to use the generic ListCtrl on MSW?

--
Robin Dunn
Software Craftsman