wx.lib.agw.ultimatelistctrl and refresh trigger on MacOS

Hello,

So I'm in the following situation, on MacOS 10.7.2, wx version 2.8.12.0:

I have a ultimatelistctrl

class UltimateListCtrl(ULC.UltimateListCtrl,
listmix.ListCtrlAutoWidthMixin, listmix.ListRowHighlighter):
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=0, agwStyle=ULC.ULC_NO_HIGHLIGHT):
ULC.UltimateListCtrl.__init__(self, parent, id, pos, size, style, agwStyle)
listmix.ListCtrlAutoWidthMixin.__init__(self)
self.setResizeColumn("LAST")

This has some wx.lib.agw.hyperlink items added like:

data_structured_item = self.list.GetItem(index, 4)
hyper_link = hl.HyperLinkCtrl(self.list, wx.ID_ANY, text)
hyper_link.AutoBrowse(False)
hyper_link.SetBackgroundColour("white")
hyper_link.SetColours("#808080", "#808080", "BLUE")
hyper_link.EnableRollover(True)
hyper_link.SetUnderlines(False, False, False)
hyper_link.SetBold(True)
hyper_link.UpdateLink()
hyper_link.Bind(hl.EVT_HYPERLINK_LEFT, self.on_data_structured)
data_structured_item.SetWindow(hyper_link, True)
self.list.SetItem(data_structured_item)

But somehow, anytime some hyper_links are added/modified they all go
blank, until I do a mouse over event on one of them. Now I'm guessing
I'm missing some Layout() or Update() call somewhere but the situation
dazzles me. So:

If I do a mouse over on any of the hyperlinks they repaint fine. If I
click somewhere outside my frame, I'm guessing a wx.FocusEvent generated
also gets them to repaint fine. If I resize my frame, they also repaint
just fine. Now I tried something like sugested here:
WhenAndHowToCallLayout - wxPyWiki and tried with Layout()
Refresh() or Update(), none worked.

Finally I went the 'brute' way and:

while widget.GetParent():
widget = widget.GetParent()
if widget.IsTopLevel():
size = widget.GetSize()
widget.SetSize((size[0]+1, size[1]+1))
widget.SetSize(size)

This works fine, so I thought, oh cool seems like I have to generate a
resize event on the top level frame, but:

while widget.GetParent():
widget = widget.GetParent()
if widget.IsTopLevel():
widget.SendSizeEvent()

This doesnt work either.

So my questions would be:
1. What is the difference between:

widget.SetSize((size[0]+1, size[1]+1))
widget.SetSize(size)
and:
widget.SendSizeEvent()

It depends on the type of widget and what it does in it's default EVT_SIZE handler. Obviously there will be 2 size events in the first case and only one in the second, but also there will be newly exposed pixels in the first case so that will also trigger a EVT_PAINT event.

2. Is there some more proper way to handle the problem, like I'm missing
a call to something like Repaint() or Update() somewhere along there.

It seems you've already tried Refresh, which is what I would have suggested, so please make a runnable, small as possible, sample application that demonstrates the problem so we can take a closer look at what exactly you are doing or not doing. MakingSampleApps - wxPyWiki

···

On 11/25/11 2:06 AM, Neacsa Bogdan Valentin wrote:

--
Robin Dunn
Software Craftsman

Hi,

Well, I've tried making a sample as simple as I could. When pressing the
button a new row should be added, unfortunately the list isn't refreshed as
expected. (line 139 is where I try different calls). Now what I've noticed
while doing that, if I went recursive till the top widget and called both
Update, Refresh and Layout the list would refresh.
Going further I see that calling Update + Refresh on the parent will also do
the job. So I guess my question now becomes, why? I've atached the sample.

It works OK on Windows 7, Python 2.7, wxPython 2.9.2.4 and using the
latest ULC from SVN. I am not in a position to say if it is Mac
specific or not as I have no Mac to test this stuff on. In any case,
you may think of switching from wx.lib.agw.hyperlink to using
HyperText items in ULC directly, i.e.:

item = self.list.GetItem(index, column)
item.SetHyperText(True)
self.list.SetItem(item)

Andrea.

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

···

On 28 November 2011 11:08, Neacsa Bogdan Valentin wrote:

I'm not sure why, but I noticed that it does work correctly as-is with wxOSX-cocoa and the 2.9.2.4 release.

···

On 11/28/11 2:08 AM, Neacsa Bogdan Valentin wrote:

Well, I've tried making a sample as simple as I could. When pressing the
button a new row should be added, unfortunately the list isn't refreshed
as expected. (line 139 is where I try different calls). Now what I've
noticed while doing that, if I went recursive till the top widget and
called both Update, Refresh and Layout the list would refresh.

Going further I see that calling Update + Refresh on the parent will
also do the job. So I guess my question now becomes, why? I've atached
the sample.

--
Robin Dunn
Software Craftsman