[wxPython-users] Re: wx.grid column sizing
Robin Dunn
robin at alldunn.com
Mon Feb 25 10:45:40 PST 2008
Randall Smith wrote:
> Robin Dunn wrote:
>
>>
>> wx.DC.GetTextExtent
>>
>
> Does this look right? My widths are coming up a bit short. About 5
> pixels short.
>
> dg_font = wx.Font(10, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL,
> wx.FONTWEIGHT_NORMAL)
> dc = wx.MemoryDC()
> width = dc.GetTextExtent(text, font=dg_font)[0]
It probably isn't the same font that is being used in the grid. Try
using grid.GetFont() instead, or if you are setting different fonts for
the cells then you can get the cell attribute object and use the font
returned by it. Also, you should have a bitmap selected into the
MemoryDC as it is not valid without it on some platforms.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list