String extent in wxListCtrl

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?

Does using a wxClientDC make any difference? How about first doing dc.SetFont(list.GetFont()) ?

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Does using a wxClientDC make any difference?

No.

How about first doing dc.SetFont(list.GetFont()) ?

This solved the problem :wink:

Thanks for the help,
  Anakim Border
  aborder@users.sourceforge.net

···

On Thursday 02 October 2003 18:24, Robin Dunn wrote: