Hi all. I’ve posted on SO and emailed Andrea Gavana, but no luck so I’m trying here.
I have a ULC and I want a column of ExpandoTextCtrls, but I can’t get any widget to resize and have the ULC redraw itself correctly. I’m working with a wx.Button that resizes itself when clicked just to simplify. When I do button.SetSize, the button resizes but overflows on top of neighbouring cells. The button’s position doesn’t change either.
The only way I could mimic the behavior I want is to actually delete the entire item and re-insert a new button instance of a new size, then call the list’s SendSizeEvent. Sending the SizeEvent didn’t have any effect after simply modifying the original button.
I tried to look at the ULC source to figure out what the difference is between inserting a new item and modifying one, the block quote (docstring) in the on_button method is my attempt to do that but unsuccessfully. I basically just took the last few lines from ULC.UltimateListMainWindow and mimiced them, setting the state to _dirty=True and calling RefreshLines. This has no effect.
I’ve attached my code, its just boilerplate ULC creation, plus a button and an Expando in a list.
I would appreciate either a suggestion on how I can accomplish the original goal in a new way (a multi-column list with a column of expandos), or help on where to start subclassing ULC’s internal behavior to force a complete re-draw when a subwindow changes size.
i found a way to resize the row with the expando text ctrl. But sometimes the row height is reset and if the text ctrl grows bigger than the window, it wont scroll down. But at least it’s something you can experiment with
I’v added a binding to EVT_ETC_LAYOUT_NEEDED. When the event occurs do:
newHeight = event.height
line = self.ultimateList._mainWin.GetLine(2)
line.SetHeight(newHeight)
self.ultimateList.RefreshItem(2)
Thanks for looking at it. That did help somewhat, but still lines after the expando don’t get redrawn based on the expando’s new height. It seems the ULC only checks the size of a window sub-item only on line creation, and the only way to force it to recheck I’ve found seems to be to modify ultimatelistctrl.py internally. Lokla on stack overflow helped me get it working perfectly my changing the UltimateListItemData.GetWindowSize method from
def GetWindowSize(self):
“”" Returns the associated window size. “”"
return self._windowsize
to
def GetWindowSize(self):
""" Returns the associated window size. """
wnd = self. _wnd
if wnd.GetSizer(): # the window is a complex one hold by a sizer
size = wnd.GetBestSize()
else: # simple window, without sizers
size = wnd.GetSize()
print(size)
return size
and then call these in the OnEtcLayout:
self.ultimateList._mainWin.ResetLineDimensions(True)
self.ultimateList._mainWin.RecalculatePositions()
I realize this is not best practice but is the only way I have been able to get a fully working solution. If the author of ULC is accepting patches I’d be happy to help write that, but if not I’ll just keep the modified file locally and package it with my particular app.