On Tue, Jun 4, 2013 at 1:41 PM, Yuming Cao <
yumin...@cyaninc.com> wrote:
> Not really, since I'm trying display a selectable message dialog, most of
> the time, the text message is short, the textctrl's behavior is kind of
> weird. If I set its size too large, the text alignment is strange, if too
> small, there's scroll bar on the side, which is not ideal for a message box.
What do you mean by a "selectable" message dialog? What is the
purpose of the thing you are trying to create?
I don't think the TextCtrl's behavior is weird or the alignment is
strange; it strikes me as perfectly reasonable for a text control.
What is probably the issue is that you are using the wrong widget for
your purpose, unless you have a very long (paragraphs long) message to
display to the user, in which case then a TextCtrl might be
appropriate (for something almost like a README.txt file). For
shorter messages to the user, why not use StaticText (or, better yet,
see next point).
Is there a reason why the standard wx.MessageDialog, the
GenericMessageDialog or the ScrolledMessageDialog aren't sufficient
for your purposes?
Also, are you aware of the textwrap module, which can help to make
message widths look nicer by constraining them to something
reasonable, like 70 characters wide:
import sys
import textwrap
message = 'This message is pretty long if it is not wrapped to a ' \
'nicer length, so it is a good idea to
consider using textwrap ' \
'to shorten the length of it so that it looks
a bit better in the ' \
'messageDialog that you are using to display
this message.'
if sys.platform == "win32":
lines = textwrap.wrap(message,70)
message = "\n".join(lines)
dlg = wx.MessageDialog(self, message, 'wrapped msg'', wx.OK | wx.ICON_WARNING)
etc...