Phoenix icon indicating copy to clipboard operation
Phoenix copied to clipboard

SetHeaderHeight does not work in UltimateListCtrl

Open ras37srq opened this issue 3 years ago • 3 comments

Win-11 64-bit: wxPython-4.2.0-cp39-cp39-win_amd64.whl (installed via pip): Python 3.9.10 stock:

*Description of the problem Cannot control the height of the column headers in UltimateListCtrl: In the example code, the text in each column is default size but has 2 newlines. This requires increasing the column height to see the entire header but .SetHeaderHeight does nothing.

Code Example (click to expand)
import wx
        
from wx.lib.agw import ultimatelistctrl as ULC
import wx.lib.agw as AGW

hdrCol0 = f'Spanish\n(Americas)\ntext'
hdrCol1 = f'Spanish\n(Americas)\naudio'


app = wx.App(redirect=True)
top = wx.Frame(None, title="Bad Header-Row Height", size=(500,400))

agwStyle = ( ULC.ULC_HAS_VARIABLE_ROW_HEIGHT | wx.LC_REPORT )
progress = ULC.UltimateListCtrl(top, agwStyle=agwStyle)

progress.InsertColumn(0, hdrCol0)
progress.InsertColumn(1, hdrCol1)


# The following line does NOT change the height of the
# column-header row regardless of its value, so I cannot
# make the headers completely visible
progress.SetHeaderHeight(200)


top.Show()
app.MainLoop()

ras37srq avatar Aug 16 '22 19:08 ras37srq

I am hitting the same problem on MacOS.

garyrob avatar Mar 31 '25 00:03 garyrob

A simple, possible solution is to add the marked line in SetHeaderHeight:


    def SetHeaderHeight(self, height):
        """
        Sets the :class:`UltimateListHeaderWindow` height, in pixels. This overrides the default
        header window size derived from :class:`RendererNative`. If `height` is ``None``, the
        default behaviour is restored.

        :param `height`: the header window height, in pixels (if it is ``None``, the default
         height obtained using :class:`RendererNative` is used).
        """

        if not self._headerWin:
            return

        if height is not None and height < 1:
            raise Exception("Invalid height passed to SetHeaderHeight: %s"%repr(height))

        self._headerWin._headerHeight = height
        self._headerWin.InvalidateBestSize()            # <==== THIS LINE
        self.DoLayout()

Andrea.

infinity77 avatar Mar 31 '25 08:03 infinity77

See if this flies:

https://github.com/wxWidgets/Phoenix/pull/2729

infinity77 avatar Mar 31 '25 12:03 infinity77