Use wxPython's wx.lib.dialogs.ScrolledMessageDialog() if you have to bring up a message box with a large amount of information:
# for a large information/message text uase wxPython's
# wx.lib.dialogs.ScrolledMessageDialog() widget
import wx
import wx.lib.dialogs
class MyPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, wx.ID_ANY)
self.SetBackgroundColour("blue")
# create an input widget
self.button1 = wx.Button(self, wx.ID_ANY,
label='The Zen of Python', pos=(10, 20))
# bind mouse event to an action
self.button1.Bind(wx.EVT_BUTTON, self.onAction)
def onAction(self, event):
""" some action code"""
# pick an informative textfile you have in the
# working directory (or use full path)
fin = open("ZenPy.txt", "r")
info = fin.read()
fin.close()
dlg = wx.lib.dialogs.ScrolledMessageDialog(self, info,
"The Zen of Python, by Tim Peters ...")
dlg.SetBackgroundColour('brown')
dlg.ShowModal()
info_text = """\
The Zen of Python, by Tim Peters ...
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one, and preferably only one obvious way to do it.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea, let's do more of them!
"""
# create …