Re: modifying wx.Rect() returned from ListCtrl.GetItemRect(item)

Robin Dunn <[email protected]> Tue, 22 May 2018 16:04:55 -0700 (PDT)
Newsgroups gmane.comp.python.wxpython.devel
Message-ID <[email protected]>
On Tuesday, May 22, 2018 at 11:52:49 AM UTC-7, kg*2 wrote:
>
> Hi,
>     I'm having some difficulty modifying the wx.Rect returned from 
> ListCtrl.GetItemRect(n).  I'm trying to increase the width of list items in 
> a ListCtrl with the LC_ICON flags via
>
> for n, app in enumerate(collection.get_apps()):
>     self.applist.InsertItem(n, app.get_name(), ids[n])
>
>     print(self.applist.GetItemRect(n))
>
>     rect = self.applist.GetItemRect(n)
>     print(f"old: {rect.GetWidth()}")
>     rect.SetWidth(rect.GetWidth()+50)
>     self.RefreshRect(rect)
>     print(f"new: {rect.GetWidth()}")
>     self.applist.RefreshItem(n)
>
>
> But this doesn't appear to change the actual wx.Rect associated with the list item. I'd like to make the items large enough so that the ListCtrl doesn't truncate the text. Any advice is appreciated.
>
>

It doesn't work that way. The wxRect returned from GetItemRect is not the 
actual rectangle object used by the control but rather a copy. In fact, on 
Windows the native control uses a RECT structure which is translated to a 
new instance of wxRect to be returned. AFAICT we don't have any way to 
change the size of ListCtrl items, but you may be able to do something with 
UltimateListCtrl in AGW. Perhaps via a custom derived class.

--
Robin


 

-- 
You received this message because you are subscribed to the Google Groups "wxPython-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.