Widgets placed in the UltimateListControl are drawn in the wrong location
Operating system: MacOS 12.6.6 wxPython version & source: 4.2.0, conda-forge Python version & source: 3.11.3, conda
Description of the problem:
Widgets placed in the UltimateListControl in report mode don't show up in the correct cell but rather all get placed at the top of the list. You can see this from the wxpython demo. If you look at the demo code, the "I Am A Simple Multiline wx.TexCtrl" box is placed at (11, 0). However it shows up in the demo at the top of the list.
I ran into the same issue under Windows 10 Pro / Python 3.10.13 (conda) / wxPython 4.2.1 (conda-forge) and found the following fix:
In the following code of method UltimateListLineData.DrawInReportMode
if wnd:
xSize, ySize = item.GetWindowSize()
wndx = xOld - HEADER_OFFSET_X + width - xSize - 3
xa, ya = self._owner.CalcScrolledPosition((0, rect.y))
wndx += xa
if rect.height > ySize and not item._expandWin:
ya += (rect.height - ySize)/2
the division-operator in the last line is to be replaced by the floor division //.
In light of other commits that changed to floor division when calculating coordinates, this seems to be an obvious improvement and it works for me with this change. But be aware that my understanding of the code is very superficial and therefore cannot guarantee that this change solves the issue completely.
Also I found a workaround: if the widget is set with expand=True (item.SetWindow(widget, True)) by the application code, the issue also doesn't seem to occur.
Yes in a lot of circumstances, check the backslashes to be for a GUI being drawn as a pixel(Ex: We want an int)....
.... tho that may not be obvious at first ....