[wxPython-users] wx.grid column sizing
Raffaello Barella
barbarossa.platz at gmail.com
Sat Feb 23 23:11:58 PST 2008
To me, wx.DC.GetTextExtent works fine if the text is on a single line, but
if I add one or more linefeed escape sequences ('\n') it keeps evaluating
the text as a single line.
2008/2/24, Robin Dunn <robin at alldunn.com>:
>
> Randall Smith wrote:
> > I'm developing an app that shows database results in a grid and trying
> > to keep performance a priority. I'm happy with the grid performance
> > using a subclass of PyGridTableBase (it's astonishing), but I lose those
> > gains when I need to choose a good size for my columns.
> >
> > grid.AutoSizeColumns is terribly slow even on a small data set. So I'm
> > considering these two approaches at the moment.
> >
> > 1. Get the width of the rendered column labels and set the width of the
> > columns to the label width or a minimum default. I can't figure out how
> > to get the width of the label text. Is there a straight forward way to
> > do this so that I get the correct width regardless of font size, style,
> > etc. Something like FontRenderSize(text, font_style, font_size)?
>
> wx.DC.GetTextExtent
>
>
> >
> > 2. Fake it. Build a temporary grid with a subset of the results, call
> > AutoSizeColumns (assuming it completes quickly on a very small data set)
> > and use those sizes. I guess it would be quicker to use the functions
> > used by AutoSizeColumns directly instead of creating a grid. Or would
> > it be quicker to write an algorithm in Python? Maybe a C
> extension? Hmm.
>
>
> AutoSizeColumns simply loops through all the values, and calls
> GetTextExtent on each of them and sets the width to the the max.
>
>
> --
> Robin Dunn
> Software Craftsman
> http://wxPython.org Java give you jitters? Relax with wxPython!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200802=
24/84130436/attachment.htm
More information about the wxpython-users
mailing list