Hi,
2009/12/10 Mike Driscoll:
> Hi,
>
> On Dec 10, 2:51 pm, Reckoner <
recko...@gmail.com> wrote:
>> thanks for your reply.
>>
>> I looked at the CustomCheckBox per your direction, and it seems that
>> you can change the text height in the label for the checkbox, but I'm
>> not sure how you would get the line wrap that way, say, by inserting
>> the newline '\n' character into the string.
>>
>> Any more hints?
>>
>> Thanks in advance
>>
>
> Did you try the wordwrap module? See here:
>
>
http://www.wxpython.org/docs/api/wx.lib.wordwrap-module.html
>
> I'm not sure if that will work in this case or not.
It will, although the textwrap module is best suited for this task.
Basically, what you should do is set up a wx.EVT_SIZE handler like
this (highly untested):
self.Bind(wx.EVT_SIZE, self.OnSize)
def OnSize(self, event):
width, height = event.GetSize()
lines = textwrap.wrap(self.GetLabel(), width)
self.SetLabel("\n".join(lines))
event.Skip()
Then, in the DoGetBestSize you need to use GetMultiLineTextExtent
instead of GetTextExtent (and everywhere else too). And, in the
OnPaint method, you should either use dc.DrawLabel or multiple calls
to dc.DrawText (in a number equal to the number of lines).