String extent in wxListCtrl

Anakim,

You might want to look at the demo, it uses an mixin to autosize the columns, works not too badly for me.

See you
Werner

Anakim Border wrote:

···

I'm using a wxListCtrl in report mode to display a file list. Since I know, for example, that file size is never showed with more than 5 digits, I'd like to change its column width to gain space for other fields.
The naive approach is to call wxWindow::GetCharWidth and to multiply the return value by 5, but this doesn't work well since wxListCtrl is using a proportional font.
So I did something like:

dc = wx.WindowDC(list)
width, height = dc.GetTextExtent('99999')
list.SetColumnWidth(2, width)

This doesn't help either, since width is underestimated (the list only shows 3 digits); the same happens with

dc.GetFullTextExtent('99999', font = list.GetFont())

Is there any (other) way to obtain the correct text extent?

--
Anakim Border
aborder@users.sourceforge.net

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org